Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / globule / node_modules / lodash / _basePullAt.js
1 var castPath = require('./_castPath'),
2     isIndex = require('./_isIndex'),
3     isKey = require('./_isKey'),
4     last = require('./last'),
5     parent = require('./_parent'),
6     toKey = require('./_toKey');
7
8 /** Used for built-in method references. */
9 var arrayProto = Array.prototype;
10
11 /** Built-in value references. */
12 var splice = arrayProto.splice;
13
14 /**
15  * The base implementation of `_.pullAt` without support for individual
16  * indexes or capturing the removed elements.
17  *
18  * @private
19  * @param {Array} array The array to modify.
20  * @param {number[]} indexes The indexes of elements to remove.
21  * @returns {Array} Returns `array`.
22  */
23 function basePullAt(array, indexes) {
24   var length = array ? indexes.length : 0,
25       lastIndex = length - 1;
26
27   while (length--) {
28     var index = indexes[length];
29     if (length == lastIndex || index !== previous) {
30       var previous = index;
31       if (isIndex(index)) {
32         splice.call(array, index, 1);
33       }
34       else if (!isKey(index, array)) {
35         var path = castPath(index),
36             object = parent(array, path);
37
38         if (object != null) {
39           delete object[toKey(last(path))];
40         }
41       }
42       else {
43         delete array[toKey(index)];
44       }
45     }
46   }
47   return array;
48 }
49
50 module.exports = basePullAt;