Remove semicolons.

This commit is contained in:
John-David Dalton
2017-02-04 23:50:10 -08:00
parent f3a8e55e70
commit 6cb3460fce
452 changed files with 4261 additions and 4261 deletions

View File

@@ -1,5 +1,5 @@
/** Used to stand-in for `undefined` hash values. */ /** Used to stand-in for `undefined` hash values. */
const HASH_UNDEFINED = '__lodash_hash_undefined__'; const HASH_UNDEFINED = '__lodash_hash_undefined__'
class Hash { class Hash {
@@ -11,13 +11,13 @@ class Hash {
* @param {Array} [entries] The key-value pairs to cache. * @param {Array} [entries] The key-value pairs to cache.
*/ */
constructor(entries) { constructor(entries) {
let index = -1; let index = -1
const length = entries == null ? 0 : entries.length; const length = entries == null ? 0 : entries.length
this.clear(); this.clear()
while (++index < length) { while (++index < length) {
const entry = entries[index]; const entry = entries[index]
this.set(entry[0], entry[1]); this.set(entry[0], entry[1])
} }
} }
@@ -27,8 +27,8 @@ class Hash {
* @memberOf Hash * @memberOf Hash
*/ */
clear() { clear() {
this.__data__ = Object.create(null); this.__data__ = Object.create(null)
this.size = 0; this.size = 0
} }
/** /**
@@ -40,9 +40,9 @@ class Hash {
* @returns {boolean} Returns `true` if the entry was removed, else `false`. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ */
delete(key) { delete(key) {
const result = this.has(key) && delete this.__data__[key]; const result = this.has(key) && delete this.__data__[key]
this.size -= result ? 1 : 0; this.size -= result ? 1 : 0
return result; return result
} }
/** /**
@@ -53,9 +53,9 @@ class Hash {
* @returns {*} Returns the entry value. * @returns {*} Returns the entry value.
*/ */
get(key) { get(key) {
const data = this.__data__; const data = this.__data__
const result = data[key]; const result = data[key]
return result === HASH_UNDEFINED ? undefined : result; return result === HASH_UNDEFINED ? undefined : result
} }
/** /**
@@ -66,8 +66,8 @@ class Hash {
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ */
has(key) { has(key) {
const data = this.__data__; const data = this.__data__
return data[key] !== undefined; return data[key] !== undefined
} }
/** /**
@@ -79,11 +79,11 @@ class Hash {
* @returns {Object} Returns the hash instance. * @returns {Object} Returns the hash instance.
*/ */
set(key, value) { set(key, value) {
const data = this.__data__; const data = this.__data__
this.size += this.has(key) ? 0 : 1; this.size += this.has(key) ? 0 : 1
data[key] = value === undefined ? HASH_UNDEFINED : value; data[key] = value === undefined ? HASH_UNDEFINED : value
return this; return this
} }
} }
export default Hash; export default Hash

View File

@@ -1,7 +1,7 @@
import assocIndexOf from './assocIndexOf.js'; import assocIndexOf from './assocIndexOf.js'
/** Built-in value references. */ /** Built-in value references. */
const splice = Array.prototype.splice; const splice = Array.prototype.splice
class ListCache { class ListCache {
@@ -13,13 +13,13 @@ class ListCache {
* @param {Array} [entries] The key-value pairs to cache. * @param {Array} [entries] The key-value pairs to cache.
*/ */
constructor(entries) { constructor(entries) {
let index = -1; let index = -1
const length = entries == null ? 0 : entries.length; const length = entries == null ? 0 : entries.length
this.clear(); this.clear()
while (++index < length) { while (++index < length) {
const entry = entries[index]; const entry = entries[index]
this.set(entry[0], entry[1]); this.set(entry[0], entry[1])
} }
} }
@@ -29,8 +29,8 @@ class ListCache {
* @memberOf ListCache * @memberOf ListCache
*/ */
clear() { clear() {
this.__data__ = []; this.__data__ = []
this.size = 0; this.size = 0
} }
/** /**
@@ -41,20 +41,20 @@ class ListCache {
* @returns {boolean} Returns `true` if the entry was removed, else `false`. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ */
delete(key) { delete(key) {
const data = this.__data__; const data = this.__data__
const index = assocIndexOf(data, key); const index = assocIndexOf(data, key)
if (index < 0) { if (index < 0) {
return false; return false
} }
const lastIndex = data.length - 1; const lastIndex = data.length - 1
if (index == lastIndex) { if (index == lastIndex) {
data.pop(); data.pop()
} else { } else {
splice.call(data, index, 1); splice.call(data, index, 1)
} }
--this.size; --this.size
return true; return true
} }
/** /**
@@ -65,9 +65,9 @@ class ListCache {
* @returns {*} Returns the entry value. * @returns {*} Returns the entry value.
*/ */
get(key) { get(key) {
const data = this.__data__; const data = this.__data__
const index = assocIndexOf(data, key); const index = assocIndexOf(data, key)
return index < 0 ? undefined : data[index][1]; return index < 0 ? undefined : data[index][1]
} }
/** /**
@@ -78,7 +78,7 @@ class ListCache {
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ */
has(key) { has(key) {
return assocIndexOf(this.__data__, key) > -1; return assocIndexOf(this.__data__, key) > -1
} }
/** /**
@@ -90,17 +90,17 @@ class ListCache {
* @returns {Object} Returns the list cache instance. * @returns {Object} Returns the list cache instance.
*/ */
set(key, value) { set(key, value) {
const data = this.__data__; const data = this.__data__
const index = assocIndexOf(data, key); const index = assocIndexOf(data, key)
if (index < 0) { if (index < 0) {
++this.size; ++this.size
data.push([key, value]); data.push([key, value])
} else { } else {
data[index][1] = value; data[index][1] = value
} }
return this; return this
} }
} }
export default ListCache; export default ListCache

View File

@@ -1,6 +1,6 @@
import Hash from './Hash.js'; import Hash from './Hash.js'
import ListCache from './ListCache.js'; import ListCache from './ListCache.js'
/** /**
* Gets the data for `map`. * Gets the data for `map`.
@@ -11,10 +11,10 @@ import ListCache from './ListCache.js';
* @returns {*} Returns the map data. * @returns {*} Returns the map data.
*/ */
function getMapData({ __data__ }, key) { function getMapData({ __data__ }, key) {
const data = __data__; const data = __data__
return isKeyable(key) return isKeyable(key)
? data[typeof key == 'string' ? 'string' : 'hash'] ? data[typeof key == 'string' ? 'string' : 'hash']
: data.map; : data.map
} }
/** /**
@@ -25,10 +25,10 @@ function getMapData({ __data__ }, key) {
* @returns {boolean} Returns `true` if `value` is suitable, else `false`. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/ */
function isKeyable(value) { function isKeyable(value) {
const type = typeof value; const type = typeof value
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
? (value !== '__proto__') ? (value !== '__proto__')
: (value === null); : (value === null)
} }
class MapCache { class MapCache {
@@ -41,13 +41,13 @@ class MapCache {
* @param {Array} [entries] The key-value pairs to cache. * @param {Array} [entries] The key-value pairs to cache.
*/ */
constructor(entries) { constructor(entries) {
let index = -1; let index = -1
const length = entries == null ? 0 : entries.length; const length = entries == null ? 0 : entries.length
this.clear(); this.clear()
while (++index < length) { while (++index < length) {
const entry = entries[index]; const entry = entries[index]
this.set(entry[0], entry[1]); this.set(entry[0], entry[1])
} }
} }
@@ -57,12 +57,12 @@ class MapCache {
* @memberOf MapCache * @memberOf MapCache
*/ */
clear() { clear() {
this.size = 0; this.size = 0
this.__data__ = { this.__data__ = {
'hash': new Hash, 'hash': new Hash,
'map': new (Map || ListCache), 'map': new (Map || ListCache),
'string': new Hash 'string': new Hash
}; }
} }
/** /**
@@ -73,9 +73,9 @@ class MapCache {
* @returns {boolean} Returns `true` if the entry was removed, else `false`. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ */
delete(key) { delete(key) {
const result = getMapData(this, key)['delete'](key); const result = getMapData(this, key)['delete'](key)
this.size -= result ? 1 : 0; this.size -= result ? 1 : 0
return result; return result
} }
/** /**
@@ -86,7 +86,7 @@ class MapCache {
* @returns {*} Returns the entry value. * @returns {*} Returns the entry value.
*/ */
get(key) { get(key) {
return getMapData(this, key).get(key); return getMapData(this, key).get(key)
} }
/** /**
@@ -97,7 +97,7 @@ class MapCache {
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ */
has(key) { has(key) {
return getMapData(this, key).has(key); return getMapData(this, key).has(key)
} }
/** /**
@@ -109,13 +109,13 @@ class MapCache {
* @returns {Object} Returns the map cache instance. * @returns {Object} Returns the map cache instance.
*/ */
set(key, value) { set(key, value) {
const data = getMapData(this, key); const data = getMapData(this, key)
const size = data.size; const size = data.size
data.set(key, value); data.set(key, value)
this.size += data.size == size ? 0 : 1; this.size += data.size == size ? 0 : 1
return this; return this
} }
} }
export default MapCache; export default MapCache

View File

@@ -1,7 +1,7 @@
import MapCache from './MapCache.js'; import MapCache from './MapCache.js'
/** Used to stand-in for `undefined` hash values. */ /** Used to stand-in for `undefined` hash values. */
const HASH_UNDEFINED = '__lodash_hash_undefined__'; const HASH_UNDEFINED = '__lodash_hash_undefined__'
class SetCache { class SetCache {
@@ -13,12 +13,12 @@ class SetCache {
* @param {Array} [values] The values to cache. * @param {Array} [values] The values to cache.
*/ */
constructor(values) { constructor(values) {
let index = -1; let index = -1
const length = values == null ? 0 : values.length; const length = values == null ? 0 : values.length
this.__data__ = new MapCache; this.__data__ = new MapCache
while (++index < length) { while (++index < length) {
this.add(values[index]); this.add(values[index])
} }
} }
@@ -31,8 +31,8 @@ class SetCache {
* @returns {Object} Returns the cache instance. * @returns {Object} Returns the cache instance.
*/ */
add(value) { add(value) {
this.__data__.set(value, HASH_UNDEFINED); this.__data__.set(value, HASH_UNDEFINED)
return this; return this
} }
/** /**
@@ -43,10 +43,10 @@ class SetCache {
* @returns {number} Returns `true` if `value` is found, else `false`. * @returns {number} Returns `true` if `value` is found, else `false`.
*/ */
has(value) { has(value) {
return this.__data__.has(value); return this.__data__.has(value)
} }
} }
SetCache.prototype.push = SetCache.prototype.add; SetCache.prototype.push = SetCache.prototype.add
export default SetCache; export default SetCache

View File

@@ -1,8 +1,8 @@
import ListCache from './ListCache.js'; import ListCache from './ListCache.js'
import MapCache from './MapCache.js'; import MapCache from './MapCache.js'
/** Used as the size to enable large array optimizations. */ /** Used as the size to enable large array optimizations. */
const LARGE_ARRAY_SIZE = 200; const LARGE_ARRAY_SIZE = 200
class Stack { class Stack {
@@ -14,8 +14,8 @@ class Stack {
* @param {Array} [entries] The key-value pairs to cache. * @param {Array} [entries] The key-value pairs to cache.
*/ */
constructor(entries) { constructor(entries) {
const data = this.__data__ = new ListCache(entries); const data = this.__data__ = new ListCache(entries)
this.size = data.size; this.size = data.size
} }
/** /**
@@ -24,8 +24,8 @@ class Stack {
* @memberOf Stack * @memberOf Stack
*/ */
clear() { clear() {
this.__data__ = new ListCache; this.__data__ = new ListCache
this.size = 0; this.size = 0
} }
/** /**
@@ -36,11 +36,11 @@ class Stack {
* @returns {boolean} Returns `true` if the entry was removed, else `false`. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ */
delete(key) { delete(key) {
const data = this.__data__; const data = this.__data__
const result = data['delete'](key); const result = data['delete'](key)
this.size = data.size; this.size = data.size
return result; return result
} }
/** /**
@@ -51,7 +51,7 @@ class Stack {
* @returns {*} Returns the entry value. * @returns {*} Returns the entry value.
*/ */
get(key) { get(key) {
return this.__data__.get(key); return this.__data__.get(key)
} }
/** /**
@@ -62,7 +62,7 @@ class Stack {
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ */
has(key) { has(key) {
return this.__data__.has(key); return this.__data__.has(key)
} }
/** /**
@@ -74,20 +74,20 @@ class Stack {
* @returns {Object} Returns the stack cache instance. * @returns {Object} Returns the stack cache instance.
*/ */
set(key, value) { set(key, value) {
let data = this.__data__; let data = this.__data__
if (data instanceof ListCache) { if (data instanceof ListCache) {
const pairs = data.__data__; const pairs = data.__data__
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
pairs.push([key, value]); pairs.push([key, value])
this.size = ++data.size; this.size = ++data.size
return this; return this
} }
data = this.__data__ = new MapCache(pairs); data = this.__data__ = new MapCache(pairs)
} }
data.set(key, value); data.set(key, value)
this.size = data.size; this.size = data.size
return this; return this
} }
} }
export default Stack; export default Stack

View File

@@ -8,8 +8,8 @@
*/ */
function addMapEntry(map, pair) { function addMapEntry(map, pair) {
// Don't return `map.set` because it's not chainable in IE 11. // Don't return `map.set` because it's not chainable in IE 11.
map.set(pair[0], pair[1]); map.set(pair[0], pair[1])
return map; return map
} }
export default addMapEntry; export default addMapEntry

View File

@@ -8,8 +8,8 @@
*/ */
function addSetEntry(set, value) { function addSetEntry(set, value) {
// Don't return `set.add` because it's not chainable in IE 11. // Don't return `set.add` because it's not chainable in IE 11.
set.add(value); set.add(value)
return set; return set
} }
export default addSetEntry; export default addSetEntry

View File

@@ -10,12 +10,12 @@
*/ */
function apply(func, thisArg, args) { function apply(func, thisArg, args) {
switch (args.length) { switch (args.length) {
case 0: return func.call(thisArg); case 0: return func.call(thisArg)
case 1: return func.call(thisArg, args[0]); case 1: return func.call(thisArg, args[0])
case 2: return func.call(thisArg, args[0], args[1]); case 2: return func.call(thisArg, args[0], args[1])
case 3: return func.call(thisArg, args[0], args[1], args[2]); case 3: return func.call(thisArg, args[0], args[1], args[2])
} }
return func.apply(thisArg, args); return func.apply(thisArg, args)
} }
export default apply; export default apply

View File

@@ -7,15 +7,15 @@
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function arrayEach(array, iteratee) { function arrayEach(array, iteratee) {
let index = -1; let index = -1
const length = array == null ? 0 : array.length; const length = array == null ? 0 : array.length
while (++index < length) { while (++index < length) {
if (iteratee(array[index], index, array) === false) { if (iteratee(array[index], index, array) === false) {
break; break
} }
} }
return array; return array
} }
export default arrayEach; export default arrayEach

View File

@@ -7,14 +7,14 @@
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function arrayEachRight(array, iteratee) { function arrayEachRight(array, iteratee) {
let length = array == null ? 0 : array.length; let length = array == null ? 0 : array.length
while (length--) { while (length--) {
if (iteratee(array[length], length, array) === false) { if (iteratee(array[length], length, array) === false) {
break; break
} }
} }
return array; return array
} }
export default arrayEachRight; export default arrayEachRight

View File

@@ -8,15 +8,15 @@
* else `false`. * else `false`.
*/ */
function arrayEvery(array, predicate) { function arrayEvery(array, predicate) {
let index = -1; let index = -1
const length = array == null ? 0 : array.length; const length = array == null ? 0 : array.length
while (++index < length) { while (++index < length) {
if (!predicate(array[index], index, array)) { if (!predicate(array[index], index, array)) {
return false; return false
} }
} }
return true; return true
} }
export default arrayEvery; export default arrayEvery

View File

@@ -7,18 +7,18 @@
* @returns {Array} Returns the new filtered array. * @returns {Array} Returns the new filtered array.
*/ */
function arrayFilter(array, predicate) { function arrayFilter(array, predicate) {
let index = -1; let index = -1
let resIndex = 0; let resIndex = 0
const length = array == null ? 0 : array.length; const length = array == null ? 0 : array.length
const result = []; const result = []
while (++index < length) { while (++index < length) {
const value = array[index]; const value = array[index]
if (predicate(value, index, array)) { if (predicate(value, index, array)) {
result[resIndex++] = value; result[resIndex++] = value
} }
} }
return result; return result
} }
export default arrayFilter; export default arrayFilter

View File

@@ -1,4 +1,4 @@
import baseIndexOf from './baseIndexOf.js'; import baseIndexOf from './baseIndexOf.js'
/** /**
* A specialized version of `includes` for arrays without support for * A specialized version of `includes` for arrays without support for
@@ -10,8 +10,8 @@ import baseIndexOf from './baseIndexOf.js';
* @returns {boolean} Returns `true` if `target` is found, else `false`. * @returns {boolean} Returns `true` if `target` is found, else `false`.
*/ */
function arrayIncludes(array, value) { function arrayIncludes(array, value) {
const length = array == null ? 0 : array.length; const length = array == null ? 0 : array.length
return !!length && baseIndexOf(array, value, 0) > -1; return !!length && baseIndexOf(array, value, 0) > -1
} }
export default arrayIncludes; export default arrayIncludes

View File

@@ -8,15 +8,15 @@
* @returns {boolean} Returns `true` if `target` is found, else `false`. * @returns {boolean} Returns `true` if `target` is found, else `false`.
*/ */
function arrayIncludesWith(array, value, comparator) { function arrayIncludesWith(array, value, comparator) {
let index = -1; let index = -1
const length = array == null ? 0 : array.length; const length = array == null ? 0 : array.length
while (++index < length) { while (++index < length) {
if (comparator(value, array[index])) { if (comparator(value, array[index])) {
return true; return true
} }
} }
return false; return false
} }
export default arrayIncludesWith; export default arrayIncludesWith

View File

@@ -1,11 +1,11 @@
import baseTimes from './baseTimes.js'; import baseTimes from './baseTimes.js'
import isArguments from '../isArguments.js'; import isArguments from '../isArguments.js'
import isBuffer from '../isBuffer.js'; import isBuffer from '../isBuffer.js'
import isIndex from './isIndex.js'; import isIndex from './isIndex.js'
import isTypedArray from '../isTypedArray.js'; import isTypedArray from '../isTypedArray.js'
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.hasOwnProperty; const hasOwnProperty = Object.prototype.hasOwnProperty
/** /**
* Creates an array of the enumerable property names of the array-like `value`. * Creates an array of the enumerable property names of the array-like `value`.
@@ -16,13 +16,13 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
* @returns {Array} Returns the array of property names. * @returns {Array} Returns the array of property names.
*/ */
function arrayLikeKeys(value, inherited) { function arrayLikeKeys(value, inherited) {
const isArr = Array.isArray(value); const isArr = Array.isArray(value)
const isArg = !isArr && isArguments(value); const isArg = !isArr && isArguments(value)
const isBuff = !isArr && !isArg && isBuffer(value); const isBuff = !isArr && !isArg && isBuffer(value)
const isType = !isArr && !isArg && !isBuff && isTypedArray(value); const isType = !isArr && !isArg && !isBuff && isTypedArray(value)
const skipIndexes = isArr || isArg || isBuff || isType; const skipIndexes = isArr || isArg || isBuff || isType
const result = skipIndexes ? baseTimes(value.length, String) : []; const result = skipIndexes ? baseTimes(value.length, String) : []
const length = result.length; const length = result.length
for (const key in value) { for (const key in value) {
if ((inherited || hasOwnProperty.call(value, key)) && if ((inherited || hasOwnProperty.call(value, key)) &&
@@ -35,10 +35,10 @@ function arrayLikeKeys(value, inherited) {
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || // Skip index properties. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || // Skip index properties.
isIndex(key, length)) isIndex(key, length))
))) { ))) {
result.push(key); result.push(key)
} }
} }
return result; return result
} }
export default arrayLikeKeys; export default arrayLikeKeys

View File

@@ -7,14 +7,14 @@
* @returns {Array} Returns the new mapped array. * @returns {Array} Returns the new mapped array.
*/ */
function arrayMap(array, iteratee) { function arrayMap(array, iteratee) {
let index = -1; let index = -1
const length = array == null ? 0 : array.length; const length = array == null ? 0 : array.length
const result = Array(length); const result = Array(length)
while (++index < length) { while (++index < length) {
result[index] = iteratee(array[index], index, array); result[index] = iteratee(array[index], index, array)
} }
return result; return result
} }
export default arrayMap; export default arrayMap

View File

@@ -7,14 +7,14 @@
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function arrayPush(array, values) { function arrayPush(array, values) {
let index = -1; let index = -1
const length = values.length; const length = values.length
const offset = array.length; const offset = array.length
while (++index < length) { while (++index < length) {
array[offset + index] = values[index]; array[offset + index] = values[index]
} }
return array; return array
} }
export default arrayPush; export default arrayPush

View File

@@ -10,16 +10,16 @@
* @returns {*} Returns the accumulated value. * @returns {*} Returns the accumulated value.
*/ */
function arrayReduce(array, iteratee, accumulator, initAccum) { function arrayReduce(array, iteratee, accumulator, initAccum) {
let index = -1; let index = -1
const length = array == null ? 0 : array.length; const length = array == null ? 0 : array.length
if (initAccum && length) { if (initAccum && length) {
accumulator = array[++index]; accumulator = array[++index]
} }
while (++index < length) { while (++index < length) {
accumulator = iteratee(accumulator, array[index], index, array); accumulator = iteratee(accumulator, array[index], index, array)
} }
return accumulator; return accumulator
} }
export default arrayReduce; export default arrayReduce

View File

@@ -10,14 +10,14 @@
* @returns {*} Returns the accumulated value. * @returns {*} Returns the accumulated value.
*/ */
function arrayReduceRight(array, iteratee, accumulator, initAccum) { function arrayReduceRight(array, iteratee, accumulator, initAccum) {
let length = array == null ? 0 : array.length; let length = array == null ? 0 : array.length
if (initAccum && length) { if (initAccum && length) {
accumulator = array[--length]; accumulator = array[--length]
} }
while (length--) { while (length--) {
accumulator = iteratee(accumulator, array[length], length, array); accumulator = iteratee(accumulator, array[length], length, array)
} }
return accumulator; return accumulator
} }
export default arrayReduceRight; export default arrayReduceRight

View File

@@ -1,4 +1,4 @@
import baseRandom from './baseRandom.js'; import baseRandom from './baseRandom.js'
/** /**
* A specialized version of `sample` for arrays. * A specialized version of `sample` for arrays.
@@ -8,8 +8,8 @@ import baseRandom from './baseRandom.js';
* @returns {*} Returns the random element. * @returns {*} Returns the random element.
*/ */
function arraySample(array) { function arraySample(array) {
const length = array.length; const length = array.length
return length ? array[baseRandom(0, length - 1)] : undefined; return length ? array[baseRandom(0, length - 1)] : undefined
} }
export default arraySample; export default arraySample

View File

@@ -1,6 +1,6 @@
import baseClamp from './baseClamp.js'; import baseClamp from './baseClamp.js'
import copyArray from './copyArray.js'; import copyArray from './copyArray.js'
import shuffleSelf from './shuffleSelf.js'; import shuffleSelf from './shuffleSelf.js'
/** /**
* A specialized version of `sampleSize` for arrays. * A specialized version of `sampleSize` for arrays.
@@ -11,7 +11,7 @@ import shuffleSelf from './shuffleSelf.js';
* @returns {Array} Returns the random elements. * @returns {Array} Returns the random elements.
*/ */
function arraySampleSize(array, n) { function arraySampleSize(array, n) {
return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length))
} }
export default arraySampleSize; export default arraySampleSize

