mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
22 lines
490 B
JavaScript
22 lines
490 B
JavaScript
define(['./_assocIndexOf'], function(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;
|
|
}
|
|
}
|
|
|
|
return assocSet;
|
|
});
|