mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +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.
|
* @returns {Array} Returns the new duplicate free array.
|
||||||
*/
|
*/
|
||||||
function baseUniq(array, iteratee, comparator) {
|
function baseUniq(array, iteratee, comparator) {
|
||||||
var seen,
|
var index = -1,
|
||||||
index = -1,
|
|
||||||
includes = arrayIncludes,
|
includes = arrayIncludes,
|
||||||
length = array.length,
|
length = array.length,
|
||||||
isCommon = true,
|
isCommon = true,
|
||||||
@@ -3391,6 +3390,10 @@
|
|||||||
includes = arrayIncludesWith;
|
includes = arrayIncludesWith;
|
||||||
}
|
}
|
||||||
else if (length >= LARGE_ARRAY_SIZE) {
|
else if (length >= LARGE_ARRAY_SIZE) {
|
||||||
|
var set = createSet(array);
|
||||||
|
if (set) {
|
||||||
|
return setToArray(set);
|
||||||
|
}
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
includes = cacheHas;
|
includes = cacheHas;
|
||||||
seen = new SetCache;
|
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
|
* Creates a function that either curries or invokes `func` with optional
|
||||||
* `this` binding and partially applied arguments.
|
* `this` binding and partially applied arguments.
|
||||||
|
|||||||
Reference in New Issue
Block a user