Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
var cachePush = require('./cachePush'),
2
getNative = require('./getNative');
3
4
/** Native method references. */
5
var Set = getNative(global, 'Set');
6
7
/* Native method references for those with the same name as other `lodash` methods. */
8
var nativeCreate = getNative(Object, 'create');
9
10
/**
11
*
12
* Creates a cache object to store unique values.
13
*
14
* @private
15
* @param {Array} [values] The values to cache.
16
*/
17
function SetCache(values) {
18
var length = values ? values.length : 0;
19
20
this.data = { 'hash': nativeCreate(null), 'set': new Set };
21
while (length--) {
22
this.push(values[length]);
23
}
24
}
25
26
// Add functions to the `Set` cache.
27
SetCache.prototype.push = cachePush;
28
29
module.exports = SetCache;
30
31