Remove baseSlice.

This commit is contained in:
John-David Dalton
2017-04-17 21:03:39 -07:00
parent a023f92049
commit e5e8f35c06
11 changed files with 37 additions and 54 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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