00167fad646752533f4ecdae43f1ac9f338073b2
[yaffs-website] / node_modules / grunt-legacy-log-utils / node_modules / lodash / _basePullAllBy.js
1 var arrayMap = require('./_arrayMap'),
2     baseIndexOf = require('./_baseIndexOf');
3
4 /** Used for built-in method references. */
5 var arrayProto = Array.prototype;
6
7 /** Built-in value references. */
8 var splice = arrayProto.splice;
9
10 /**
11  * The base implementation of `_.pullAllBy` without support for iteratee
12  * shorthands.
13  *
14  * @private
15  * @param {Array} array The array to modify.
16  * @param {Array} values The values to remove.
17  * @param {Function} [iteratee] The iteratee invoked per element.
18  * @returns {Array} Returns `array`.
19  */
20 function basePullAllBy(array, values, iteratee) {
21   var index = -1,
22       length = values.length,
23       seen = array;
24
25   if (iteratee) {
26     seen = arrayMap(array, function(value) { return iteratee(value); });
27   }
28   while (++index < length) {
29     var fromIndex = 0,
30         value = values[index],
31         computed = iteratee ? iteratee(value) : value;
32
33     while ((fromIndex = baseIndexOf(seen, computed, fromIndex)) > -1) {
34       if (seen !== array) {
35         splice.call(seen, fromIndex, 1);
36       }
37       splice.call(array, fromIndex, 1);
38     }
39   }
40   return array;
41 }
42
43 module.exports = basePullAllBy;