View File

@@ -1,5 +1,5 @@
import copyArray from './copyArray.js'; import copyArray from './copyArray.js'
import shuffleSelf from './shuffleSelf.js'; import shuffleSelf from './shuffleSelf.js'
/** /**
* A specialized version of `shuffle` for arrays. * A specialized version of `shuffle` for arrays.
@@ -9,7 +9,7 @@ import shuffleSelf from './shuffleSelf.js';
* @returns {Array} Returns the new shuffled array. * @returns {Array} Returns the new shuffled array.
*/ */
function arrayShuffle(array) { function arrayShuffle(array) {
return shuffleSelf(copyArray(array)); return shuffleSelf(copyArray(array))
} }
export default arrayShuffle; export default arrayShuffle

View File

@@ -8,15 +8,15 @@
* else `false`. * else `false`.
*/ */
function arraySome(array, predicate) { function arraySome(array, predicate) {
let index = -1; let index = -1
const length = array == null ? 0 : array.length; const length = array == null ? 0 : array.length
while (++index < length) { while (++index < length) {
if (predicate(array[index], index, array)) { if (predicate(array[index], index, array)) {
return true; return true
} }
} }
return false; return false
} }
export default arraySome; export default arraySome

View File

@@ -6,7 +6,7 @@
* @returns {number} Returns the string size. * @returns {number} Returns the string size.
*/ */
function asciiSize({ length }) { function asciiSize({ length }) {
return length; return length
} }
export default asciiSize; export default asciiSize

View File

@@ -6,7 +6,7 @@
* @returns {Array} Returns the converted array. * @returns {Array} Returns the converted array.
*/ */
function asciiToArray(string) { function asciiToArray(string) {
return string.split(''); return string.split('')
} }
export default asciiToArray; export default asciiToArray

View File

@@ -1,5 +1,5 @@
/** Used to match words composed of alphanumeric characters. */ /** Used to match words composed of alphanumeric characters. */
const reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; const reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g
/** /**
* Splits an ASCII `string` into an array of its words. * Splits an ASCII `string` into an array of its words.
@@ -9,7 +9,7 @@ const reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
* @returns {Array} Returns the words of `string`. * @returns {Array} Returns the words of `string`.
*/ */
function asciiWords(string) { function asciiWords(string) {
return string.match(reAsciiWord) || []; return string.match(reAsciiWord) || []
} }
export default asciiWords; export default asciiWords

View File

@@ -1,5 +1,5 @@
import baseAssignValue from './baseAssignValue.js'; import baseAssignValue from './baseAssignValue.js'
import eq from '../eq.js'; import eq from '../eq.js'
/** /**
* This function is like `assignValue` except that it doesn't assign * This function is like `assignValue` except that it doesn't assign
@@ -13,8 +13,8 @@ import eq from '../eq.js';
function assignMergeValue(object, key, value) { function assignMergeValue(object, key, value) {
if ((value !== undefined && !eq(object[key], value)) || if ((value !== undefined && !eq(object[key], value)) ||
(value === undefined && !(key in object))) { (value === undefined && !(key in object))) {
baseAssignValue(object, key, value); baseAssignValue(object, key, value)
} }
} }
export default assignMergeValue; export default assignMergeValue

View File

@@ -1,8 +1,8 @@
import baseAssignValue from './baseAssignValue.js'; import baseAssignValue from './baseAssignValue.js'
import eq from '../eq.js'; import eq from '../eq.js'
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.hasOwnProperty; const hasOwnProperty = Object.prototype.hasOwnProperty
/** /**
* Assigns `value` to `key` of `object` if the existing value is not equivalent * Assigns `value` to `key` of `object` if the existing value is not equivalent
@@ -15,11 +15,11 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
* @param {*} value The value to assign. * @param {*} value The value to assign.
*/ */
function assignValue(object, key, value) { function assignValue(object, key, value) {
const objValue = object[key]; const objValue = object[key]
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
(value === undefined && !(key in object))) { (value === undefined && !(key in object))) {
baseAssignValue(object, key, value); baseAssignValue(object, key, value)
} }
} }
export default assignValue; export default assignValue

View File

@@ -1,4 +1,4 @@
import eq from '../eq.js'; import eq from '../eq.js'
/** /**
* Gets the index at which the `key` is found in `array` of key-value pairs. * Gets the index at which the `key` is found in `array` of key-value pairs.
@@ -9,13 +9,13 @@ import eq from '../eq.js';
* @returns {number} Returns the index of the matched value, else `-1`. * @returns {number} Returns the index of the matched value, else `-1`.
*/ */
function assocIndexOf(array, key) { function assocIndexOf(array, key) {
let length = array.length; let length = array.length
while (length--) { while (length--) {
if (eq(array[length][0], key)) { if (eq(array[length][0], key)) {
return length; return length
} }
} }
return -1; return -1
} }
export default assocIndexOf; export default assocIndexOf

View File

