1 | import assocIndexOf from './_assocIndexOf';
|
2 |
|
3 | /**
|
4 | * Sets the associative array `key` to `value`.
|
5 | *
|
6 | * @private
|
7 | * @param {Array} array The array to modify.
|
8 | * @param {string} key The key of the value to set.
|
9 | * @param {*} value The value to set.
|
10 | */
|
11 | function assocSet(array, key, value) {
|
12 | var index = assocIndexOf(array, key);
|
13 | if (index < 0) {
|
14 | array.push([key, value]);
|
15 | } else {
|
16 | array[index][1] = value;
|
17 | }
|
18 | }
|
19 |
|
20 | export default assocSet;
|