mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Remove baseSlice.
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* The base implementation of `slice`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to slice.
|
||||
* @param {number} [start=0] The start position.
|
||||
* @param {number} [end=array.length] The end position.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
*/
|
||||
function baseSlice(array, start, end) {
|
||||
let index = -1
|
||||
let { length } = array
|
||||
|
||||
if (start < 0) {
|
||||
start = -start > length ? 0 : (length + start)
|
||||
}
|
||||
end = end > length ? length : end
|
||||
if (end < 0) {
|
||||
end += length
|
||||
}
|
||||
length = start > end ? 0 : ((end - start) >>> 0)
|
||||
start >>>= 0
|
||||
|
||||
const result = new Array(length)
|
||||
while (++index < length) {
|
||||
result[index] = array[index + start]
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export default baseSlice
|
||||
@@ -1,4 +1,4 @@
|
||||
import baseSlice from './baseSlice.js'
|
||||
import slice from '../slice.js'
|
||||
|
||||
/**
|
||||
* The base implementation of methods like `dropWhile` and `takeWhile`.
|
||||
@@ -18,8 +18,8 @@ function baseWhile(array, predicate, isDrop, fromRight) {
|
||||
predicate(array[index], index, array)) {}
|
||||
|
||||
return isDrop
|
||||
? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
|
||||
: baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index))
|
||||
? slice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
|
||||
: slice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index))
|
||||
}
|
||||
|
||||
export default baseWhile
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import baseSlice from './baseSlice.js'
|
||||
import slice from '../slice.js'
|
||||
|
||||
/**
|
||||
* Casts `array` to a slice if it's needed.
|
||||
@@ -12,7 +12,7 @@ import baseSlice from './baseSlice.js'
|
||||
function castSlice(array, start, end) {
|
||||
const { length } = array
|
||||
end = end === undefined ? length : end
|
||||
return (!start && end >= length) ? array : baseSlice(array, start, end)
|
||||
return (!start && end >= length) ? array : slice(array, start, end)
|
||||
}
|
||||
|
||||
export default castSlice
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import baseGet from './baseGet.js'
|
||||
import baseSlice from './baseSlice.js'
|
||||
import slice from '../slice.js'
|
||||
|
||||
/**
|
||||
* Gets the parent value at `path` of `object`.
|
||||
@@ -10,7 +10,7 @@ import baseSlice from './baseSlice.js'
|
||||
* @returns {*} Returns the parent value.
|
||||
*/
|
||||
function parent(object, path) {
|
||||
return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1))
|
||||
return path.length < 2 ? object : baseGet(object, slice(path, 0, -1))
|
||||
}
|
||||
|
||||
export default parent
|
||||
|
||||
Reference in New Issue
Block a user