@@ -1,5 +1,5 @@
import copyObject from './copyObject.js'; import copyObject from './copyObject.js'
import keys from '../keys.js'; import keys from '../keys.js'
/** /**
* The base implementation of `assign` without support for multiple sources * The base implementation of `assign` without support for multiple sources
@@ -11,7 +11,7 @@ import keys from '../keys.js';
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
function baseAssign(object, source) { function baseAssign(object, source) {
return object && copyObject(source, keys(source), object); return object && copyObject(source, keys(source), object)
} }
export default baseAssign; export default baseAssign

View File

@@ -1,5 +1,5 @@
import copyObject from './copyObject.js'; import copyObject from './copyObject.js'
import keysIn from '../keysIn.js'; import keysIn from '../keysIn.js'
/** /**
* The base implementation of `assignIn` without support for multiple sources * The base implementation of `assignIn` without support for multiple sources
@@ -11,7 +11,7 @@ import keysIn from '../keysIn.js';
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
function baseAssignIn(object, source) { function baseAssignIn(object, source) {
return object && copyObject(source, keysIn(source), object); return object && copyObject(source, keysIn(source), object)
} }
export default baseAssignIn; export default baseAssignIn

View File

@@ -14,10 +14,10 @@ function baseAssignValue(object, key, value) {
'enumerable': true, 'enumerable': true,
'value': value, 'value': value,
'writable': true 'writable': true
}); })
} else { } else {
object[key] = value; object[key] = value
} }
} }
export default baseAssignValue; export default baseAssignValue

View File

@@ -1,4 +1,4 @@
import get from '../get.js'; import get from '../get.js'
/** /**
* The base implementation of `at` without support for individual paths. * The base implementation of `at` without support for individual paths.
@@ -9,15 +9,15 @@ import get from '../get.js';
* @returns {Array} Returns the picked elements. * @returns {Array} Returns the picked elements.
*/ */
function baseAt(object, paths) { function baseAt(object, paths) {
let index = -1; let index = -1
const length = paths.length; const length = paths.length
const result = Array(length); const result = Array(length)
const skip = object == null; const skip = object == null
while (++index < length) { while (++index < length) {
result[index] = skip ? undefined : get(object, paths[index]); result[index] = skip ? undefined : get(object, paths[index])
} }
return result; return result
} }
export default baseAt; export default baseAt

View File

@@ -9,10 +9,10 @@
*/ */
function baseClamp(number, lower, upper) { function baseClamp(number, lower, upper) {
if (number === number) { if (number === number) {
number = number <= upper ? number : upper; number = number <= upper ? number : upper
number = number >= lower ? number : lower; number = number >= lower ? number : lower
} }
return number; return number
} }
export default baseClamp; export default baseClamp

View File

@@ -1,67 +1,67 @@
import Stack from './Stack.js'; import Stack from './Stack.js'
import arrayEach from './arrayEach.js'; import arrayEach from './arrayEach.js'
import assignValue from './assignValue.js'; import assignValue from './assignValue.js'
import baseAssign from './baseAssign.js'; import baseAssign from './baseAssign.js'
import baseAssignIn from './baseAssignIn.js'; import baseAssignIn from './baseAssignIn.js'
import baseCreate from './baseCreate.js'; import baseCreate from './baseCreate.js'
import cloneBuffer from './cloneBuffer.js'; import cloneBuffer from './cloneBuffer.js'
import copyArray from './copyArray.js'; import copyArray from './copyArray.js'
import cloneArrayBuffer from './cloneArrayBuffer.js'; import cloneArrayBuffer from './cloneArrayBuffer.js'
import cloneDataView from './cloneDataView.js'; import cloneDataView from './cloneDataView.js'
import cloneMap from './cloneMap.js'; import cloneMap from './cloneMap.js'
import cloneRegExp from './cloneRegExp.js'; import cloneRegExp from './cloneRegExp.js'
import cloneSet from './cloneSet.js'; import cloneSet from './cloneSet.js'
import cloneSymbol from './cloneSymbol.js'; import cloneSymbol from './cloneSymbol.js'
import cloneTypedArray from './cloneTypedArray.js'; import cloneTypedArray from './cloneTypedArray.js'
import copySymbols from './copySymbols.js'; import copySymbols from './copySymbols.js'
import copySymbolsIn from './copySymbolsIn.js'; import copySymbolsIn from './copySymbolsIn.js'
import getAllKeys from './getAllKeys.js'; import getAllKeys from './getAllKeys.js'
import getAllKeysIn from './getAllKeysIn.js'; import getAllKeysIn from './getAllKeysIn.js'
import getTag from './getTag.js'; import getTag from './getTag.js'
import initCloneArray from './initCloneArray.js'; import initCloneArray from './initCloneArray.js'
import initCloneByTag from './initCloneByTag.js'; import initCloneByTag from './initCloneByTag.js'
import initCloneObject from './initCloneObject.js'; import initCloneObject from './initCloneObject.js'
import isBuffer from '../isBuffer.js'; import isBuffer from '../isBuffer.js'
import isObject from '../isObject.js'; import isObject from '../isObject.js'
import isPrototype from './isPrototype.js'; import isPrototype from './isPrototype.js'
import keys from '../keys.js'; import keys from '../keys.js'
/** Used to compose bitmasks for cloning. */ /** Used to compose bitmasks for cloning. */
const CLONE_DEEP_FLAG = 1; const CLONE_DEEP_FLAG = 1
const CLONE_FLAT_FLAG = 2; const CLONE_FLAT_FLAG = 2
const CLONE_SYMBOLS_FLAG = 4; const CLONE_SYMBOLS_FLAG = 4
/** `Object#toString` result references. */ /** `Object#toString` result references. */
const argsTag = '[object Arguments]'; const argsTag = '[object Arguments]'
const arrayTag = '[object Array]'; const arrayTag = '[object Array]'
const boolTag = '[object Boolean]'; const boolTag = '[object Boolean]'
const dateTag = '[object Date]'; const dateTag = '[object Date]'
const errorTag = '[object Error]'; const errorTag = '[object Error]'
const funcTag = '[object Function]'; const funcTag = '[object Function]'
const genTag = '[object GeneratorFunction]'; const genTag = '[object GeneratorFunction]'
const mapTag = '[object Map]'; const mapTag = '[object Map]'
const numberTag = '[object Number]'; const numberTag = '[object Number]'
const objectTag = '[object Object]'; const objectTag = '[object Object]'
const regexpTag = '[object RegExp]'; const regexpTag = '[object RegExp]'
const setTag = '[object Set]'; const setTag = '[object Set]'
const stringTag = '[object String]'; const stringTag = '[object String]'
const symbolTag = '[object Symbol]'; const symbolTag = '[object Symbol]'
const weakMapTag = '[object WeakMap]'; const weakMapTag = '[object WeakMap]'
const arrayBufferTag = '[object ArrayBuffer]'; const arrayBufferTag = '[object ArrayBuffer]'
const dataViewTag = '[object DataView]'; const dataViewTag = '[object DataView]'
const float32Tag = '[object Float32Array]'; const float32Tag = '[object Float32Array]'
const float64Tag = '[object Float64Array]'; const float64Tag = '[object Float64Array]'
const int8Tag = '[object Int8Array]'; const int8Tag = '[object Int8Array]'
const int16Tag = '[object Int16Array]'; const int16Tag = '[object Int16Array]'
const int32Tag = '[object Int32Array]'; const int32Tag = '[object Int32Array]'
const uint8Tag = '[object Uint8Array]'; const uint8Tag = '[object Uint8Array]'
const uint8ClampedTag = '[object Uint8ClampedArray]'; const uint8ClampedTag = '[object Uint8ClampedArray]'
const uint16Tag = '[object Uint16Array]'; const uint16Tag = '[object Uint16Array]'
const uint32Tag = '[object Uint32Array]'; const uint32Tag = '[object Uint32Array]'
/** Used to identify `toStringTag` values supported by `clone`. */ /** Used to identify `toStringTag` values supported by `clone`. */
const cloneableTags = {}; const cloneableTags = {}
cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[argsTag] = cloneableTags[arrayTag] =
cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[boolTag] = cloneableTags[dateTag] =
@@ -72,12 +72,12 @@ cloneableTags[numberTag] = cloneableTags[objectTag] =
cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[regexpTag] = cloneableTags[setTag] =
cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] =
cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true
cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[errorTag] = cloneableTags[funcTag] =
cloneableTags[weakMapTag] = false; cloneableTags[weakMapTag] = false
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.hasOwnProperty; const hasOwnProperty = Object.prototype.hasOwnProperty
/** /**
* Initializes an object clone. * Initializes an object clone.
@@ -89,7 +89,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
function initCloneObject(object) { function initCloneObject(object) {
return (typeof object.constructor == 'function' && !isPrototype(object)) return (typeof object.constructor == 'function' && !isPrototype(object))
? baseCreate(Object.getPrototypeOf(object)) ? baseCreate(Object.getPrototypeOf(object))
: {}; : {}
} }
/** /**
@@ -106,38 +106,38 @@ function initCloneObject(object) {
* @returns {Object} Returns the initialized clone. * @returns {Object} Returns the initialized clone.
*/ */
function initCloneByTag(object, tag, cloneFunc, isDeep) { function initCloneByTag(object, tag, cloneFunc, isDeep) {
const Ctor = object.constructor; const Ctor = object.constructor
switch (tag) { switch (tag) {
case arrayBufferTag: case arrayBufferTag:
return cloneArrayBuffer(object); return cloneArrayBuffer(object)
case boolTag: case boolTag:
case dateTag: case dateTag:
return new Ctor(+object); return new Ctor(+object)
case dataViewTag: case dataViewTag:
return cloneDataView(object, isDeep); return cloneDataView(object, isDeep)
case float32Tag: case float64Tag: case float32Tag: case float64Tag:
case int8Tag: case int16Tag: case int32Tag: case int8Tag: case int16Tag: case int32Tag:
case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
return cloneTypedArray(object, isDeep); return cloneTypedArray(object, isDeep)
case mapTag: case mapTag:
return cloneMap(object, isDeep, cloneFunc); return cloneMap(object, isDeep, cloneFunc)
case numberTag: case numberTag:
case stringTag: case stringTag:
return new Ctor(object); return new Ctor(object)
case regexpTag: case regexpTag:
return cloneRegExp(object); return cloneRegExp(object)
case setTag: case setTag:
return cloneSet(object, isDeep, cloneFunc); return cloneSet(object, isDeep, cloneFunc)
case symbolTag: case symbolTag:
return cloneSymbol(object); return cloneSymbol(object)
} }
} }
@@ -149,15 +149,15 @@ function initCloneByTag(object, tag, cloneFunc, isDeep) {
* @returns {Array} Returns the initialized clone. * @returns {Array} Returns the initialized clone.
*/ */
function initCloneArray(array) { function initCloneArray(array) {
const length = array.length; const length = array.length
const result = array.constructor(length); const result = array.constructor(length)
// Add properties assigned by `RegExp#exec`. // Add properties assigned by `RegExp#exec`.
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
result.index = array.index; result.index = array.index
result.input = array.input; result.input = array.input
} }
return result; return result
} }
/** /**
@@ -177,69 +177,69 @@ function initCloneArray(array) {
* @returns {*} Returns the cloned value. * @returns {*} Returns the cloned value.
*/ */
function baseClone(value, bitmask, customizer, key, object, stack) { function baseClone(value, bitmask, customizer, key, object, stack) {
let result; let result
const isDeep = bitmask & CLONE_DEEP_FLAG; const isDeep = bitmask & CLONE_DEEP_FLAG
const isFlat = bitmask & CLONE_FLAT_FLAG; const isFlat = bitmask & CLONE_FLAT_FLAG
const isFull = bitmask & CLONE_SYMBOLS_FLAG; const isFull = bitmask & CLONE_SYMBOLS_FLAG
if (customizer) { if (customizer) {
result = object ? customizer(value, key, object, stack) : customizer(value); result = object ? customizer(value, key, object, stack) : customizer(value)
} }
if (result !== undefined) { if (result !== undefined) {
return result; return result
} }
if (!isObject(value)) { if (!isObject(value)) {
return value; return value
} }
const isArr = Array.isArray(value); const isArr = Array.isArray(value)
if (isArr) { if (isArr) {
result = initCloneArray(value); result = initCloneArray(value)
if (!isDeep) { if (!isDeep) {
return copyArray(value, result); return copyArray(value, result)
} }
} else { } else {
const tag = getTag(value); const tag = getTag(value)
const isFunc = tag == funcTag || tag == genTag; const isFunc = tag == funcTag || tag == genTag
if (isBuffer(value)) { if (isBuffer(value)) {
return cloneBuffer(value, isDeep); return cloneBuffer(value, isDeep)
} }
if (tag == objectTag || tag == argsTag || (isFunc && !object)) { if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
result = (isFlat || isFunc) ? {} : initCloneObject(value); result = (isFlat || isFunc) ? {} : initCloneObject(value)
if (!isDeep) { if (!isDeep) {
return isFlat return isFlat
? copySymbolsIn(value, baseAssignIn(result, value)) ? copySymbolsIn(value, baseAssignIn(result, value))
: copySymbols(value, baseAssign(result, value)); : copySymbols(value, baseAssign(result, value))
} }
} else { } else {
if (!cloneableTags[tag]) { if (!cloneableTags[tag]) {
return object ? value : {}; return object ? value : {}
} }
result = initCloneByTag(value, tag, baseClone, isDeep); result = initCloneByTag(value, tag, baseClone, isDeep)
} }
} }
// Check for circular references and return its corresponding clone. // Check for circular references and return its corresponding clone.
stack || (stack = new Stack); stack || (stack = new Stack)
const stacked = stack.get(value); const stacked = stack.get(value)
if (stacked) { if (stacked) {
return stacked; return stacked
} }
stack.set(value, result); stack.set(value, result)
const keysFunc = isFull const keysFunc = isFull
? (isFlat ? getAllKeysIn : getAllKeys) ? (isFlat ? getAllKeysIn : getAllKeys)
: (isFlat ? keysIn : keys); : (isFlat ? keysIn : keys)
const props = isArr ? undefined : keysFunc(value); const props = isArr ? undefined : keysFunc(value)
arrayEach(props || value, (subValue, key) => { arrayEach(props || value, (subValue, key) => {
if (props) { if (props) {
key = subValue; key = subValue
subValue = value[key]; subValue = value[key]
} }
// Recursively populate clone (susceptible to call stack limits). // Recursively populate clone (susceptible to call stack limits).
assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack))
}); })
return result; return result
} }
export default baseClone; export default baseClone

View File

@@ -1,5 +1,5 @@
import baseConformsTo from './baseConformsTo.js'; import baseConformsTo from './baseConformsTo.js'
import keys from '../keys.js'; import keys from '../keys.js'
/** /**
* The base implementation of `conforms` which doesn't clone `source`. * The base implementation of `conforms` which doesn't clone `source`.
@@ -9,8 +9,8 @@ import keys from '../keys.js';
* @returns {Function} Returns the new spec function. * @returns {Function} Returns the new spec function.
*/ */
function baseConforms(source) { function baseConforms(source) {
const props = keys(source); const props = keys(source)
return object => baseConformsTo(object, source, props); return object => baseConformsTo(object, source, props)
} }
export default baseConforms; export default baseConforms

