source: node_modules/es-toolkit/dist/array/pull.js

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

Added visualizations

  • Property mode set to 100644
File size: 532 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5function pull(arr, valuesToRemove) {
6 const valuesSet = new Set(valuesToRemove);
7 let resultIndex = 0;
8 for (let i = 0; i < arr.length; i++) {
9 if (valuesSet.has(arr[i])) {
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
22exports.pull = pull;
Note: See TracBrowser for help on using the repository browser.