diff --git a/index.js b/index.js index 22cc66d2..36cca4c7 100644 --- a/index.js +++ b/index.js @@ -2834,8 +2834,8 @@ return function(xs) { if (n < 0) return Nothing; - // Fast path for arrays. - if (Array.isArray (xs)) { + // Fast path for objects supporting `slice`. + if (xs.slice) { // we want to support TypedArrays e.i. buffers return n <= xs.length ? Just (arrayCase (n, xs)) : Nothing; } diff --git a/test/drop.js b/test/drop.js index 06fa6f2c..c68cf8fc 100644 --- a/test/drop.js +++ b/test/drop.js @@ -28,4 +28,7 @@ test ('drop', () => { eq (S.drop (-1) (Cons (1) (Cons (2) (Cons (3) (Nil))))) (S.Nothing); + // eq (S.unchecked.drop (0) (new Uint8Array([10, 20, 30, 40, 50]))) (S.unchecked.Just (new Uint8Array([10, 20, 30, 40, 50]))); + eq (S.unchecked.drop (1) (new Uint8Array([10, 20, 30, 40, 50]))) (S.unchecked.Just (new Uint8Array([20, 30, 40, 50]))); + });