View File

@@ -7,21 +7,21 @@
* @returns {boolean} Returns `true` if `object` conforms, else `false`. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
*/ */
function baseConformsTo(object, source, props) { function baseConformsTo(object, source, props) {
let length = props.length; let length = props.length
if (object == null) { if (object == null) {
return !length; return !length
} }
object = Object(object); object = Object(object)
while (length--) { while (length--) {
const key = props[length]; const key = props[length]
const predicate = source[key]; const predicate = source[key]
const value = object[key]; const value = object[key]
if ((value === undefined && !(key in object)) || !predicate(value)) { if ((value === undefined && !(key in object)) || !predicate(value)) {
return false; return false
} }
} }
return true; return true
} }
export default baseConformsTo; export default baseConformsTo

View File

@@ -1,4 +1,4 @@
import isObject from '../isObject.js'; import isObject from '../isObject.js'
/** /**
* The base implementation of `create` without support for assigning * The base implementation of `create` without support for assigning
@@ -9,7 +9,7 @@ import isObject from '../isObject.js';
* @returns {Object} Returns the new object. * @returns {Object} Returns the new object.
*/ */
function baseCreate(proto) { function baseCreate(proto) {
return isObject(proto) ? Object.create(proto) : {}; return isObject(proto) ? Object.create(proto) : {}
} }
export default baseCreate; export default baseCreate

View File

@@ -1,11 +1,11 @@
import SetCache from './SetCache.js'; import SetCache from './SetCache.js'
import arrayIncludes from './arrayIncludes.js'; import arrayIncludes from './arrayIncludes.js'
import arrayIncludesWith from './arrayIncludesWith.js'; import arrayIncludesWith from './arrayIncludesWith.js'
import arrayMap from './arrayMap.js'; import arrayMap from './arrayMap.js'
import cacheHas from './cacheHas.js'; import cacheHas from './cacheHas.js'
/** Used as the size to enable large array optimizations. */ /** Used as the size to enable large array optimizations. */
const LARGE_ARRAY_SIZE = 200; const LARGE_ARRAY_SIZE = 200
/** /**
* The base implementation of methods like `difference` without support * The base implementation of methods like `difference` without support
@@ -19,48 +19,48 @@ const LARGE_ARRAY_SIZE = 200;
* @returns {Array} Returns the new array of filtered values. * @returns {Array} Returns the new array of filtered values.
*/ */
function baseDifference(array, values, iteratee, comparator) { function baseDifference(array, values, iteratee, comparator) {
let index = -1; let index = -1
let includes = arrayIncludes; let includes = arrayIncludes
let isCommon = true; let isCommon = true
const length = array.length; const length = array.length
const result = []; const result = []
const valuesLength = values.length; const valuesLength = values.length
if (!length) { if (!length) {
return result; return result
} }
if (iteratee) { if (iteratee) {
values = arrayMap(values, value => iteratee(value)); values = arrayMap(values, value => iteratee(value))
} }
if (comparator) { if (comparator) {
includes = arrayIncludesWith; includes = arrayIncludesWith
isCommon = false; isCommon = false
} }
else if (values.length >= LARGE_ARRAY_SIZE) { else if (values.length >= LARGE_ARRAY_SIZE) {
includes = cacheHas; includes = cacheHas
isCommon = false; isCommon = false
values = new SetCache(values); values = new SetCache(values)
} }
outer: outer:
while (++index < length) { while (++index < length) {
let value = array[index]; let value = array[index]
const computed = iteratee == null ? value : iteratee(value); const computed = iteratee == null ? value : iteratee(value)
value = (comparator || value !== 0) ? value : 0; value = (comparator || value !== 0) ? value : 0
if (isCommon && computed === computed) { if (isCommon && computed === computed) {
let valuesIndex = valuesLength; let valuesIndex = valuesLength
while (valuesIndex--) { while (valuesIndex--) {
if (values[valuesIndex] === computed) { if (values[valuesIndex] === computed) {
continue outer; continue outer
} }
} }
result.push(value); result.push(value)
} }
else if (!includes(values, computed, comparator)) { else if (!includes(values, computed, comparator)) {
result.push(value); result.push(value)
} }
} }
return result; return result
} }
export default baseDifference; export default baseDifference

View File

@@ -1,5 +1,5 @@
import baseForOwn from './baseForOwn.js'; import baseForOwn from './baseForOwn.js'
import createBaseEach from './createBaseEach.js'; import createBaseEach from './createBaseEach.js'
/** /**
* The base implementation of `forEach`. * The base implementation of `forEach`.
@@ -9,6 +9,6 @@ import createBaseEach from './createBaseEach.js';
* @param {Function} iteratee The function invoked per iteration. * @param {Function} iteratee The function invoked per iteration.
* @returns {Array|Object} Returns `collection`. * @returns {Array|Object} Returns `collection`.
*/ */
const baseEach = createBaseEach(baseForOwn); const baseEach = createBaseEach(baseForOwn)
export default baseEach; export default baseEach

View File

@@ -1,5 +1,5 @@
import baseForOwnRight from './baseForOwnRight.js'; import baseForOwnRight from './baseForOwnRight.js'
import createBaseEach from './createBaseEach.js'; import createBaseEach from './createBaseEach.js'
/** /**
* The base implementation of `forEachRight`. * The base implementation of `forEachRight`.
@@ -9,6 +9,6 @@ import createBaseEach from './createBaseEach.js';
* @param {Function} iteratee The function invoked per iteration. * @param {Function} iteratee The function invoked per iteration.
* @returns {Array|Object} Returns `collection`. * @returns {Array|Object} Returns `collection`.
*/ */
const baseEachRight = createBaseEach(baseForOwnRight, true); const baseEachRight = createBaseEach(baseForOwnRight, true)
export default baseEachRight; export default baseEachRight

View File

@@ -1,4 +1,4 @@
import baseEach from './baseEach.js'; import baseEach from './baseEach.js'
/** /**
* The base implementation of `every`. * The base implementation of `every`.
@@ -10,12 +10,12 @@ import baseEach from './baseEach.js';
* else `false` * else `false`
*/ */
function baseEvery(collection, predicate) { function baseEvery(collection, predicate) {
let result = true; let result = true
baseEach(collection, (value, index, collection) => { baseEach(collection, (value, index, collection) => {
result = !!predicate(value, index, collection); result = !!predicate(value, index, collection)
return result; return result
}); })
return result; return result
} }
export default baseEvery; export default baseEvery

View File

@@ -1,5 +1,5 @@
import toInteger from '../toInteger.js'; import toInteger from '../toInteger.js'
import toLength from '../toLength.js'; import toLength from '../toLength.js'
/** /**
* The base implementation of `fill` without an iteratee call guard. * The base implementation of `fill` without an iteratee call guard.
@@ -12,21 +12,21 @@ import toLength from '../toLength.js';
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function baseFill(array, value, start, end) { function baseFill(array, value, start, end) {
const length = array.length; const length = array.length
start = toInteger(start); start = toInteger(start)
if (start < 0) { if (start < 0) {
start = -start > length ? 0 : (length + start); start = -start > length ? 0 : (length + start)
} }
end = (end === undefined || end > length) ? length : toInteger(end); end = (end === undefined || end > length) ? length : toInteger(end)
if (end < 0) { if (end < 0) {
end += length; end += length
} }
end = start > end ? 0 : toLength(end); end = start > end ? 0 : toLength(end)
while (start < end) { while (start < end) {
array[start++] = value; array[start++] = value
} }
return array; return array
} }
export default baseFill; export default baseFill

View File

@@ -1,4 +1,4 @@
import baseEach from './baseEach.js'; import baseEach from './baseEach.js'
/** /**
* The base implementation of `filter`. * The base implementation of `filter`.
@@ -9,13 +9,13 @@ import baseEach from './baseEach.js';
* @returns {Array} Returns the new filtered array. * @returns {Array} Returns the new filtered array.
*/ */
function baseFilter(collection, predicate) { function baseFilter(collection, predicate) {
const result = []; const result = []
baseEach(collection, (value, index, collection) => { baseEach(collection, (value, index, collection) => {
if (predicate(value, index, collection)) { if (predicate(value, index, collection)) {
result.push(value); result.push(value)
} }
}); })
return result; return result
} }
export default baseFilter; export default baseFilter

View File

@@ -9,15 +9,15 @@
* @returns {number} Returns the index of the matched value, else `-1`. * @returns {number} Returns the index of the matched value, else `-1`.
*/ */
function baseFindIndex(array, predicate, fromIndex, fromRight) { function baseFindIndex(array, predicate, fromIndex, fromRight) {
const length = array.length; const length = array.length
let index = fromIndex + (fromRight ? 1 : -1); let index = fromIndex + (fromRight ? 1 : -1)
while ((fromRight ? index-- : ++index < length)) { while ((fromRight ? index-- : ++index < length)) {
if (predicate(array[index], index, array)) { if (predicate(array[index], index, array)) {
return index; return index
} }
} }
return -1; return -1
} }
export default baseFindIndex; export default baseFindIndex

View File

@@ -9,14 +9,14 @@
* @returns {*} Returns the found element or its key, else `undefined`. * @returns {*} Returns the found element or its key, else `undefined`.
*/ */
function baseFindKey(collection, predicate, eachFunc) { function baseFindKey(collection, predicate, eachFunc) {
let result; let result
eachFunc(collection, (value, key, collection) => { eachFunc(collection, (value, key, collection) => {
if (predicate(value, key, collection)) { if (predicate(value, key, collection)) {
result = key; result = key
return false; return false
} }
}); })
return result; return result
} }
export default baseFindKey; export default baseFindKey

View File

@@ -1,5 +1,5 @@
import arrayPush from './arrayPush.js'; import arrayPush from './arrayPush.js'
import isFlattenable from './isFlattenable.js'; import isFlattenable from './isFlattenable.js'
/** /**
* The base implementation of `flatten` with support for restricting flattening. * The base implementation of `flatten` with support for restricting flattening.
@@ -13,26 +13,26 @@ import isFlattenable from './isFlattenable.js';
* @returns {Array} Returns the new flattened array. * @returns {Array} Returns the new flattened array.
*/ */
function baseFlatten(array, depth, predicate, isStrict, result) { function baseFlatten(array, depth, predicate, isStrict, result) {
let index = -1; let index = -1
const length = array.length; const length = array.length
predicate || (predicate = isFlattenable); predicate || (predicate = isFlattenable)
result || (result = []); result || (result = [])
while (++index < length) { while (++index < length) {
const value = array[index]; const value = array[index]
if (depth > 0 && predicate(value)) { if (depth > 0 && predicate(value)) {
if (depth > 1) { if (depth > 1) {
// Recursively flatten arrays (susceptible to call stack limits). // Recursively flatten arrays (susceptible to call stack limits).
baseFlatten(value, depth - 1, predicate, isStrict, result); baseFlatten(value, depth - 1, predicate, isStrict, result)
} else { } else {
arrayPush(result, value); arrayPush(result, value)
} }
} else if (!isStrict) { } else if (!isStrict) {
result[result.length] = value; result[result.length] = value
} }
} }
return result; return result
} }
export default baseFlatten; export default baseFlatten

View File

@@ -1,4 +1,4 @@
import createBaseFor from './createBaseFor.js'; import createBaseFor from './createBaseFor.js'
/** /**
* The base implementation of `baseForOwn` which iterates over `object` * The base implementation of `baseForOwn` which iterates over `object`
@@ -11,6 +11,6 @@ import createBaseFor from './createBaseFor.js';
* @param {Function} keysFunc The function to get the keys of `object`. * @param {Function} keysFunc The function to get the keys of `object`.
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
const baseFor = createBaseFor(); const baseFor = createBaseFor()
export default baseFor; export default baseFor

View File

@@ -1,5 +1,5 @@
import baseFor from './baseFor.js'; import baseFor from './baseFor.js'
import keys from '../keys.js'; import keys from '../keys.js'
/** /**
* The base implementation of `forOwn`. * The base implementation of `forOwn`.
@@ -10,7 +10,7 @@ import keys from '../keys.js';
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
function baseForOwn(object, iteratee) { function baseForOwn(object, iteratee) {
return object && baseFor(object, iteratee, keys); return object && baseFor(object, iteratee, keys)
} }
export default baseForOwn; export default baseForOwn

View File

@@ -1,5 +1,5 @@
import baseForRight from './baseForRight.js'; import baseForRight from './baseForRight.js'
import keys from '../keys.js'; import keys from '../keys.js'
/** /**
* The base implementation of `forOwnRight`. * The base implementation of `forOwnRight`.
@@ -10,7 +10,7 @@ import keys from '../keys.js';
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
function baseForOwnRight(object, iteratee) { function baseForOwnRight(object, iteratee) {
return object && baseForRight(object, iteratee, keys); return object && baseForRight(object, iteratee, keys)
} }
export default baseForOwnRight; export default baseForOwnRight

View File

@@ -1,4 +1,4 @@
import createBaseFor from './createBaseFor.js'; import createBaseFor from './createBaseFor.js'
/** /**
* This function is like `baseFor` except that it iterates over properties * This function is like `baseFor` except that it iterates over properties
@@ -10,6 +10,6 @@ import createBaseFor from './createBaseFor.js';
* @param {Function} keysFunc The function to get the keys of `object`. * @param {Function} keysFunc The function to get the keys of `object`.
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
const baseForRight = createBaseFor(true); const baseForRight = createBaseFor(true)
export default baseForRight; export default baseForRight

View File

@@ -1,5 +1,5 @@
import arrayFilter from './arrayFilter.js'; import arrayFilter from './arrayFilter.js'
import isFunction from '../isFunction.js'; import isFunction from '../isFunction.js'
/** /**
* The base implementation of `functions` which creates an array of * The base implementation of `functions` which creates an array of
@@ -11,7 +11,7 @@ import isFunction from '../isFunction.js';
* @returns {Array} Returns the function names. * @returns {Array} Returns the function names.
*/ */
function baseFunctions(object, props) { function baseFunctions(object, props) {
return arrayFilter(props, key => isFunction(object[key])); return arrayFilter(props, key => isFunction(object[key]))
} }
export default baseFunctions; export default baseFunctions

View File

