mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Remove baseTimes.
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
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'
|
||||||
@@ -21,9 +20,12 @@ function arrayLikeKeys(value, inherited) {
|
|||||||
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 length = value.length
|
||||||
const length = result.length
|
const result = new Array(skipIndexes ? length : 0)
|
||||||
|
let index = skipIndexes ? -1 : length
|
||||||
|
while (++index < length) {
|
||||||
|
result[index] = `${ index }`
|
||||||
|
}
|
||||||
for (const key in value) {
|
for (const key in value) {
|
||||||
if ((inherited || hasOwnProperty.call(value, key)) &&
|
if ((inherited || hasOwnProperty.call(value, key)) &&
|
||||||
!(skipIndexes && (
|
!(skipIndexes && (
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
* The base implementation of `times` without support for max array length checks.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {number} n The number of times to invoke `iteratee`.
|
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
|
||||||
* @returns {Array} Returns the array of results.
|
|
||||||
*/
|
|
||||||
function baseTimes(n, iteratee) {
|
|
||||||
let index = -1
|
|
||||||
const result = Array(n)
|
|
||||||
|
|
||||||
while (++index < n) {
|
|
||||||
result[index] = iteratee(index)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
export default baseTimes
|
|
||||||
15
times.js
15
times.js
@@ -1,4 +1,3 @@
|
|||||||
import baseTimes from './.internal/baseTimes.js'
|
|
||||||
import toInteger from './toInteger.js'
|
import toInteger from './toInteger.js'
|
||||||
|
|
||||||
/** Used as references for various `Number` constants. */
|
/** Used as references for various `Number` constants. */
|
||||||
@@ -7,9 +6,6 @@ const MAX_SAFE_INTEGER = 9007199254740991
|
|||||||
/** 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
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
||||||
const nativeMin = Math.min
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invokes the iteratee `n` times, returning an array of the results of
|
* Invokes the iteratee `n` times, returning an array of the results of
|
||||||
* each invocation. The iteratee is invoked with one argumentindex).
|
* each invocation. The iteratee is invoked with one argumentindex).
|
||||||
@@ -32,10 +28,13 @@ function times(n, iteratee) {
|
|||||||
if (n < 1 || n > MAX_SAFE_INTEGER) {
|
if (n < 1 || n > MAX_SAFE_INTEGER) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
let index = MAX_ARRAY_LENGTH
|
let index = -1
|
||||||
const length = nativeMin(n, MAX_ARRAY_LENGTH)
|
const length = Math.min(n, MAX_ARRAY_LENGTH)
|
||||||
const result = baseTimes(length, iteratee)
|
const result = Array(length)
|
||||||
|
while (++index < length) {
|
||||||
|
result[index] = iteratee(index)
|
||||||
|
}
|
||||||
|
index = MAX_ARRAY_LENGTH
|
||||||
n -= MAX_ARRAY_LENGTH
|
n -= MAX_ARRAY_LENGTH
|
||||||
while (++index < n) {
|
while (++index < n) {
|
||||||
iteratee(index)
|
iteratee(index)
|
||||||
|
|||||||
8
unzip.js
8
unzip.js
@@ -1,7 +1,6 @@
|
|||||||
import arrayFilter from './.internal/arrayFilter.js'
|
import arrayFilter from './.internal/arrayFilter.js'
|
||||||
import arrayMap from './.internal/arrayMap.js'
|
import arrayMap from './.internal/arrayMap.js'
|
||||||
import baseProperty from './.internal/baseProperty.js'
|
import baseProperty from './.internal/baseProperty.js'
|
||||||
import baseTimes from './.internal/baseTimes.js'
|
|
||||||
import isArrayLikeObject from './isArrayLikeObject.js'
|
import isArrayLikeObject from './isArrayLikeObject.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. */
|
||||||
@@ -36,7 +35,12 @@ function unzip(array) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return baseTimes(length, (index) => arrayMap(array, baseProperty(index)))
|
let index = -1
|
||||||
|
const result = new Array(length)
|
||||||
|
while (++index < length) {
|
||||||
|
result[index] = arrayMap(array, baseProperty(index))
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export default unzip
|
export default unzip
|
||||||
|
|||||||
Reference in New Issue
Block a user