mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Remove arrayPush in favor of spreading arguments.
This commit is contained in:
@@ -1,20 +0,0 @@
|
|||||||
/**
|
|
||||||
* Appends the elements of `values` to `array`.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Array} array The array to modify.
|
|
||||||
* @param {Array} values The values to append.
|
|
||||||
* @returns {Array} Returns `array`.
|
|
||||||
*/
|
|
||||||
function arrayPush(array, values) {
|
|
||||||
let index = -1
|
|
||||||
const length = values.length
|
|
||||||
const offset = array.length
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
array[offset + index] = values[index]
|
|
||||||
}
|
|
||||||
return array
|
|
||||||
}
|
|
||||||
|
|
||||||
export default arrayPush
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import arrayPush from './arrayPush.js'
|
|
||||||
import isFlattenable from './isFlattenable.js'
|
import isFlattenable from './isFlattenable.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,7 +25,7 @@ function baseFlatten(array, depth, predicate, isStrict, result) {
|
|||||||
// 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)
|
result.push(...value)
|
||||||
}
|
}
|
||||||
} else if (!isStrict) {
|
} else if (!isStrict) {
|
||||||
result[result.length] = value
|
result[result.length] = value
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import arrayPush from './arrayPush.js'
|
|
||||||
import getSymbols from './getSymbols.js'
|
import getSymbols from './getSymbols.js'
|
||||||
import keys from '../keys.js'
|
import keys from '../keys.js'
|
||||||
|
|
||||||
@@ -11,7 +10,10 @@ import keys from '../keys.js'
|
|||||||
*/
|
*/
|
||||||
function getAllKeys(object) {
|
function getAllKeys(object) {
|
||||||
const result = keys(object)
|
const result = keys(object)
|
||||||
return Array.isArray(object) ? result : arrayPush(result, getSymbols(object))
|
if (!Array.isArray(object)) {
|
||||||
|
result.push(...getSymbols(object))
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export default getAllKeys
|
export default getAllKeys
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import arrayPush from './arrayPush.js'
|
|
||||||
import getSymbolsIn from './getSymbolsIn.js'
|
import getSymbolsIn from './getSymbolsIn.js'
|
||||||
import keysIn from '../keysIn.js'
|
import keysIn from '../keysIn.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of own and inherited enumerable property names and
|
* Creates an array of own and inherited enumerable property names and symbols of `object`.
|
||||||
* symbols of `object`.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The object to query.
|
* @param {Object} object The object to query.
|
||||||
@@ -12,7 +10,10 @@ import keysIn from '../keysIn.js'
|
|||||||
*/
|
*/
|
||||||
function getAllKeysIn(object) {
|
function getAllKeysIn(object) {
|
||||||
const result = keysIn(object)
|
const result = keysIn(object)
|
||||||
return Array.isArray(object) ? result : arrayPush(result, getSymbolsIn(object))
|
if (!Array.isArray(object)) {
|
||||||
|
result.push(...getSymbolsIn(object))
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export default getAllKeysIn
|
export default getAllKeysIn
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import arrayPush from './arrayPush.js'
|
|
||||||
import getSymbols from './getSymbols.js'
|
import getSymbols from './getSymbols.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. */
|
||||||
@@ -14,7 +13,7 @@ const nativeGetSymbols = Object.getOwnPropertySymbols
|
|||||||
const getSymbolsIn = !nativeGetSymbols ? () => [] : object => {
|
const getSymbolsIn = !nativeGetSymbols ? () => [] : object => {
|
||||||
const result = []
|
const result = []
|
||||||
while (object) {
|
while (object) {
|
||||||
arrayPush(result, getSymbols(object))
|
result.push(...getSymbols(object))
|
||||||
object = Object.getPrototypeOf(Object(object))
|
object = Object.getPrototypeOf(Object(object))
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user