@@ -1,5 +1,5 @@
import castPath from './castPath.js'; import castPath from './castPath.js'
import toKey from './toKey.js'; import toKey from './toKey.js'
/** /**
* The base implementation of `get` without support for default values. * The base implementation of `get` without support for default values.
@@ -10,15 +10,15 @@ import toKey from './toKey.js';
* @returns {*} Returns the resolved value. * @returns {*} Returns the resolved value.
*/ */
function baseGet(object, path) { function baseGet(object, path) {
path = castPath(path, object); path = castPath(path, object)
let index = 0; let index = 0
const length = path.length; const length = path.length
while (object != null && index < length) { while (object != null && index < length) {
object = object[toKey(path[index++])]; object = object[toKey(path[index++])]
} }
return (index && index == length) ? object : undefined; return (index && index == length) ? object : undefined
} }
export default baseGet; export default baseGet

View File

@@ -1,12 +1,12 @@
import getRawTag from './getRawTag.js'; import getRawTag from './getRawTag.js'
import objectToString from './objectToString.js'; import objectToString from './objectToString.js'
/** `Object#toString` result references. */ /** `Object#toString` result references. */
const nullTag = '[object Null]'; const nullTag = '[object Null]'
const undefinedTag = '[object Undefined]'; const undefinedTag = '[object Undefined]'
/** Built-in value references. */ /** Built-in value references. */
const symToStringTag = Symbol ? Symbol.toStringTag : undefined; const symToStringTag = Symbol ? Symbol.toStringTag : undefined
/** /**
* The base implementation of `getTag` without fallbacks for buggy environments. * The base implementation of `getTag` without fallbacks for buggy environments.
@@ -17,11 +17,11 @@ const symToStringTag = Symbol ? Symbol.toStringTag : undefined;
*/ */
function baseGetTag(value) { function baseGetTag(value) {
if (value == null) { if (value == null) {
return value === undefined ? undefinedTag : nullTag; return value === undefined ? undefinedTag : nullTag
} }
return (symToStringTag && symToStringTag in Object(value)) return (symToStringTag && symToStringTag in Object(value))
? getRawTag(value) ? getRawTag(value)
: objectToString(value); : objectToString(value)
} }
export default baseGetTag; export default baseGetTag

View File

@@ -1,5 +1,5 @@
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.hasOwnProperty; const hasOwnProperty = Object.prototype.hasOwnProperty
/** /**
* The base implementation of `has` without support for deep paths. * The base implementation of `has` without support for deep paths.
@@ -10,7 +10,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
* @returns {boolean} Returns `true` if `key` exists, else `false`. * @returns {boolean} Returns `true` if `key` exists, else `false`.
*/ */
function baseHas(object, key) { function baseHas(object, key) {
return object != null && hasOwnProperty.call(object, key); return object != null && hasOwnProperty.call(object, key)
} }
export default baseHas; export default baseHas

View File

@@ -7,7 +7,7 @@
* @returns {boolean} Returns `true` if `key` exists, else `false`. * @returns {boolean} Returns `true` if `key` exists, else `false`.
*/ */
function baseHasIn(object, key) { function baseHasIn(object, key) {
return object != null && key in Object(object); return object != null && key in Object(object)
} }
export default baseHasIn; export default baseHasIn

View File

@@ -1,6 +1,6 @@
/* Built-in method references for those with the same name as other `lodash` methods. */ /* Built-in method references for those with the same name as other `lodash` methods. */
const nativeMax = Math.max; const nativeMax = Math.max
const nativeMin = Math.min; const nativeMin = Math.min
/** /**
* The base implementation of `inRange` which doesn't coerce arguments. * The base implementation of `inRange` which doesn't coerce arguments.
@@ -12,7 +12,7 @@ const nativeMin = Math.min;
* @returns {boolean} Returns `true` if `number` is in the range, else `false`. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
*/ */
function baseInRange(number, start, end) { function baseInRange(number, start, end) {
return number >= nativeMin(start, end) && number < nativeMax(start, end); return number >= nativeMin(start, end) && number < nativeMax(start, end)
} }
export default baseInRange; export default baseInRange

View File

@@ -1,6 +1,6 @@
import baseFindIndex from './baseFindIndex.js'; import baseFindIndex from './baseFindIndex.js'
import baseIsNaN from './baseIsNaN.js'; import baseIsNaN from './baseIsNaN.js'
import strictIndexOf from './strictIndexOf.js'; import strictIndexOf from './strictIndexOf.js'
/** /**
* The base implementation of `indexOf` without `fromIndex` bounds checks. * The base implementation of `indexOf` without `fromIndex` bounds checks.
@@ -14,7 +14,7 @@ import strictIndexOf from './strictIndexOf.js';
function baseIndexOf(array, value, fromIndex) { function baseIndexOf(array, value, fromIndex) {
return value === value return value === value
? strictIndexOf(array, value, fromIndex) ? strictIndexOf(array, value, fromIndex)
: baseFindIndex(array, baseIsNaN, fromIndex); : baseFindIndex(array, baseIsNaN, fromIndex)
} }
export default baseIndexOf; export default baseIndexOf

View File

@@ -9,15 +9,15 @@
* @returns {number} Returns the index of the matched value, else `-1`. * @returns {number} Returns the index of the matched value, else `-1`.
*/ */
function baseIndexOfWith(array, value, fromIndex, comparator) { function baseIndexOfWith(array, value, fromIndex, comparator) {
let index = fromIndex - 1; let index = fromIndex - 1
const length = array.length; const length = array.length
while (++index < length) { while (++index < length) {
if (comparator(array[index], value)) { if (comparator(array[index], value)) {
return index; return index
} }
} }
return -1; return -1
} }
export default baseIndexOfWith; export default baseIndexOfWith

View File

@@ -1,11 +1,11 @@
import SetCache from './SetCache.js'; import SetCache from './SetCache.js'
import arrayIncludes from './arrayIncludes.js'; import arrayIncludes from './arrayIncludes.js'
import arrayIncludesWith from './arrayIncludesWith.js'; import arrayIncludesWith from './arrayIncludesWith.js'
import arrayMap from './arrayMap.js'; import arrayMap from './arrayMap.js'
import cacheHas from './cacheHas.js'; import cacheHas from './cacheHas.js'
/* Built-in method references for those with the same name as other `lodash` methods. */ /* Built-in method references for those with the same name as other `lodash` methods. */
const nativeMin = Math.min; const nativeMin = Math.min
/** /**
* The base implementation of methods like `intersection` that accepts an * The base implementation of methods like `intersection` that accepts an
@@ -18,58 +18,58 @@ const nativeMin = Math.min;
* @returns {Array} Returns the new array of shared values. * @returns {Array} Returns the new array of shared values.
*/ */
function baseIntersection(arrays, iteratee, comparator) { function baseIntersection(arrays, iteratee, comparator) {
const includes = comparator ? arrayIncludesWith : arrayIncludes; const includes = comparator ? arrayIncludesWith : arrayIncludes
const length = arrays[0].length; const length = arrays[0].length
const othLength = arrays.length; const othLength = arrays.length
const caches = Array(othLength); const caches = Array(othLength)
const result = []; const result = []
let array; let array
let maxLength = Infinity; let maxLength = Infinity
let othIndex = othLength; let othIndex = othLength
while (othIndex--) { while (othIndex--) {
array = arrays[othIndex]; array = arrays[othIndex]
if (othIndex && iteratee) { if (othIndex && iteratee) {
array = arrayMap(array, valye => iteratee(value)); array = arrayMap(array, valye => iteratee(value))
} }
maxLength = nativeMin(array.length, maxLength); maxLength = nativeMin(array.length, maxLength)
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
? new SetCache(othIndex && array) ? new SetCache(othIndex && array)
: undefined; : undefined
} }
array = arrays[0]; array = arrays[0]
let index = -1; let index = -1
const seen = caches[0]; const seen = caches[0]
outer: outer:
while (++index < length && result.length < maxLength) { while (++index < length && result.length < maxLength) {
let value = array[index]; let value = array[index]
const computed = iteratee ? iteratee(value) : value; const computed = iteratee ? iteratee(value) : value
value = (comparator || value !== 0) ? value : 0; value = (comparator || value !== 0) ? value : 0
if (!(seen if (!(seen
? cacheHas(seen, computed) ? cacheHas(seen, computed)
: includes(result, computed, comparator) : includes(result, computed, comparator)
)) { )) {
othIndex = othLength; othIndex = othLength
while (--othIndex) { while (--othIndex) {
const cache = caches[othIndex]; const cache = caches[othIndex]
if (!(cache if (!(cache
? cacheHas(cache, computed) ? cacheHas(cache, computed)
: includes(arrays[othIndex], computed, comparator)) : includes(arrays[othIndex], computed, comparator))
) { ) {
continue outer; continue outer
} }
} }
if (seen) { if (seen) {
seen.push(computed); seen.push(computed)
} }
result.push(value); result.push(value)
} }
} }
return result; return result
} }
export default baseIntersection; export default baseIntersection

View File

@@ -1,5 +1,5 @@
import baseIsEqualDeep from './baseIsEqualDeep.js'; import baseIsEqualDeep from './baseIsEqualDeep.js'
import isObjectLike from '../isObjectLike.js'; import isObjectLike from '../isObjectLike.js'
/** /**
* The base implementation of `isEqual` which supports partial comparisons * The base implementation of `isEqual` which supports partial comparisons
@@ -17,12 +17,12 @@ import isObjectLike from '../isObjectLike.js';
*/ */
function baseIsEqual(value, other, bitmask, customizer, stack) { function baseIsEqual(value, other, bitmask, customizer, stack) {
if (value === other) { if (value === other) {
return true; return true
} }
if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
return value !== value && other !== other; return value !== value && other !== other
} }
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack)
} }
export default baseIsEqual; export default baseIsEqual

View File

@@ -1,21 +1,21 @@
import Stack from './Stack.js'; import Stack from './Stack.js'
import equalArrays from './equalArrays.js'; import equalArrays from './equalArrays.js'
import equalByTag from './equalByTag.js'; import equalByTag from './equalByTag.js'
import equalObjects from './equalObjects.js'; import equalObjects from './equalObjects.js'
import getTag from './getTag.js'; import getTag from './getTag.js'
import isBuffer from '../isBuffer.js'; import isBuffer from '../isBuffer.js'
import isTypedArray from '../isTypedArray.js'; import isTypedArray from '../isTypedArray.js'
/** Used to compose bitmasks for value comparisons. */ /** Used to compose bitmasks for value comparisons. */
const COMPARE_PARTIAL_FLAG = 1; const COMPARE_PARTIAL_FLAG = 1
/** `Object#toString` result references. */ /** `Object#toString` result references. */
const argsTag = '[object Arguments]'; const argsTag = '[object Arguments]'
const arrayTag = '[object Array]'; const arrayTag = '[object Array]'
const objectTag = '[object Object]'; const objectTag = '[object Object]'
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.hasOwnProperty; const hasOwnProperty = Object.prototype.hasOwnProperty
/** /**
* A specialized version of `baseIsEqual` for arrays and objects which performs * A specialized version of `baseIsEqual` for arrays and objects which performs
@@ -32,48 +32,48 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/ */
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
let objIsArr = Array.isArray(object); let objIsArr = Array.isArray(object)
const othIsArr = Array.isArray(other); const othIsArr = Array.isArray(other)
let objTag = objIsArr ? arrayTag : getTag(object); let objTag = objIsArr ? arrayTag : getTag(object)
let othTag = othIsArr ? arrayTag : getTag(other); let othTag = othIsArr ? arrayTag : getTag(other)
objTag = objTag == argsTag ? objectTag : objTag; objTag = objTag == argsTag ? objectTag : objTag
othTag = othTag == argsTag ? objectTag : othTag; othTag = othTag == argsTag ? objectTag : othTag
let objIsObj = objTag == objectTag; let objIsObj = objTag == objectTag
const othIsObj = othTag == objectTag; const othIsObj = othTag == objectTag
const isSameTag = objTag == othTag; const isSameTag = objTag == othTag
if (isSameTag && isBuffer(object)) { if (isSameTag && isBuffer(object)) {
if (!isBuffer(other)) { if (!isBuffer(other)) {
return false; return false
} }
objIsArr = true; objIsArr = true
objIsObj = false; objIsObj = false
} }
if (isSameTag && !objIsObj) { if (isSameTag && !objIsObj) {
stack || (stack = new Stack); stack || (stack = new Stack)
return (objIsArr || isTypedArray(object)) return (objIsArr || isTypedArray(object))
? equalArrays(object, other, bitmask, customizer, equalFunc, stack) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
: equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack)
} }
if (!(bitmask & COMPARE_PARTIAL_FLAG)) { if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
const objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'); const objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__')
const othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); const othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__')
if (objIsWrapped || othIsWrapped) { if (objIsWrapped || othIsWrapped) {
const objUnwrapped = objIsWrapped ? object.value() : object; const objUnwrapped = objIsWrapped ? object.value() : object
const othUnwrapped = othIsWrapped ? other.value() : other; const othUnwrapped = othIsWrapped ? other.value() : other
stack || (stack = new Stack); stack || (stack = new Stack)
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack)
} }
} }
if (!isSameTag) { if (!isSameTag) {
return false; return false
} }
stack || (stack = new Stack); stack || (stack = new Stack)
return equalObjects(object, other, bitmask, customizer, equalFunc, stack); return equalObjects(object, other, bitmask, customizer, equalFunc, stack)
} }
export default baseIsEqualDeep; export default baseIsEqualDeep

View File

@@ -1,9 +1,9 @@
import Stack from './Stack.js'; import Stack from './Stack.js'
import baseIsEqual from './baseIsEqual.js'; import baseIsEqual from './baseIsEqual.js'
/** Used to compose bitmasks for value comparisons. */ /** Used to compose bitmasks for value comparisons. */
const COMPARE_PARTIAL_FLAG = 1; const COMPARE_PARTIAL_FLAG = 1
const COMPARE_UNORDERED_FLAG = 2; const COMPARE_UNORDERED_FLAG = 2
/** /**
* The base implementation of `isMatch`. * The base implementation of `isMatch`.
@@ -16,49 +16,49 @@ const COMPARE_UNORDERED_FLAG = 2;
* @returns {boolean} Returns `true` if `object` is a match, else `false`. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
*/ */
function baseIsMatch(object, source, matchData, customizer) { function baseIsMatch(object, source, matchData, customizer) {
let index = matchData.length; let index = matchData.length
const length = index; const length = index
const noCustomizer = !customizer; const noCustomizer = !customizer
if (object == null) { if (object == null) {
return !length; return !length
} }
let data; let data
let result; let result
object = Object(object); object = Object(object)
while (index--) { while (index--) {
data = matchData[index]; data = matchData[index]
if ((noCustomizer && data[2]) if ((noCustomizer && data[2])
? data[1] !== object[data[0]] ? data[1] !== object[data[0]]
: !(data[0] in object) : !(data[0] in object)
) { ) {
return false; return false
} }
} }
while (++index < length) { while (++index < length) {
data = matchData[index]; data = matchData[index]
const key = data[0]; const key = data[0]
const objValue = object[key]; const objValue = object[key]
const srcValue = data[1]; const srcValue = data[1]
if (noCustomizer && data[2]) { if (noCustomizer && data[2]) {
if (objValue === undefined && !(key in object)) { if (objValue === undefined && !(key in object)) {
return false; return false
} }
} else { } else {
const stack = new Stack; const stack = new Stack
if (customizer) { if (customizer) {
result = customizer(objValue, srcValue, key, object, source, stack); result = customizer(objValue, srcValue, key, object, source, stack)
} }
if (!(result === undefined if (!(result === undefined
? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
: result : result
)) { )) {
return false; return false
} }
} }
} }
return true; return true
} }
export default baseIsMatch; export default baseIsMatch

