mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
456 B
21 lines
456 B
9 years ago
|
var assocIndexOf = require('./_assocIndexOf');
|
||
|
|
||
|
/**
|
||
|
* Sets the associative array `key` to `value`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} array The array to modify.
|
||
|
* @param {string} key The key of the value to set.
|
||
|
* @param {*} value The value to set.
|
||
|
*/
|
||
|
function assocSet(array, key, value) {
|
||
|
var index = assocIndexOf(array, key);
|
||
|
if (index < 0) {
|
||
|
array.push([key, value]);
|
||
|
} else {
|
||
|
array[index][1] = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = assocSet;
|