source: trip-planner-front/node_modules/lodash/_basePullAll.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1var arrayMap = require('./_arrayMap'),
2 baseIndexOf = require('./_baseIndexOf'),
3 baseIndexOfWith = require('./_baseIndexOfWith'),
4 baseUnary = require('./_baseUnary'),
5 copyArray = require('./_copyArray');
6
7/** Used for built-in method references. */
8var arrayProto = Array.prototype;
9
10/** Built-in value references. */
11var splice = arrayProto.splice;
12
13/**
14 * The base implementation of `_.pullAllBy` without support for iteratee
15 * shorthands.
16 *
17 * @private
18 * @param {Array} array The array to modify.
19 * @param {Array} values The values to remove.
20 * @param {Function} [iteratee] The iteratee invoked per element.
21 * @param {Function} [comparator] The comparator invoked per element.
22 * @returns {Array} Returns `array`.
23 */
24function basePullAll(array, values, iteratee, comparator) {
25 var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
26 index = -1,
27 length = values.length,
28 seen = array;
29
30 if (array === values) {
31 values = copyArray(values);
32 }
33 if (iteratee) {
34 seen = arrayMap(array, baseUnary(iteratee));
35 }
36 while (++index < length) {
37 var fromIndex = 0,
38 value = values[index],
39 computed = iteratee ? iteratee(value) : value;
40
41 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
42 if (seen !== array) {
43 splice.call(seen, fromIndex, 1);
44 }
45 splice.call(array, fromIndex, 1);
46 }
47 }
48 return array;
49}
50
51module.exports = basePullAll;
Note: See TracBrowser for help on using the repository browser.