mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Add createSet.
This commit is contained in:
18
lodash.js
18
lodash.js
@@ -3378,8 +3378,7 @@
|
||||
* @returns {Array} Returns the new duplicate free array.
|
||||
*/
|
||||
function baseUniq(array, iteratee, comparator) {
|
||||
var seen,
|
||||
index = -1,
|
||||
var index = -1,
|
||||
includes = arrayIncludes,
|
||||
length = array.length,
|
||||
isCommon = true,
|
||||
@@ -3391,6 +3390,10 @@
|
||||
includes = arrayIncludesWith;
|
||||
}
|
||||
else if (length >= LARGE_ARRAY_SIZE) {
|
||||
var set = createSet(array);
|
||||
if (set) {
|
||||
return setToArray(set);
|
||||
}
|
||||
isCommon = false;
|
||||
includes = cacheHas;
|
||||
seen = new SetCache;
|
||||
@@ -4227,6 +4230,17 @@
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a set of `values`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} values The values to add to the set.
|
||||
* @returns {Object} Returns the new set.
|
||||
*/
|
||||
var createSet = !(Set && new Set([1, 2]).size === 2) ? noop : function(values) {
|
||||
return new Set(values);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a function that either curries or invokes `func` with optional
|
||||
* `this` binding and partially applied arguments.
|
||||
|
||||
Reference in New Issue
Block a user