View File

@@ -6,7 +6,7 @@
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
*/ */
function baseIsNaN(value) { function baseIsNaN(value) {
return value !== value; return value !== value
} }
export default baseIsNaN; export default baseIsNaN

View File

@@ -1,8 +1,8 @@
import isPrototype from './isPrototype.js'; import isPrototype from './isPrototype.js'
import nativeKeys from './nativeKeys.js'; import nativeKeys from './nativeKeys.js'
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.hasOwnProperty; const hasOwnProperty = Object.prototype.hasOwnProperty
/** /**
* The base implementation of `keys` which doesn't treat sparse arrays as dense. * The base implementation of `keys` which doesn't treat sparse arrays as dense.
@@ -13,15 +13,15 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
*/ */
function baseKeys(object) { function baseKeys(object) {
if (!isPrototype(object)) { if (!isPrototype(object)) {
return nativeKeys(object); return nativeKeys(object)
} }
const result = []; const result = []
for (const key in Object(object)) { for (const key in Object(object)) {
if (hasOwnProperty.call(object, key) && key != 'constructor') { if (hasOwnProperty.call(object, key) && key != 'constructor') {
result.push(key); result.push(key)
} }
} }
return result; return result
} }
export default baseKeys; export default baseKeys

View File

@@ -1,9 +1,9 @@
import isObject from '../isObject.js'; import isObject from '../isObject.js'
import isPrototype from './isPrototype.js'; import isPrototype from './isPrototype.js'
import nativeKeysIn from './nativeKeysIn.js'; import nativeKeysIn from './nativeKeysIn.js'
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.hasOwnProperty; const hasOwnProperty = Object.prototype.hasOwnProperty
/** /**
* The base implementation of `keysIn` which doesn't treat sparse arrays as dense. * The base implementation of `keysIn` which doesn't treat sparse arrays as dense.
@@ -14,17 +14,17 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
*/ */
function baseKeysIn(object) { function baseKeysIn(object) {
if (!isObject(object)) { if (!isObject(object)) {
return nativeKeysIn(object); return nativeKeysIn(object)
} }
const isProto = isPrototype(object); const isProto = isPrototype(object)
const result = []; const result = []
for (const key in object) { for (const key in object) {
if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
result.push(key); result.push(key)
} }
} }
return result; return result
} }
export default baseKeysIn; export default baseKeysIn

View File

@@ -1,5 +1,5 @@
import baseEach from './baseEach.js'; import baseEach from './baseEach.js'
import isArrayLike from '../isArrayLike.js'; import isArrayLike from '../isArrayLike.js'
/** /**
* The base implementation of `map`. * The base implementation of `map`.
@@ -10,13 +10,13 @@ import isArrayLike from '../isArrayLike.js';
* @returns {Array} Returns the new mapped array. * @returns {Array} Returns the new mapped array.
*/ */
function baseMap(collection, iteratee) { function baseMap(collection, iteratee) {
let index = -1; let index = -1
const result = isArrayLike(collection) ? Array(collection.length) : []; const result = isArrayLike(collection) ? Array(collection.length) : []
baseEach(collection, (value, key, collection) => { baseEach(collection, (value, key, collection) => {
result[++index] = iteratee(value, key, collection); result[++index] = iteratee(value, key, collection)
}); })
return result; return result
} }
export default baseMap; export default baseMap

View File

@@ -1,6 +1,6 @@
import baseIsMatch from './baseIsMatch.js'; import baseIsMatch from './baseIsMatch.js'
import getMatchData from './getMatchData.js'; import getMatchData from './getMatchData.js'
import matchesStrictComparable from './matchesStrictComparable.js'; import matchesStrictComparable from './matchesStrictComparable.js'
/** /**
* The base implementation of `matches` which doesn't clone `source`. * The base implementation of `matches` which doesn't clone `source`.
@@ -10,11 +10,11 @@ import matchesStrictComparable from './matchesStrictComparable.js';
* @returns {Function} Returns the new spec function. * @returns {Function} Returns the new spec function.
*/ */
function baseMatches(source) { function baseMatches(source) {
const matchData = getMatchData(source); const matchData = getMatchData(source)
if (matchData.length == 1 && matchData[0][2]) { if (matchData.length == 1 && matchData[0][2]) {
return matchesStrictComparable(matchData[0][0], matchData[0][1]); return matchesStrictComparable(matchData[0][0], matchData[0][1])
} }
return object => object === source || baseIsMatch(object, source, matchData); return object => object === source || baseIsMatch(object, source, matchData)
} }
export default baseMatches; export default baseMatches

View File

@@ -1,14 +1,14 @@
import baseIsEqual from './baseIsEqual.js'; import baseIsEqual from './baseIsEqual.js'
import get from '../get.js'; import get from '../get.js'
import hasIn from '../hasIn.js'; import hasIn from '../hasIn.js'
import isKey from './isKey.js'; import isKey from './isKey.js'
import isStrictComparable from './isStrictComparable.js'; import isStrictComparable from './isStrictComparable.js'
import matchesStrictComparable from './matchesStrictComparable.js'; import matchesStrictComparable from './matchesStrictComparable.js'
import toKey from './toKey.js'; import toKey from './toKey.js'
/** Used to compose bitmasks for value comparisons. */ /** Used to compose bitmasks for value comparisons. */
const COMPARE_PARTIAL_FLAG = 1; const COMPARE_PARTIAL_FLAG = 1
const COMPARE_UNORDERED_FLAG = 2; const COMPARE_UNORDERED_FLAG = 2
/** /**
* The base implementation of `matchesProperty` which doesn't clone `srcValue`. * The base implementation of `matchesProperty` which doesn't clone `srcValue`.
@@ -20,14 +20,14 @@ const COMPARE_UNORDERED_FLAG = 2;
*/ */
function baseMatchesProperty(path, srcValue) { function baseMatchesProperty(path, srcValue) {
if (isKey(path) && isStrictComparable(srcValue)) { if (isKey(path) && isStrictComparable(srcValue)) {
return matchesStrictComparable(toKey(path), srcValue); return matchesStrictComparable(toKey(path), srcValue)
} }
return object => { return object => {
const objValue = get(object, path); const objValue = get(object, path)
return (objValue === undefined && objValue === srcValue) return (objValue === undefined && objValue === srcValue)
? hasIn(object, path) ? hasIn(object, path)
: baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG)
}; }
} }
export default baseMatchesProperty; export default baseMatchesProperty

View File

@@ -1,9 +1,9 @@
import Stack from './Stack.js'; import Stack from './Stack.js'
import assignMergeValue from './assignMergeValue.js'; import assignMergeValue from './assignMergeValue.js'
import baseFor from './baseFor.js'; import baseFor from './baseFor.js'
import baseMergeDeep from './baseMergeDeep.js'; import baseMergeDeep from './baseMergeDeep.js'
import isObject from '../isObject.js'; import isObject from '../isObject.js'
import keysIn from '../keysIn.js'; import keysIn from '../keysIn.js'
/** /**
* The base implementation of `merge` without support for multiple sources. * The base implementation of `merge` without support for multiple sources.
@@ -18,24 +18,24 @@ import keysIn from '../keysIn.js';
*/ */
function baseMerge(object, source, srcIndex, customizer, stack) { function baseMerge(object, source, srcIndex, customizer, stack) {
if (object === source) { if (object === source) {
return; return
} }
baseFor(source, (srcValue, key) => { baseFor(source, (srcValue, key) => {
if (isObject(srcValue)) { if (isObject(srcValue)) {
stack || (stack = new Stack); stack || (stack = new Stack)
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack)
} }
else { else {
const newValue = customizer const newValue = customizer
? customizer(object[key], srcValue, `${ key }`, object, source, stack) ? customizer(object[key], srcValue, `${ key }`, object, source, stack)
: undefined; : undefined
if (newValue === undefined) { if (newValue === undefined) {
newValue = srcValue; newValue = srcValue
} }
assignMergeValue(object, key, newValue); assignMergeValue(object, key, newValue)
} }
}, keysIn); }, keysIn)
} }
export default baseMerge; export default baseMerge

View File

@@ -1,16 +1,16 @@
import assignMergeValue from './assignMergeValue.js'; import assignMergeValue from './assignMergeValue.js'
import cloneBuffer from './cloneBuffer.js'; import cloneBuffer from './cloneBuffer.js'
import cloneTypedArray from './cloneTypedArray.js'; import cloneTypedArray from './cloneTypedArray.js'
import copyArray from './copyArray.js'; import copyArray from './copyArray.js'
import initCloneObject from './initCloneObject.js'; import initCloneObject from './initCloneObject.js'
import isArguments from '../isArguments.js'; import isArguments from '../isArguments.js'
import isArrayLikeObject from '../isArrayLikeObject.js'; import isArrayLikeObject from '../isArrayLikeObject.js'
import isBuffer from '../isBuffer.js'; import isBuffer from '../isBuffer.js'
import isFunction from '../isFunction.js'; import isFunction from '../isFunction.js'
import isObject from '../isObject.js'; import isObject from '../isObject.js'
import isPlainObject from '../isPlainObject.js'; import isPlainObject from '../isPlainObject.js'
import isTypedArray from '../isTypedArray.js'; import isTypedArray from '../isTypedArray.js'
import toPlainObject from '../toPlainObject.js'; import toPlainObject from '../toPlainObject.js'
/** /**
* A specialized version of `baseMerge` for arrays and objects which performs * A specialized version of `baseMerge` for arrays and objects which performs
@@ -28,65 +28,65 @@ import toPlainObject from '../toPlainObject.js';
* counterparts. * counterparts.
*/ */
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
const objValue = object[key]; const objValue = object[key]
const srcValue = source[key]; const srcValue = source[key]
const stacked = stack.get(srcValue); const stacked = stack.get(srcValue)
if (stacked) { if (stacked) {
assignMergeValue(object, key, stacked); assignMergeValue(object, key, stacked)
return; return
} }
let newValue = customizer let newValue = customizer
? customizer(objValue, srcValue, `${ key }`, object, source, stack) ? customizer(objValue, srcValue, `${ key }`, object, source, stack)
: undefined; : undefined
let isCommon = newValue === undefined; let isCommon = newValue === undefined
if (isCommon) { if (isCommon) {
const isArr = Array.isArray(srcValue); const isArr = Array.isArray(srcValue)
const isBuff = !isArr && isBuffer(srcValue); const isBuff = !isArr && isBuffer(srcValue)
const isTyped = !isArr && !isBuff && isTypedArray(srcValue); const isTyped = !isArr && !isBuff && isTypedArray(srcValue)
newValue = srcValue; newValue = srcValue
if (isArr || isBuff || isTyped) { if (isArr || isBuff || isTyped) {
if (Array.isArray(objValue)) { if (Array.isArray(objValue)) {
newValue = objValue; newValue = objValue
} }
else if (isArrayLikeObject(objValue)) { else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue); newValue = copyArray(objValue)
} }
else if (isBuff) { else if (isBuff) {
isCommon = false; isCommon = false
newValue = cloneBuffer(srcValue, true); newValue = cloneBuffer(srcValue, true)
} }
else if (isTyped) { else if (isTyped) {
isCommon = false; isCommon = false
newValue = cloneTypedArray(srcValue, true); newValue = cloneTypedArray(srcValue, true)
} }
else { else {
newValue = []; newValue = []
} }
} }
else if (isPlainObject(srcValue) || isArguments(srcValue)) { else if (isPlainObject(srcValue) || isArguments(srcValue)) {
newValue = objValue; newValue = objValue
if (isArguments(objValue)) { if (isArguments(objValue)) {
newValue = toPlainObject(objValue); newValue = toPlainObject(objValue)
} }
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
newValue = initCloneObject(srcValue); newValue = initCloneObject(srcValue)
} }
} }
else { else {
isCommon = false; isCommon = false
} }
} }
if (isCommon) { if (isCommon) {
// Recursively merge objects and arrays (susceptible to call stack limits). // Recursively merge objects and arrays (susceptible to call stack limits).
stack.set(srcValue, newValue); stack.set(srcValue, newValue)
mergeFunc(newValue, srcValue, srcIndex, customizer, stack); mergeFunc(newValue, srcValue, srcIndex, customizer, stack)
stack['delete'](srcValue); stack['delete'](srcValue)
} }
assignMergeValue(object, key, newValue); assignMergeValue(object, key, newValue)
} }
export default baseMergeDeep; export default baseMergeDeep

View File

@@ -1,4 +1,4 @@
import isIndex from './isIndex.js'; import isIndex from './isIndex.js'
/** /**
* The base implementation of `nth` which doesn't coerce arguments. * The base implementation of `nth` which doesn't coerce arguments.
@@ -9,12 +9,12 @@ import isIndex from './isIndex.js';
* @returns {*} Returns the nth element of `array`. * @returns {*} Returns the nth element of `array`.
*/ */
function baseNth(array, n) { function baseNth(array, n) {
const length = array.length; const length = array.length
if (!length) { if (!length) {
return; return
} }
n += n < 0 ? length : 0; n += n < 0 ? length : 0
return isIndex(n, length) ? array[n] : undefined; return isIndex(n, length) ? array[n] : undefined
} }
export default baseNth; export default baseNth

View File

