mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 16:47:49 +00:00
Bump to v3.0.0.
This commit is contained in:
30
internal/SetCache.js
Normal file
30
internal/SetCache.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import cachePush from './cachePush';
|
||||
import isNative from '../lang/isNative';
|
||||
import root from './root';
|
||||
|
||||
/** Native method references. */
|
||||
var Set = isNative(Set = root.Set) && Set;
|
||||
|
||||
/* Native method references for those with the same name as other `lodash` methods. */
|
||||
var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate;
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a cache object to store unique values.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} [values] The values to cache.
|
||||
*/
|
||||
function SetCache(values) {
|
||||
var length = values ? values.length : 0;
|
||||
|
||||
this.data = { 'hash': nativeCreate(null), 'set': new Set };
|
||||
while (length--) {
|
||||
this.push(values[length]);
|
||||
}
|
||||
}
|
||||
|
||||
// Add functions to the `Set` cache.
|
||||
SetCache.prototype.push = cachePush;
|
||||
|
||||
export default SetCache;
|
||||
Reference in New Issue
Block a user