source: node_modules/es-toolkit/dist/array/pull.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: 439 bytes
Line 
1function pull(arr, valuesToRemove) {
2 const valuesSet = new Set(valuesToRemove);
3 let resultIndex = 0;
4 for (let i = 0; i < arr.length; i++) {
5 if (valuesSet.has(arr[i])) {
6 continue;
7 }
8 if (!Object.hasOwn(arr, i)) {
9 delete arr[resultIndex++];
10 continue;
11 }
12 arr[resultIndex++] = arr[i];
13 }
14 arr.length = resultIndex;
15 return arr;
16}
17
18export { pull };
Note: See TracBrowser for help on using the repository browser.