@@ -1,8 +1,8 @@
import arrayMap from './arrayMap.js'; import arrayMap from './arrayMap.js'
import baseMap from './baseMap.js'; import baseMap from './baseMap.js'
import baseSortBy from './baseSortBy.js'; import baseSortBy from './baseSortBy.js'
import compareMultiple from './compareMultiple.js'; import compareMultiple from './compareMultiple.js'
import identity from '../identity.js'; import identity from '../identity.js'
/** /**
* The base implementation of `orderBy` without param guards. * The base implementation of `orderBy` without param guards.
@@ -14,15 +14,15 @@ import identity from '../identity.js';
* @returns {Array} Returns the new sorted array. * @returns {Array} Returns the new sorted array.
*/ */
function baseOrderBy(collection, iteratees, orders) { function baseOrderBy(collection, iteratees, orders) {
let index = -1; let index = -1
iteratees = iteratees.length ? iteratees : [identity]; iteratees = iteratees.length ? iteratees : [identity]
const result = baseMap(collection, (value, key, collection) => { const result = baseMap(collection, (value, key, collection) => {
const criteria = arrayMap(iteratees, iteratee => iteratee(value)); const criteria = arrayMap(iteratees, iteratee => iteratee(value))
return { 'criteria': criteria, 'index': ++index, 'value': value }; return { 'criteria': criteria, 'index': ++index, 'value': value }
}); })
return baseSortBy(result, (object, other) => compareMultiple(object, other, orders)); return baseSortBy(result, (object, other) => compareMultiple(object, other, orders))
} }
export default baseOrderBy; export default baseOrderBy

View File

@@ -1,5 +1,5 @@
import basePickBy from './basePickBy.js'; import basePickBy from './basePickBy.js'
import hasIn from '../hasIn.js'; import hasIn from '../hasIn.js'
/** /**
* The base implementation of `pick` without support for individual * The base implementation of `pick` without support for individual
@@ -11,7 +11,7 @@ import hasIn from '../hasIn.js';
* @returns {Object} Returns the new object. * @returns {Object} Returns the new object.
*/ */
function basePick(object, paths) { function basePick(object, paths) {
return basePickBy(object, paths, (value, path) => hasIn(object, path)); return basePickBy(object, paths, (value, path) => hasIn(object, path))
} }
export default basePick; export default basePick

View File

@@ -1,6 +1,6 @@
import baseGet from './baseGet.js'; import baseGet from './baseGet.js'
import baseSet from './baseSet.js'; import baseSet from './baseSet.js'
import castPath from './castPath.js'; import castPath from './castPath.js'
/** /**
* The base implementation of `pickBy`. * The base implementation of `pickBy`.
@@ -12,18 +12,18 @@ import castPath from './castPath.js';
* @returns {Object} Returns the new object. * @returns {Object} Returns the new object.
*/ */
function basePickBy(object, paths, predicate) { function basePickBy(object, paths, predicate) {
let index = -1; let index = -1
const length = paths.length; const length = paths.length
const result = {}; const result = {}
while (++index < length) { while (++index < length) {
const path = paths[index]; const path = paths[index]
const value = baseGet(object, path); const value = baseGet(object, path)
if (predicate(value, path)) { if (predicate(value, path)) {
baseSet(result, castPath(path, object), value); baseSet(result, castPath(path, object), value)
} }
} }
return result; return result
} }
export default basePickBy; export default basePickBy

View File

@@ -6,7 +6,7 @@
* @returns {Function} Returns the new accessor function. * @returns {Function} Returns the new accessor function.
*/ */
function baseProperty(key) { function baseProperty(key) {
return object => object == null ? undefined : object[key]; return object => object == null ? undefined : object[key]
} }
export default baseProperty; export default baseProperty

View File

@@ -1,4 +1,4 @@
import baseGet from './baseGet.js'; import baseGet from './baseGet.js'
/** /**
* A specialized version of `baseProperty` which supports deep paths. * A specialized version of `baseProperty` which supports deep paths.
@@ -8,7 +8,7 @@ import baseGet from './baseGet.js';
* @returns {Function} Returns the new accessor function. * @returns {Function} Returns the new accessor function.
*/ */
function basePropertyDeep(path) { function basePropertyDeep(path) {
return object => baseGet(object, path); return object => baseGet(object, path)
} }
export default basePropertyDeep; export default basePropertyDeep

View File

@@ -6,7 +6,7 @@
* @returns {Function} Returns the new accessor function. * @returns {Function} Returns the new accessor function.
*/ */
function basePropertyOf(object) { function basePropertyOf(object) {
return key => object == null ? undefined : object[key]; return key => object == null ? undefined : object[key]
} }
export default basePropertyOf; export default basePropertyOf

View File

@@ -1,10 +1,10 @@
import arrayMap from './arrayMap.js'; import arrayMap from './arrayMap.js'
import baseIndexOf from './baseIndexOf.js'; import baseIndexOf from './baseIndexOf.js'
import baseIndexOfWith from './baseIndexOfWith.js'; import baseIndexOfWith from './baseIndexOfWith.js'
import copyArray from './copyArray.js'; import copyArray from './copyArray.js'
/** Built-in value references. */ /** Built-in value references. */
const splice = Array.prototype.splice; const splice = Array.prototype.splice
/** /**
* The base implementation of `pullAllBy`. * The base implementation of `pullAllBy`.
@@ -17,31 +17,31 @@ const splice = Array.prototype.splice;
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function basePullAll(array, values, iteratee, comparator) { function basePullAll(array, values, iteratee, comparator) {
const indexOf = comparator ? baseIndexOfWith : baseIndexOf; const indexOf = comparator ? baseIndexOfWith : baseIndexOf
const length = values.length; const length = values.length
let index = -1; let index = -1
let seen = array; let seen = array
if (array === values) { if (array === values) {
values = copyArray(values); values = copyArray(values)
} }
if (iteratee) { if (iteratee) {
seen = arrayMap(array, value => iteratee(value)); seen = arrayMap(array, value => iteratee(value))
} }
while (++index < length) { while (++index < length) {
let fromIndex = 0; let fromIndex = 0
const value = values[index]; const value = values[index]
const computed = iteratee ? iteratee(value) : value; const computed = iteratee ? iteratee(value) : value
while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
if (seen !== array) { if (seen !== array) {
splice.call(seen, fromIndex, 1); splice.call(seen, fromIndex, 1)
} }
splice.call(array, fromIndex, 1); splice.call(array, fromIndex, 1)
} }
} }
return array; return array
} }
export default basePullAll; export default basePullAll

View File

@@ -1,8 +1,8 @@
import baseUnset from './baseUnset.js'; import baseUnset from './baseUnset.js'
import isIndex from './isIndex.js'; import isIndex from './isIndex.js'
/** Built-in value references. */ /** Built-in value references. */
const splice = Array.prototype.splice; const splice = Array.prototype.splice
/** /**
* The base implementation of `pullAt` without support for individual * The base implementation of `pullAt` without support for individual
@@ -14,22 +14,22 @@ const splice = Array.prototype.splice;
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function basePullAt(array, indexes) { function basePullAt(array, indexes) {
let length = array ? indexes.length : 0; let length = array ? indexes.length : 0
const lastIndex = length - 1; const lastIndex = length - 1
while (length--) { while (length--) {
let previous; let previous
const index = indexes[length]; const index = indexes[length]
if (length == lastIndex || index !== previous) { if (length == lastIndex || index !== previous) {
previous = index; previous = index
if (isIndex(index)) { if (isIndex(index)) {
splice.call(array, index, 1); splice.call(array, index, 1)
} else { } else {
baseUnset(array, index); baseUnset(array, index)
} }
} }
} }
return array; return array
} }
export default basePullAt; export default basePullAt

View File

@@ -8,7 +8,7 @@
* @returns {number} Returns the random number. * @returns {number} Returns the random number.
*/ */
function baseRandom(lower, upper) { function baseRandom(lower, upper) {
return lower + Math.floor(Math.random() * (upper - lower + 1)); return lower + Math.floor(Math.random() * (upper - lower + 1))
} }
export default baseRandom; export default baseRandom

View File

@@ -1,6 +1,6 @@
/* Built-in method references for those with the same name as other `lodash` methods. */ /* Built-in method references for those with the same name as other `lodash` methods. */
const nativeCeil = Math.ceil; const nativeCeil = Math.ceil
const nativeMax = Math.max; const nativeMax = Math.max
/** /**
* The base implementation of `range` and `rangeRight` which doesn't * The base implementation of `range` and `rangeRight` which doesn't
@@ -14,15 +14,15 @@ const nativeMax = Math.max;
* @returns {Array} Returns the range of numbers. * @returns {Array} Returns the range of numbers.
*/ */
function baseRange(start, end, step, fromRight) { function baseRange(start, end, step, fromRight) {
let index = -1; let index = -1
let length = nativeMax(nativeCeil((end - start) / (step || 1)), 0); let length = nativeMax(nativeCeil((end - start) / (step || 1)), 0)
const result = Array(length); const result = Array(length)
while (length--) { while (length--) {
result[fromRight ? length : ++index] = start; result[fromRight ? length : ++index] = start
start += step; start += step
} }
return result; return result
} }
export default baseRange; export default baseRange

View File

@@ -15,9 +15,9 @@ function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
eachFunc(collection, (value, index, collection) => { eachFunc(collection, (value, index, collection) => {
accumulator = initAccum accumulator = initAccum
? (initAccum = false, value) ? (initAccum = false, value)
: iteratee(accumulator, value, index, collection); : iteratee(accumulator, value, index, collection)
}); })
return accumulator; return accumulator
} }
export default baseReduce; export default baseReduce

View File

@@ -1,8 +1,8 @@
/** Used as references for various `Number` constants. */ /** Used as references for various `Number` constants. */
const MAX_SAFE_INTEGER = 9007199254740991; const MAX_SAFE_INTEGER = 9007199254740991
/* Built-in method references for those with the same name as other `lodash` methods. */ /* Built-in method references for those with the same name as other `lodash` methods. */
const nativeFloor = Math.floor; const nativeFloor = Math.floor
/** /**
* The base implementation of `repeat` which doesn't coerce arguments. * The base implementation of `repeat` which doesn't coerce arguments.
@@ -13,23 +13,23 @@ const nativeFloor = Math.floor;
* @returns {string} Returns the repeated string. * @returns {string} Returns the repeated string.
*/ */
function baseRepeat(string, n) { function baseRepeat(string, n) {
let result = ''; let result = ''
if (!string || n < 1 || n > MAX_SAFE_INTEGER) { if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
return result; return result
} }
// Leverage the exponentiation by squaring algorithm for a faster repeat. // Leverage the exponentiation by squaring algorithm for a faster repeat.
// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
do { do {
if (n % 2) { if (n % 2) {
result += string; result += string
} }
n = nativeFloor(n / 2); n = nativeFloor(n / 2)
if (n) { if (n) {
string += string; string += string
} }
} while (n); } while (n)
return result; return result
} }
export default baseRepeat; export default baseRepeat

View File

@@ -1,5 +1,5 @@
import arraySample from './arraySample.js'; import arraySample from './arraySample.js'
import values from '../values.js'; import values from '../values.js'
/** /**
* The base implementation of `sample`. * The base implementation of `sample`.
@@ -9,7 +9,7 @@ import values from '../values.js';
* @returns {*} Returns the random element. * @returns {*} Returns the random element.
*/ */
function baseSample(collection) { function baseSample(collection) {
return arraySample(values(collection)); return arraySample(values(collection))
} }
export default baseSample; export default baseSample

View File

@@ -1,6 +1,6 @@
import baseClamp from './baseClamp.js'; import baseClamp from './baseClamp.js'
import shuffleSelf from './shuffleSelf.js'; import shuffleSelf from './shuffleSelf.js'
import values from '../values.js'; import values from '../values.js'
/** /**
* The base implementation of `sampleSize` without param guards. * The base implementation of `sampleSize` without param guards.
@@ -11,8 +11,8 @@ import values from '../values.js';
* @returns {Array} Returns the random elements. * @returns {Array} Returns the random elements.
*/ */
function baseSampleSize(collection, n) { function baseSampleSize(collection, n) {
const array = values(collection); const array = values(collection)
return shuffleSelf(array, baseClamp(n, 0, array.length)); return shuffleSelf(array, baseClamp(n, 0, array.length))
} }
export default baseSampleSize; export default baseSampleSize

View File

@@ -1,8 +1,8 @@
import assignValue from './assignValue.js'; import assignValue from './assignValue.js'
import castPath from './castPath.js'; import castPath from './castPath.js'
import isIndex from './isIndex.js'; import isIndex from './isIndex.js'
import isObject from '../isObject.js'; import isObject from '../isObject.js'
import toKey from './toKey.js'; import toKey from './toKey.js'
/** /**
* The base implementation of `set`. * The base implementation of `set`.
@@ -16,33 +16,33 @@ import toKey from './toKey.js';
*/ */
function baseSet(object, path, value, customizer) { function baseSet(object, path, value, customizer) {
if (!isObject(object)) { if (!isObject(object)) {
return object; return object
} }
path = castPath(path, object); path = castPath(path, object)
const length = path.length; const length = path.length
const lastIndex = length - 1; const lastIndex = length - 1
let index = -1; let index = -1
let nested = object; let nested = object
while (nested != null && ++index < length) { while (nested != null && ++index < length) {
const key = toKey(path[index]); const key = toKey(path[index])
let newValue = value; let newValue = value
if (index != lastIndex) { if (index != lastIndex) {
const objValue = nested[key]; const objValue = nested[key]
newValue = customizer ? customizer(objValue, key, nested) : undefined; newValue = customizer ? customizer(objValue, key, nested) : undefined
if (newValue === undefined) { if (newValue === undefined) {
newValue = isObject(objValue) newValue = isObject(objValue)
? objValue ? objValue
: (isIndex(path[index + 1]) ? [] : {}); : (isIndex(path[index + 1]) ? [] : {})
} }
} }
assignValue(nested, key, newValue); assignValue(nested, key, newValue)
nested = nested[key]; nested = nested[key]
} }
return object; return object
} }
export default baseSet; export default baseSet

View File

@@ -1,5 +1,5 @@
import constant from '../constant.js'; import constant from '../constant.js'
import identity from '../identity.js'; import identity from '../identity.js'
/** /**
* The base implementation of `setToString` without support for hot loop shorting. * The base implementation of `setToString` without support for hot loop shorting.
@@ -15,7 +15,7 @@ function baseSetToString(func, string){
'enumerable': false, 'enumerable': false,
'value': constant(string), 'value': constant(string),
'writable': true 'writable': true
}); })
} }
export default baseSetToString; export default baseSetToString

View File

@@ -1,5 +1,5 @@
import shuffleSelf from './shuffleSelf.js'; import shuffleSelf from './shuffleSelf.js'
import values from '../values.js'; import values from '../values.js'
/** /**
* The base implementation of `shuffle`. * The base implementation of `shuffle`.
@@ -9,7 +9,7 @@ import values from '../values.js';
* @returns {Array} Returns the new shuffled array. * @returns {Array} Returns the new shuffled array.
*/ */
function baseShuffle(collection) { function baseShuffle(collection) {
return shuffleSelf(values(collection)); return shuffleSelf(values(collection))
} }
export default baseShuffle; export default baseShuffle

