mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
27 lines
685 B
JavaScript
27 lines
685 B
JavaScript
define(['./_Map', './_assocSet', './_hashSet', './_isKeyable'], function(Map, assocSet, hashSet, isKeyable) {
|
|
|
|
/**
|
|
* Sets the map `key` to `value`.
|
|
*
|
|
* @private
|
|
* @name set
|
|
* @memberOf MapCache
|
|
* @param {string} key The key of the value to set.
|
|
* @param {*} value The value to set.
|
|
* @returns {Object} Returns the map cache instance.
|
|
*/
|
|
function mapSet(key, value) {
|
|
var data = this.__data__;
|
|
if (isKeyable(key)) {
|
|
hashSet(typeof key == 'string' ? data.string : data.hash, key, value);
|
|
} else if (Map) {
|
|
data.map.set(key, value);
|
|
} else {
|
|
assocSet(data.map, key, value);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
return mapSet;
|
|
});
|