source: node_modules/es-toolkit/dist/compat/array/pullAllBy.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: 625 bytes
Line 
1import { iteratee } from '../util/iteratee.mjs';
2
3function pullAllBy(arr, valuesToRemove, _getValue) {
4 const getValue = iteratee(_getValue);
5 const valuesSet = new Set(Array.from(valuesToRemove).map(x => getValue(x)));
6 let resultIndex = 0;
7 for (let i = 0; i < arr.length; i++) {
8 const value = getValue(arr[i]);
9 if (valuesSet.has(value)) {
10 continue;
11 }
12 if (!Object.hasOwn(arr, i)) {
13 delete arr[resultIndex++];
14 continue;
15 }
16 arr[resultIndex++] = arr[i];
17 }
18 arr.length = resultIndex;
19 return arr;
20}
21
22export { pullAllBy };
Note: See TracBrowser for help on using the repository browser.