709a04a9c69cb3b40a28d53df257c1497b6c3551
[yaffs-website] / node_modules / grunt-legacy-util / node_modules / lodash / _assocDelete.js
1 var assocIndexOf = require('./_assocIndexOf');
2
3 /** Used for built-in method references. */
4 var arrayProto = Array.prototype;
5
6 /** Built-in value references. */
7 var splice = arrayProto.splice;
8
9 /**
10  * Removes `key` and its value from the associative array.
11  *
12  * @private
13  * @param {Array} array The array to query.
14  * @param {string} key The key of the value to remove.
15  * @returns {boolean} Returns `true` if the entry was removed, else `false`.
16  */
17 function assocDelete(array, key) {
18   var index = assocIndexOf(array, key);
19   if (index < 0) {
20     return false;
21   }
22   var lastIndex = array.length - 1;
23   if (index == lastIndex) {
24     array.pop();
25   } else {
26     splice.call(array, index, 1);
27   }
28   return true;
29 }
30
31 module.exports = assocDelete;