source: node_modules/es-toolkit/dist/array/partition.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 350 bytes
RevLine 
[a762898]1function partition(arr, isInTruthy) {
2 const truthy = [];
3 const falsy = [];
4 for (let i = 0; i < arr.length; i++) {
5 const item = arr[i];
6 if (isInTruthy(item, i, arr)) {
7 truthy.push(item);
8 }
9 else {
10 falsy.push(item);
11 }
12 }
13 return [truthy, falsy];
14}
15
16export { partition };
Note: See TracBrowser for help on using the repository browser.