View File

@@ -9,23 +9,23 @@
*/ */
function baseSlice(array, start, end) { function baseSlice(array, start, end) {
let index = -1, let index = -1,
length = array.length; length = array.length
if (start < 0) { if (start < 0) {
start = -start > length ? 0 : (length + start); start = -start > length ? 0 : (length + start)
} }
end = end > length ? length : end; end = end > length ? length : end
if (end < 0) { if (end < 0) {
end += length; end += length
} }
length = start > end ? 0 : ((end - start) >>> 0); length = start > end ? 0 : ((end - start) >>> 0)
start >>>= 0; start >>>= 0
const result = Array(length); const result = Array(length)
while (++index < length) { while (++index < length) {
result[index] = array[index + start]; result[index] = array[index + start]
} }
return result; return result
} }
export default baseSlice; export default baseSlice

View File

@@ -1,4 +1,4 @@
import baseEach from './baseEach.js'; import baseEach from './baseEach.js'
/** /**
* The base implementation of `some`. * The base implementation of `some`.
@@ -10,13 +10,13 @@ import baseEach from './baseEach.js';
* else `false`. * else `false`.
*/ */
function baseSome(collection, predicate) { function baseSome(collection, predicate) {
let result; let result
baseEach(collection, (value, index, collection) => { baseEach(collection, (value, index, collection) => {
result = predicate(value, index, collection); result = predicate(value, index, collection)
return !result; return !result
}); })
return !!result; return !!result
} }
export default baseSome; export default baseSome

View File

@@ -9,13 +9,13 @@
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function baseSortBy(array, comparer) { function baseSortBy(array, comparer) {
let length = array.length; let length = array.length
array.sort(comparer); array.sort(comparer)
while (length--) { while (length--) {
array[length] = array[length].value; array[length] = array[length].value
} }
return array; return array
} }
export default baseSortBy; export default baseSortBy

View File

@@ -1,10 +1,10 @@
import baseSortedIndexBy from './baseSortedIndexBy.js'; import baseSortedIndexBy from './baseSortedIndexBy.js'
import identity from '../identity.js'; import identity from '../identity.js'
import isSymbol from '../isSymbol.js'; import isSymbol from '../isSymbol.js'
/** Used as references for the maximum length and index of an array. */ /** Used as references for the maximum length and index of an array. */
const MAX_ARRAY_LENGTH = 4294967295; const MAX_ARRAY_LENGTH = 4294967295
const HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; const HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1
/** /**
* The base implementation of `sortedIndex` and `sortedLastIndex` which * The base implementation of `sortedIndex` and `sortedLastIndex` which
@@ -19,23 +19,23 @@ const HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
* into `array`. * into `array`.
*/ */
function baseSortedIndex(array, value, retHighest) { function baseSortedIndex(array, value, retHighest) {
let low = 0; let low = 0
let high = array == null ? low : array.length; let high = array == null ? low : array.length
if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
while (low < high) { while (low < high) {
const mid = (low + high) >>> 1; const mid = (low + high) >>> 1
const computed = array[mid]; const computed = array[mid]
if (computed !== null && !isSymbol(computed) && if (computed !== null && !isSymbol(computed) &&
(retHighest ? (computed <= value) : (computed < value))) { (retHighest ? (computed <= value) : (computed < value))) {
low = mid + 1; low = mid + 1
} else { } else {
high = mid; high = mid
} }
} }
return high; return high
} }
return baseSortedIndexBy(array, value, identity, retHighest); return baseSortedIndexBy(array, value, identity, retHighest)
} }
export default baseSortedIndex; export default baseSortedIndex

View File

@@ -1,16 +1,16 @@
import isSymbol from '../isSymbol.js'; import isSymbol from '../isSymbol.js'
/** Used as references for the maximum length and index of an array. */ /** Used as references for the maximum length and index of an array. */
const MAX_ARRAY_LENGTH = 4294967295; const MAX_ARRAY_LENGTH = 4294967295
const MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; const MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1
/* Built-in method references for those with the same name as other `lodash` methods. */ /* Built-in method references for those with the same name as other `lodash` methods. */
const nativeFloor = Math.floor, nativeMin = Math.min; const nativeFloor = Math.floor, nativeMin = Math.min
/** /**
* The base implementation of `sortedIndexBy` and `sortedLastIndexBy` * The base implementation of `sortedIndexBy` and `sortedLastIndexBy`
* which invokes `iteratee` for `value` and each element of `array` to compute * which invokes `iteratee` for `value` and each element of `array` to compute
* their sort ranking. The iteratee is invoked with one argument; (value). * their sort ranking. The iteratee is invoked with one argument (value).
* *
* @private * @private
* @param {Array} array The sorted array to inspect. * @param {Array} array The sorted array to inspect.
@@ -21,44 +21,44 @@ const nativeFloor = Math.floor, nativeMin = Math.min;
* into `array`. * into `array`.
*/ */
function baseSortedIndexBy(array, value, iteratee, retHighest) { function baseSortedIndexBy(array, value, iteratee, retHighest) {
value = iteratee(value); value = iteratee(value)
let low = 0; let low = 0
let high = array == null ? 0 : array.length; let high = array == null ? 0 : array.length
const valIsNaN = value !== value; const valIsNaN = value !== value
const valIsNull = value === null; const valIsNull = value === null
const valIsSymbol = isSymbol(value); const valIsSymbol = isSymbol(value)
const valIsUndefined = value === undefined; const valIsUndefined = value === undefined
while (low < high) { while (low < high) {
let setLow; let setLow
const mid = nativeFloor((low + high) / 2); const mid = nativeFloor((low + high) / 2)
const computed = iteratee(array[mid]); const computed = iteratee(array[mid])
const othIsDefined = computed !== undefined; const othIsDefined = computed !== undefined
const othIsNull = computed === null; const othIsNull = computed === null
const othIsReflexive = computed === computed; const othIsReflexive = computed === computed
const othIsSymbol = isSymbol(computed); const othIsSymbol = isSymbol(computed)
if (valIsNaN) { if (valIsNaN) {
setLow = retHighest || othIsReflexive; setLow = retHighest || othIsReflexive
} else if (valIsUndefined) { } else if (valIsUndefined) {
setLow = othIsReflexive && (retHighest || othIsDefined); setLow = othIsReflexive && (retHighest || othIsDefined)
} else if (valIsNull) { } else if (valIsNull) {
setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull)
} else if (valIsSymbol) { } else if (valIsSymbol) {
setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol)
} else if (othIsNull || othIsSymbol) { } else if (othIsNull || othIsSymbol) {
setLow = false; setLow = false
} else { } else {
setLow = retHighest ? (computed <= value) : (computed < value); setLow = retHighest ? (computed <= value) : (computed < value)
} }
if (setLow) { if (setLow) {
low = mid + 1; low = mid + 1
} else { } else {
high = mid; high = mid
} }
} }
return nativeMin(high, MAX_ARRAY_INDEX); return nativeMin(high, MAX_ARRAY_INDEX)
} }
export default baseSortedIndexBy; export default baseSortedIndexBy

View File

@@ -1,4 +1,4 @@
import eq from '../eq.js'; import eq from '../eq.js'
/** /**
* The base implementation of `sortedUniq` and `sortedUniqBy`. * The base implementation of `sortedUniq` and `sortedUniqBy`.
@@ -9,21 +9,21 @@ import eq from '../eq.js';
* @returns {Array} Returns the new duplicate free array. * @returns {Array} Returns the new duplicate free array.
*/ */
function baseSortedUniq(array, iteratee) { function baseSortedUniq(array, iteratee) {
let seen; let seen
let index = -1; let index = -1
let resIndex = 0; let resIndex = 0
const length = array.length; const length = array.length
const result = []; const result = []
while (++index < length) { while (++index < length) {
const value = array[index], computed = iteratee ? iteratee(value) : value; const value = array[index], computed = iteratee ? iteratee(value) : value
if (!index || !eq(computed, seen)) { if (!index || !eq(computed, seen)) {
seen = computed; seen = computed
result[resIndex++] = value === 0 ? 0 : value; result[resIndex++] = value === 0 ? 0 : value
} }
} }
return result; return result
} }
export default baseSortedUniq; export default baseSortedUniq

View File

@@ -7,17 +7,17 @@
* @returns {number} Returns the sum. * @returns {number} Returns the sum.
*/ */
function baseSum(array, iteratee) { function baseSum(array, iteratee) {
let result; let result
let index = -1; let index = -1
const length = array.length; const length = array.length
while (++index < length) { while (++index < length) {
const current = iteratee(array[index]); const current = iteratee(array[index])
if (current !== undefined) { if (current !== undefined) {
result = result === undefined ? current : (result + current); result = result === undefined ? current : (result + current)
} }
} }
return result; return result
} }
export default baseSum; export default baseSum

View File

@@ -7,13 +7,13 @@
* @returns {Array} Returns the array of results. * @returns {Array} Returns the array of results.
*/ */
function baseTimes(n, iteratee) { function baseTimes(n, iteratee) {
let index = -1; let index = -1
const result = Array(n); const result = Array(n)
while (++index < n) { while (++index < n) {
result[index] = iteratee(index); result[index] = iteratee(index)
} }
return result; return result
} }
export default baseTimes; export default baseTimes

View File

@@ -1,7 +1,7 @@
import isSymbol from '../isSymbol.js'; import isSymbol from '../isSymbol.js'
/** Used as references for various `Number` constants. */ /** Used as references for various `Number` constants. */
const NAN = 0 / 0; const NAN = 0 / 0
/** /**
* The base implementation of `toNumber` which doesn't ensure correct * The base implementation of `toNumber` which doesn't ensure correct
@@ -13,12 +13,12 @@ const NAN = 0 / 0;
*/ */
function baseToNumber(value) { function baseToNumber(value) {
if (typeof value == 'number') { if (typeof value == 'number') {
return value; return value
} }
if (isSymbol(value)) { if (isSymbol(value)) {
return NAN; return NAN
} }
return +value; return +value
} }
export default baseToNumber; export default baseToNumber

View File

@@ -1,12 +1,12 @@
import arrayMap from './arrayMap.js'; import arrayMap from './arrayMap.js'
import isSymbol from '../isSymbol.js'; import isSymbol from '../isSymbol.js'
/** Used as references for various `Number` constants. */ /** Used as references for various `Number` constants. */
const INFINITY = 1 / 0; const INFINITY = 1 / 0
/** Used to convert symbols to primitives and strings. */ /** Used to convert symbols to primitives and strings. */
const symbolProto = Symbol ? Symbol.prototype : undefined; const symbolProto = Symbol ? Symbol.prototype : undefined
const symbolToString = symbolProto ? symbolProto.toString : undefined; const symbolToString = symbolProto ? symbolProto.toString : undefined
/** /**
* The base implementation of `toString` which doesn't convert nullish * The base implementation of `toString` which doesn't convert nullish
@@ -19,17 +19,17 @@ const symbolToString = symbolProto ? symbolProto.toString : undefined;
function baseToString(value) { function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments. // Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') { if (typeof value == 'string') {
return value; return value
} }
if (Array.isArray(value)) { if (Array.isArray(value)) {
// Recursively convert values (susceptible to call stack limits). // Recursively convert values (susceptible to call stack limits).
return `${ arrayMap(value, baseToString) }`; return `${ arrayMap(value, baseToString) }`
} }
if (isSymbol(value)) { if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : ''; return symbolToString ? symbolToString.call(value) : ''
} }
const result = `${ value }`; const result = `${ value }`
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result
} }
export default baseToString; export default baseToString

View File

@@ -1,12 +1,12 @@
import SetCache from './SetCache.js'; import SetCache from './SetCache.js'
import arrayIncludes from './arrayIncludes.js'; import arrayIncludes from './arrayIncludes.js'
import arrayIncludesWith from './arrayIncludesWith.js'; import arrayIncludesWith from './arrayIncludesWith.js'
import cacheHas from './cacheHas.js'; import cacheHas from './cacheHas.js'
import createSet from './createSet.js'; import createSet from './createSet.js'
import setToArray from './setToArray.js'; import setToArray from './setToArray.js'
/** Used as the size to enable large array optimizations. */ /** Used as the size to enable large array optimizations. */
const LARGE_ARRAY_SIZE = 200; const LARGE_ARRAY_SIZE = 200
/** /**
* The base implementation of `uniqBy`. * The base implementation of `uniqBy`.
@@ -18,56 +18,56 @@ const LARGE_ARRAY_SIZE = 200;
* @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) {
let index = -1; let index = -1
let includes = arrayIncludes; let includes = arrayIncludes
let isCommon = true; let isCommon = true
const length = array.length; const length = array.length
const result = []; const result = []
let seen = result; let seen = result
if (comparator) { if (comparator) {
isCommon = false; isCommon = false
includes = arrayIncludesWith; includes = arrayIncludesWith
} }
else if (length >= LARGE_ARRAY_SIZE) { else if (length >= LARGE_ARRAY_SIZE) {
const set = iteratee ? null : createSet(array); const set = iteratee ? null : createSet(array)
if (set) { if (set) {
return setToArray(set); return setToArray(set)
} }
isCommon = false; isCommon = false
includes = cacheHas; includes = cacheHas
seen = new SetCache; seen = new SetCache
} }
else { else {
seen = iteratee ? [] : result; seen = iteratee ? [] : result
} }
outer: outer:
while (++index < length) { while (++index < length) {
let value = array[index]; let value = array[index]
const computed = iteratee ? iteratee(value) : value; const computed = iteratee ? iteratee(value) : value
value = (comparator || value !== 0) ? value : 0; value = (comparator || value !== 0) ? value : 0
if (isCommon && computed === computed) { if (isCommon && computed === computed) {
let seenIndex = seen.length; let seenIndex = seen.length
while (seenIndex--) { while (seenIndex--) {
if (seen[seenIndex] === computed) { if (seen[seenIndex] === computed) {
continue outer; continue outer
} }
} }
if (iteratee) { if (iteratee) {
seen.push(computed); seen.push(computed)
} }
result.push(value); result.push(value)
} }
else if (!includes(seen, computed, comparator)) { else if (!includes(seen, computed, comparator)) {
if (seen !== result) { if (seen !== result) {
seen.push(computed); seen.push(computed)
} }
result.push(value); result.push(value)
} }
} }
return result; return result
} }
export default baseUniq; export default baseUniq

Some files were not shown because too many files have changed in this diff Show More