From 4b80666a309a6bb16833181111536faaabe49bc3 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 24 Mar 2017 08:18:16 -0700 Subject: [PATCH] Simplify `tail`. --- tail.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tail.js b/tail.js index 4a778fb32..f867a2759 100644 --- a/tail.js +++ b/tail.js @@ -1,5 +1,3 @@ -import baseSlice from './.internal/baseSlice.js' - /** * Gets all but the first element of `array`. * @@ -14,7 +12,11 @@ import baseSlice from './.internal/baseSlice.js' */ function tail(array) { 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