Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions test/drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])));

});