source: node_modules/es-toolkit/dist/compat/array/pullAllBy.js@ ba17441

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

Added visualizations

  • Property mode set to 100644
File size: 732 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const iteratee = require('../util/iteratee.js');
6
7function pullAllBy(arr, valuesToRemove, _getValue) {
8 const getValue = iteratee.iteratee(_getValue);
9 const valuesSet = new Set(Array.from(valuesToRemove).map(x => getValue(x)));
10 let resultIndex = 0;
11 for (let i = 0; i < arr.length; i++) {
12 const value = getValue(arr[i]);
13 if (valuesSet.has(value)) {
14 continue;
15 }
16 if (!Object.hasOwn(arr, i)) {
17 delete arr[resultIndex++];
18 continue;
19 }
20 arr[resultIndex++] = arr[i];
21 }
22 arr.length = resultIndex;
23 return arr;
24}
25
26exports.pullAllBy = pullAllBy;
Note: See TracBrowser for help on using the repository browser.