Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / array / pull.js
1 var baseIndexOf = require('../internal/baseIndexOf');
2
3 /** Used for native method references. */
4 var arrayProto = Array.prototype;
5
6 /** Native method references. */
7 var splice = arrayProto.splice;
8
9 /**
10  * Removes all provided values from `array` using
11  * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
12  * for equality comparisons.
13  *
14  * **Note:** Unlike `_.without`, this method mutates `array`.
15  *
16  * @static
17  * @memberOf _
18  * @category Array
19  * @param {Array} array The array to modify.
20  * @param {...*} [values] The values to remove.
21  * @returns {Array} Returns `array`.
22  * @example
23  *
24  * var array = [1, 2, 3, 1, 2, 3];
25  *
26  * _.pull(array, 2, 3);
27  * console.log(array);
28  * // => [1, 1]
29  */
30 function pull() {
31   var args = arguments,
32       array = args[0];
33
34   if (!(array && array.length)) {
35     return array;
36   }
37   var index = 0,
38       indexOf = baseIndexOf,
39       length = args.length;
40
41   while (++index < length) {
42     var fromIndex = 0,
43         value = args[index];
44
45     while ((fromIndex = indexOf(array, value, fromIndex)) > -1) {
46       splice.call(array, fromIndex, 1);
47     }
48   }
49   return array;
50 }
51
52 module.exports = pull;