Use more destructuring.

This commit is contained in:
John-David Dalton
2017-03-12 23:16:34 -07:00
parent ad3236a859
commit c89637e4db
17 changed files with 17 additions and 17 deletions

View File

@@ -9,7 +9,7 @@ import eq from '../eq.js'
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
let length = array.length
let { length } = array
while (length--) {
if (eq(array[length][0], key)) {
return length

View File

@@ -132,7 +132,7 @@ function initCloneByTag(object, tag, cloneFunc, isDeep) {
* @returns {Array} Returns the initialized clone.
*/
function initCloneArray(array) {
const length = array.length
const { length } = array
const result = new array.constructor(length)
// Add properties assigned by `RegExp#exec`.

View File

@@ -22,7 +22,7 @@ function baseDifference(array, values, iteratee, comparator) {
let index = -1
let includes = arrayIncludes
let isCommon = true
const length = array.length
const { length } = array
const result = []
const valuesLength = values.length

View File

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

View File

@@ -13,7 +13,7 @@ import isFlattenable from './isFlattenable.js'
*/
function baseFlatten(array, depth, predicate, isStrict, result) {
let index = -1
const length = array.length
const { length } = array
predicate || (predicate = isFlattenable)
result || (result = [])

View File

@@ -10,7 +10,7 @@
*/
function baseIndexOfWith(array, value, fromIndex, comparator) {
let index = fromIndex - 1
const length = array.length
const { length } = array
while (++index < length) {
if (comparator(array[index], value)) {

View File

@@ -9,7 +9,7 @@ import isIndex from './isIndex.js'
* @returns {*} Returns the nth element of `array`.
*/
function baseNth(array, n) {
const length = array.length
const { length } = array
if (!length) {
return
}

View File

@@ -9,7 +9,7 @@
*/
function baseSlice(array, start, end) {
let index = -1
let length = array.length
let { length } = array
if (start < 0) {
start = -start > length ? 0 : (length + start)

View File

@@ -9,7 +9,7 @@
* @returns {Array} Returns `array`.
*/
function baseSortBy(array, comparer) {
let length = array.length
let { length } = array
array.sort(comparer)
while (length--) {

View File

@@ -13,7 +13,7 @@ function baseSortedUniq(array, iteratee) {
let index = -1
let resIndex = 0
const length = array.length
const { length } = array
const result = []
while (++index < length) {

View File

@@ -9,7 +9,7 @@
function baseSum(array, iteratee) {
let result
let index = -1
const length = array.length
const { length } = array
while (++index < length) {
const current = iteratee(array[index])

View File

@@ -22,7 +22,7 @@ function baseUniq(array, iteratee, comparator) {
let includes = arrayIncludes
let isCommon = true
const length = array.length
const { length } = array
const result = []
let seen = result

View File

@@ -11,7 +11,7 @@ import baseSlice from './baseSlice.js'
* @returns {Array} Returns the slice of `array`.
*/
function baseWhile(array, predicate, isDrop, fromRight) {
const length = array.length
const { length } = array
let index = fromRight ? length : -1
while ((fromRight ? index-- : ++index < length) &&

View File

@@ -10,7 +10,7 @@ import baseSlice from './baseSlice.js'
* @returns {Array} Returns the cast slice.
*/
function castSlice(array, start, end) {
const length = array.length
const { length } = array
end = end === undefined ? length : end
return (!start && end >= length) ? array : baseSlice(array, start, end)
}

View File

@@ -12,7 +12,7 @@ const PLACEHOLDER = '__lodash_placeholder__'
*/
function replaceHolders(array, placeholder) {
let index = -1
const length = array.length
const { length } = array
let resIndex = 0
const result = []

View File

@@ -10,7 +10,7 @@
*/
function strictIndexOf(array, value, fromIndex) {
let index = fromIndex - 1
const length = array.length
const { length } = array
while (++index < length) {
if (array[index] === value) {

View File

@@ -32,7 +32,7 @@ function remove(array, predicate) {
}
let index = -1
const indexes = []
const length = array.length
const { length } = array
while (++index < length) {
const value = array[index]