ed3dc6b0fc6f71a6ca26ba7199c5d8907ea2238f
[platform/framework/web/crosswalk-tizen.git] /
1 var cachePush = require('./cachePush'),
2     isNative = require('../lang/isNative');
3
4 /** Native method references. */
5 var Set = isNative(Set = global.Set) && Set;
6
7 /* Native method references for those with the same name as other `lodash` methods. */
8 var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate;
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;