Use Array.isArray.

This commit is contained in:
John-David Dalton
2017-01-09 18:44:38 -08:00
parent 395a81058b
commit 68190b8546
31 changed files with 34 additions and 64 deletions

View File

@@ -1,6 +1,5 @@
import baseTimes from './_baseTimes.js'; import baseTimes from './_baseTimes.js';
import isArguments from './isArguments.js'; import isArguments from './isArguments.js';
import isArray from './isArray.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';
@@ -17,7 +16,7 @@ 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 = 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);

View File

@@ -13,7 +13,6 @@ 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 isArray from './isArray.js';
import isBuffer from './isBuffer.js'; import isBuffer from './isBuffer.js';
import isObject from './isObject.js'; import isObject from './isObject.js';
import keys from './keys.js'; import keys from './keys.js';
@@ -99,7 +98,7 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
if (!isObject(value)) { if (!isObject(value)) {
return value; return value;
} }
const isArr = isArray(value); const isArr = Array.isArray(value);
if (isArr) { if (isArr) {
result = initCloneArray(value); result = initCloneArray(value);
if (!isDeep) { if (!isDeep) {

View File

@@ -1,5 +1,4 @@
import arrayPush from './_arrayPush.js'; import arrayPush from './_arrayPush.js';
import isArray from './isArray.js';
/** /**
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
@@ -14,7 +13,7 @@ import isArray from './isArray.js';
*/ */
function baseGetAllKeys(object, keysFunc, symbolsFunc) { function baseGetAllKeys(object, keysFunc, symbolsFunc) {
const result = keysFunc(object); const result = keysFunc(object);
return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); return Array.isArray(object) ? result : arrayPush(result, symbolsFunc(object));
} }
export default baseGetAllKeys; export default baseGetAllKeys;

View File

@@ -3,7 +3,6 @@ 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 isArray from './isArray.js';
import isBuffer from './isBuffer.js'; import isBuffer from './isBuffer.js';
import isTypedArray from './isTypedArray.js'; import isTypedArray from './isTypedArray.js';
@@ -33,8 +32,8 @@ 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 = isArray(object); let objIsArr = Array.isArray(object);
const othIsArr = 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);

View File

@@ -4,7 +4,6 @@ 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 isArray from './isArray.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';
@@ -44,13 +43,13 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
let isCommon = newValue === undefined; let isCommon = newValue === undefined;
if (isCommon) { if (isCommon) {
const isArr = 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 (isArray(objValue)) { if (Array.isArray(objValue)) {
newValue = objValue; newValue = objValue;
} }
else if (isArrayLikeObject(objValue)) { else if (isArrayLikeObject(objValue)) {

View File

@@ -1,6 +1,5 @@
import Symbol from './_Symbol.js'; import Symbol from './_Symbol.js';
import arrayMap from './_arrayMap.js'; import arrayMap from './_arrayMap.js';
import isArray from './isArray.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. */
@@ -23,7 +22,7 @@ function baseToString(value) {
if (typeof value == 'string') { if (typeof value == 'string') {
return value; return value;
} }
if (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) }`;
} }

View File

@@ -1,4 +1,3 @@
import isArray from './isArray.js';
import isKey from './_isKey.js'; import isKey from './_isKey.js';
import stringToPath from './_stringToPath.js'; import stringToPath from './_stringToPath.js';
import toString from './toString.js'; import toString from './toString.js';
@@ -12,7 +11,7 @@ import toString from './toString.js';
* @returns {Array} Returns the cast property path array. * @returns {Array} Returns the cast property path array.
*/ */
function castPath(value, object) { function castPath(value, object) {
if (isArray(value)) { if (Array.isArray(value)) {
return value; return value;
} }
return isKey(value, object) ? [value] : stringToPath(toString(value)); return isKey(value, object) ? [value] : stringToPath(toString(value));

View File

@@ -1,6 +1,5 @@
import arrayAggregator from './_arrayAggregator.js'; import arrayAggregator from './_arrayAggregator.js';
import baseAggregator from './_baseAggregator.js'; import baseAggregator from './_baseAggregator.js';
import isArray from './isArray.js';
/** /**
* Creates a function like `groupBy`. * Creates a function like `groupBy`.
@@ -12,7 +11,7 @@ import isArray from './isArray.js';
*/ */
function createAggregator(setter, initializer) { function createAggregator(setter, initializer) {
return (collection, iteratee) => { return (collection, iteratee) => {
const func = isArray(collection) ? arrayAggregator : baseAggregator; const func = Array.isArray(collection) ? arrayAggregator : baseAggregator;
const accumulator = initializer ? initializer() : {}; const accumulator = initializer ? initializer() : {};
return func(collection, setter, iteratee, accumulator); return func(collection, setter, iteratee, accumulator);
}; };

View File

@@ -1,6 +1,5 @@
import castPath from './_castPath.js'; import castPath from './_castPath.js';
import isArguments from './isArguments.js'; import isArguments from './isArguments.js';
import isArray from './isArray.js';
import isIndex from './_isIndex.js'; import isIndex from './_isIndex.js';
import isLength from './isLength.js'; import isLength from './isLength.js';
import toKey from './_toKey.js'; import toKey from './_toKey.js';
@@ -34,7 +33,7 @@ function hasPath(object, path, hasFunc) {
} }
length = object == null ? 0 : object.length; length = object == null ? 0 : object.length;
return !!length && isLength(length) && isIndex(key, length) && return !!length && isLength(length) && isIndex(key, length) &&
(isArray(object) || isArguments(object)); (Array.isArray(object) || isArguments(object));
} }
export default hasPath; export default hasPath;

View File

@@ -1,6 +1,5 @@
import Symbol from './_Symbol.js'; import Symbol from './_Symbol.js';
import isArguments from './isArguments.js'; import isArguments from './isArguments.js';
import isArray from './isArray.js';
/** Built-in value references. */ /** Built-in value references. */
const spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined; const spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
@@ -13,7 +12,7 @@ const spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
*/ */
function isFlattenable(value) { function isFlattenable(value) {
return isArray(value) || isArguments(value) || return Array.isArray(value) || isArguments(value) ||
!!(spreadableSymbol && value && value[spreadableSymbol]); !!(spreadableSymbol && value && value[spreadableSymbol]);
} }

View File

@@ -1,4 +1,3 @@
import isArray from './isArray.js';
import isSymbol from './isSymbol.js'; import isSymbol from './isSymbol.js';
/** Used to match property names within property paths. */ /** Used to match property names within property paths. */
@@ -14,7 +13,7 @@ const reIsPlainProp = /^\w*$/;
* @returns {boolean} Returns `true` if `value` is a property name, else `false`. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/ */
function isKey(value, object) { function isKey(value, object) {
if (isArray(value)) { if (Array.isArray(value)) {
return false; return false;
} }
const type = typeof value; const type = typeof value;

View File

@@ -1,4 +1,3 @@
import isArray from './isArray.js';
/** /**
* Casts `value` as an array if it's not one. * Casts `value` as an array if it's not one.
@@ -37,7 +36,7 @@ function castArray(...args) {
return []; return [];
} }
const value = args[0]; const value = args[0];
return isArray(value) ? value : [value]; return Array.isArray(value) ? value : [value];
} }
export default castArray; export default castArray;

View File

@@ -1,7 +1,6 @@
import arrayPush from './_arrayPush.js'; import arrayPush from './_arrayPush.js';
import baseFlatten from './_baseFlatten.js'; import baseFlatten from './_baseFlatten.js';
import copyArray from './_copyArray.js'; import copyArray from './_copyArray.js';
import isArray from './isArray.js';
/** /**
* Creates a new array concatenating `array` with any additional arrays * Creates a new array concatenating `array` with any additional arrays
@@ -25,7 +24,7 @@ import isArray from './isArray.js';
* // => [1] * // => [1]
*/ */
function concat(array, ...values) { function concat(array, ...values) {
return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); return arrayPush(Array.isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
} }
export default concat; export default concat;

View File

@@ -1,6 +1,5 @@
import arrayEvery from './_arrayEvery.js'; import arrayEvery from './_arrayEvery.js';
import baseEvery from './_baseEvery.js'; import baseEvery from './_baseEvery.js';
import isArray from './isArray.js';
import isIterateeCall from './_isIterateeCall.js'; import isIterateeCall from './_isIterateeCall.js';
/** /**
@@ -27,7 +26,7 @@ import isIterateeCall from './_isIterateeCall.js';
* // => false * // => false
*/ */
function every(collection, predicate, guard) { function every(collection, predicate, guard) {
const func = isArray(collection) ? arrayEvery : baseEvery; const func = Array.isArray(collection) ? arrayEvery : baseEvery;
if (guard && isIterateeCall(collection, predicate, guard)) { if (guard && isIterateeCall(collection, predicate, guard)) {
predicate = undefined; predicate = undefined;
} }

View File

@@ -1,6 +1,5 @@
import arrayFilter from './_arrayFilter.js'; import arrayFilter from './_arrayFilter.js';
import baseFilter from './_baseFilter.js'; import baseFilter from './_baseFilter.js';
import isArray from './isArray.js';
/** /**
* Iterates over elements of `collection`, returning an array of all elements * Iterates over elements of `collection`, returning an array of all elements
@@ -27,7 +26,7 @@ import isArray from './isArray.js';
* // => objects for ['fred'] * // => objects for ['fred']
*/ */
function filter(collection, predicate) { function filter(collection, predicate) {
const func = isArray(collection) ? arrayFilter : baseFilter; const func = Array.isArray(collection) ? arrayFilter : baseFilter;
return func(collection, predicate); return func(collection, predicate);
} }

View File

@@ -1,6 +1,5 @@
import arrayEach from './_arrayEach.js'; import arrayEach from './_arrayEach.js';
import baseEach from './_baseEach.js';; import baseEach from './_baseEach.js';;
import isArray from './isArray.js';
/** /**
* Iterates over elements of `collection` and invokes `iteratee` for each element. * Iterates over elements of `collection` and invokes `iteratee` for each element.
@@ -32,7 +31,7 @@ import isArray from './isArray.js';
* // => Logs 'a' then 'b' (iteration order is not guaranteed). * // => Logs 'a' then 'b' (iteration order is not guaranteed).
*/ */
function forEach(collection, iteratee) { function forEach(collection, iteratee) {
const func = isArray(collection) ? arrayEach : baseEach; const func = Array.isArray(collection) ? arrayEach : baseEach;
return func(collection, iteratee); return func(collection, iteratee);
} }

View File

@@ -1,6 +1,5 @@
import arrayEachRight from './_arrayEachRight.js'; import arrayEachRight from './_arrayEachRight.js';
import baseEachRight from './_baseEachRight.js'; import baseEachRight from './_baseEachRight.js';
import isArray from './isArray.js';
/** /**
* This method is like `forEach` except that it iterates over elements of * This method is like `forEach` except that it iterates over elements of
@@ -22,7 +21,7 @@ import isArray from './isArray.js';
* // => Logs `2` then `1`. * // => Logs `2` then `1`.
*/ */
function forEachRight(collection, iteratee) { function forEachRight(collection, iteratee) {
const func = isArray(collection) ? arrayEachRight : baseEachRight; const func = Array.isArray(collection) ? arrayEachRight : baseEachRight;
return func(collection, iteratee); return func(collection, iteratee);
} }

View File

@@ -1,7 +1,6 @@
import baseKeys from './_baseKeys.js'; import baseKeys from './_baseKeys.js';
import getTag from './_getTag.js'; import getTag from './_getTag.js';
import isArguments from './isArguments.js'; import isArguments from './isArguments.js';
import isArray from './isArray.js';
import isArrayLike from './isArrayLike.js'; import isArrayLike from './isArrayLike.js';
import isBuffer from './isBuffer.js'; import isBuffer from './isBuffer.js';
import isPrototype from './_isPrototype.js'; import isPrototype from './_isPrototype.js';
@@ -51,7 +50,7 @@ function isEmpty(value) {
return true; return true;
} }
if (isArrayLike(value) && if (isArrayLike(value) &&
(isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || (Array.isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
isBuffer(value) || isTypedArray(value) || isArguments(value))) { isBuffer(value) || isTypedArray(value) || isArguments(value))) {
return !value.length; return !value.length;
} }

View File

@@ -1,5 +1,4 @@
import baseGetTag from './_baseGetTag.js'; import baseGetTag from './_baseGetTag.js';
import isArray from './isArray.js';
import isObjectLike from './isObjectLike.js'; import isObjectLike from './isObjectLike.js';
/** `Object#toString` result references. */ /** `Object#toString` result references. */
@@ -23,7 +22,7 @@ const stringTag = '[object String]';
*/ */
function isString(value) { function isString(value) {
return typeof value == 'string' || return typeof value == 'string' ||
(!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); (!Array.isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
} }
export default isString; export default isString;

3
map.js
View File

@@ -1,6 +1,5 @@
import arrayMap from './_arrayMap.js'; import arrayMap from './_arrayMap.js';
import baseMap from './_baseMap.js'; import baseMap from './_baseMap.js';
import isArray from './isArray.js';
/** /**
* Creates an array of values by running each element in `collection` thru * Creates an array of values by running each element in `collection` thru
@@ -35,7 +34,7 @@ import isArray from './isArray.js';
* // => [16, 64] (iteration order is not guaranteed) * // => [16, 64] (iteration order is not guaranteed)
*/ */
function map(collection, iteratee) { function map(collection, iteratee) {
const func = isArray(collection) ? arrayMap : baseMap; const func = Array.isArray(collection) ? arrayMap : baseMap;
return func(collection, iteratee); return func(collection, iteratee);
} }

View File

@@ -20,7 +20,7 @@ import createAssigner from './_createAssigner.js';
* @example * @example
* *
* function customizer(objValue, srcValue) { * function customizer(objValue, srcValue) {
* if (isArray(objValue)) { * if (Array.isArray(objValue)) {
* return objValue.concat(srcValue); * return objValue.concat(srcValue);
* } * }
* } * }

View File

@@ -1,5 +1,4 @@
import baseOrderBy from './_baseOrderBy.js'; import baseOrderBy from './_baseOrderBy.js';
import isArray from './isArray.js';
/** /**
* This method is like `sortBy` except that it allows specifying the sort * This method is like `sortBy` except that it allows specifying the sort
@@ -33,11 +32,11 @@ function orderBy(collection, iteratees, orders, guard) {
if (collection == null) { if (collection == null) {
return []; return [];
} }
if (!isArray(iteratees)) { if (!Array.isArray(iteratees)) {
iteratees = iteratees == null ? [] : [iteratees]; iteratees = iteratees == null ? [] : [iteratees];
} }
orders = guard ? undefined : orders; orders = guard ? undefined : orders;
if (!isArray(orders)) { if (!Array.isArray(orders)) {
orders = orders == null ? [] : [orders]; orders = orders == null ? [] : [orders];
} }
return baseOrderBy(collection, iteratees, orders); return baseOrderBy(collection, iteratees, orders);

View File

@@ -1,7 +1,6 @@
import arrayReduce from './_arrayReduce.js'; import arrayReduce from './_arrayReduce.js';
import baseEach from './_baseEach.js'; import baseEach from './_baseEach.js';
import baseReduce from './_baseReduce.js'; import baseReduce from './_baseReduce.js';
import isArray from './isArray.js';
/** /**
* Reduces `collection` to a value which is the accumulated result of running * Reduces `collection` to a value which is the accumulated result of running
@@ -40,7 +39,7 @@ import isArray from './isArray.js';
* // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
*/ */
function reduce(collection, iteratee, accumulator) { function reduce(collection, iteratee, accumulator) {
const func = isArray(collection) ? arrayReduce : baseReduce; const func = Array.isArray(collection) ? arrayReduce : baseReduce;
const initAccum = arguments.length < 3; const initAccum = arguments.length < 3;
return func(collection, iteratee, accumulator, initAccum, baseEach); return func(collection, iteratee, accumulator, initAccum, baseEach);
} }

View File

@@ -1,7 +1,6 @@
import arrayReduceRight from './_arrayReduceRight.js'; import arrayReduceRight from './_arrayReduceRight.js';
import baseEachRight from './_baseEachRight.js'; import baseEachRight from './_baseEachRight.js';
import baseReduce from './_baseReduce.js'; import baseReduce from './_baseReduce.js';
import isArray from './isArray.js';
/** /**
* This method is like `reduce` except that it iterates over elements of * This method is like `reduce` except that it iterates over elements of
@@ -25,7 +24,7 @@ import isArray from './isArray.js';
* // => [4, 5, 2, 3, 0, 1] * // => [4, 5, 2, 3, 0, 1]
*/ */
function reduceRight(collection, iteratee, accumulator) { function reduceRight(collection, iteratee, accumulator) {
const func = isArray(collection) ? arrayReduceRight : baseReduce; const func = Array.isArray(collection) ? arrayReduceRight : baseReduce;
const initAccum = arguments.length < 3; const initAccum = arguments.length < 3;
return func(collection, iteratee, accumulator, initAccum, baseEachRight); return func(collection, iteratee, accumulator, initAccum, baseEachRight);
} }

View File

@@ -1,6 +1,5 @@
import arrayFilter from './_arrayFilter.js'; import arrayFilter from './_arrayFilter.js';
import baseFilter from './_baseFilter.js'; import baseFilter from './_baseFilter.js';
import isArray from './isArray.js';
import negate from './negate.js'; import negate from './negate.js';
/** /**
@@ -25,7 +24,7 @@ import negate from './negate.js';
* // => objects for ['fred'] * // => objects for ['fred']
*/ */
function reject(collection, predicate) { function reject(collection, predicate) {
const func = isArray(collection) ? arrayFilter : baseFilter; const func = Array.isArray(collection) ? arrayFilter : baseFilter;
return func(collection, negate(predicate)); return func(collection, negate(predicate));
} }

View File

@@ -1,6 +1,5 @@
import arraySample from './_arraySample.js'; import arraySample from './_arraySample.js';
import baseSample from './_baseSample.js'; import baseSample from './_baseSample.js';
import isArray from './isArray.js';
/** /**
* Gets a random element from `collection`. * Gets a random element from `collection`.
@@ -16,7 +15,7 @@ import isArray from './isArray.js';
* // => 2 * // => 2
*/ */
function sample(collection) { function sample(collection) {
const func = isArray(collection) ? arraySample : baseSample; const func = Array.isArray(collection) ? arraySample : baseSample;
return func(collection); return func(collection);
} }

View File

@@ -1,6 +1,5 @@
import arraySampleSize from './_arraySampleSize.js'; import arraySampleSize from './_arraySampleSize.js';
import baseSampleSize from './_baseSampleSize.js'; import baseSampleSize from './_baseSampleSize.js';
import isArray from './isArray.js';
import isIterateeCall from './_isIterateeCall.js'; import isIterateeCall from './_isIterateeCall.js';
import toInteger from './toInteger.js'; import toInteger from './toInteger.js';
@@ -29,7 +28,7 @@ function sampleSize(collection, n, guard) {
} else { } else {
n = toInteger(n); n = toInteger(n);
} }
const func = isArray(collection) ? arraySampleSize : baseSampleSize; const func = Array.isArray(collection) ? arraySampleSize : baseSampleSize;
return func(collection, n); return func(collection, n);
} }

View File

@@ -1,6 +1,5 @@
import arrayShuffle from './_arrayShuffle.js'; import arrayShuffle from './_arrayShuffle.js';
import baseShuffle from './_baseShuffle.js'; import baseShuffle from './_baseShuffle.js';
import isArray from './isArray.js';
/** /**
* Creates an array of shuffled values, using a version of the * Creates an array of shuffled values, using a version of the
@@ -17,7 +16,7 @@ import isArray from './isArray.js';
* // => [4, 1, 3, 2] * // => [4, 1, 3, 2]
*/ */
function shuffle(collection) { function shuffle(collection) {
const func = isArray(collection) ? arrayShuffle : baseShuffle; const func = Array.isArray(collection) ? arrayShuffle : baseShuffle;
return func(collection); return func(collection);
} }

View File

@@ -1,6 +1,5 @@
import arraySome from './_arraySome.js'; import arraySome from './_arraySome.js';
import baseSome from './_baseSome.js'; import baseSome from './_baseSome.js';
import isArray from './isArray.js';
import isIterateeCall from './_isIterateeCall.js'; import isIterateeCall from './_isIterateeCall.js';
/** /**
@@ -22,7 +21,7 @@ import isIterateeCall from './_isIterateeCall.js';
* // => true * // => true
*/ */
function some(collection, predicate, guard) { function some(collection, predicate, guard) {
const func = isArray(collection) ? arraySome : baseSome; const func = Array.isArray(collection) ? arraySome : baseSome;
if (guard && isIterateeCall(collection, predicate, guard)) { if (guard && isIterateeCall(collection, predicate, guard)) {
predicate = undefined; predicate = undefined;
} }

View File

@@ -1,6 +1,5 @@
import arrayMap from './_arrayMap.js'; import arrayMap from './_arrayMap.js';
import copyArray from './_copyArray.js'; import copyArray from './_copyArray.js';
import isArray from './isArray.js';
import isSymbol from './isSymbol.js'; import isSymbol from './isSymbol.js';
import stringToPath from './_stringToPath.js'; import stringToPath from './_stringToPath.js';
import toKey from './_toKey.js'; import toKey from './_toKey.js';
@@ -23,7 +22,7 @@ import toString from './toString.js';
* // => ['a', '0', 'b', 'c'] * // => ['a', '0', 'b', 'c']
*/ */
function toPath(value) { function toPath(value) {
if (isArray(value)) { if (Array.isArray(value)) {
return arrayMap(value, toKey); return arrayMap(value, toKey);
} }
return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));

View File

@@ -2,7 +2,6 @@ import arrayEach from './_arrayEach.js';
import baseCreate from './_baseCreate.js'; import baseCreate from './_baseCreate.js';
import baseForOwn from './_baseForOwn.js'; import baseForOwn from './_baseForOwn.js';
import getPrototype from './_getPrototype.js'; import getPrototype from './_getPrototype.js';
import isArray from './isArray.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';
@@ -38,7 +37,7 @@ import isTypedArray from './isTypedArray.js';
* // => { '1': ['a', 'c'], '2': ['b'] } * // => { '1': ['a', 'c'], '2': ['b'] }
*/ */
function transform(object, iteratee, accumulator) { function transform(object, iteratee, accumulator) {
const isArr = isArray(object); const isArr = Array.isArray(object);
const isArrLike = isArr || isBuffer(object) || isTypedArray(object); const isArrLike = isArr || isBuffer(object) || isTypedArray(object);
if (accumulator == null) { if (accumulator == null) {