mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
21 lines
456 B
JavaScript
21 lines
456 B
JavaScript
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;
|