UNPKG

755 BJavaScriptView Raw
1import mapClear from './_mapClear';
2import mapDelete from './_mapDelete';
3import mapGet from './_mapGet';
4import mapHas from './_mapHas';
5import mapSet from './_mapSet';
6
7/**
8 * Creates a map cache object to store key-value pairs.
9 *
10 * @private
11 * @constructor
12 * @param {Array} [values] The values to cache.
13 */
14function MapCache(values) {
15 var index = -1,
16 length = values ? values.length : 0;
17
18 this.clear();
19 while (++index < length) {
20 var entry = values[index];
21 this.set(entry[0], entry[1]);
22 }
23}
24
25// Add methods to `MapCache`.
26MapCache.prototype.clear = mapClear;
27MapCache.prototype['delete'] = mapDelete;
28MapCache.prototype.get = mapGet;
29MapCache.prototype.has = mapHas;
30MapCache.prototype.set = mapSet;
31
32export default MapCache;