Simplify tail.

This commit is contained in:
John-David Dalton
2017-03-24 08:18:16 -07:00
parent ecb3c108d1
commit 4b80666a30

View File

@@ -1,5 +1,3 @@
import baseSlice from './.internal/baseSlice.js'
/** /**
* Gets all but the first element of `array`. * Gets all but the first element of `array`.
* *
@@ -14,7 +12,11 @@ import baseSlice from './.internal/baseSlice.js'
*/ */
function tail(array) { function tail(array) {
const length = array == null ? 0 : array.length const length = array == null ? 0 : array.length
return length ? baseSlice(array, 1, length) : [] if (!length) {
return []
}
const [head, ...result] = array
return result
} }
export default tail export default tail