Skip to content

Commit

Permalink
Belt.Array.slice => Js.Array2.slice
Browse files Browse the repository at this point in the history
  • Loading branch information
namenu committed Feb 21, 2021
1 parent 7b2a2c8 commit eb63a1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions __tests__/Array_test.re
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
open Garter.Array;
open Garter.Fn;

assert(take([|1, 2, 3, 4, 5|], -1) == [||]);
assert(take([|1, 2, 3, 4, 5|], 2) == [|1, 2|]);
assert(take([|1, 2, 3, 4, 5|], 7) == [|1, 2, 3, 4, 5|]);
assert(drop([|1, 2, 3, 4, 5|], -1) == [|1, 2, 3, 4, 5|]);
assert(drop([|1, 2, 3, 4, 5|], 2) == [|3, 4, 5|]);
assert(drop([|1, 2, 3, 4, 5|], 7) == [||]);

assert(takeWhile([|1, 2, 3, 4, 5|], x => x <= 2) == [|1, 2|]);
assert(takeWhile([|1, 2, 3, 4, 5|], constantly(false)) == [||]);
assert(dropWhile([|1, 2, 3, 4, 5|], x => x <= 2) == [|3, 4, 5|]);
Expand Down
4 changes: 2 additions & 2 deletions src/Garter_Array.re
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let take = (ar, n) => {
} else {
n;
};
slice(ar, ~offset=0, ~len);
Js.Array2.slice(ar, ~start=0, ~end_=len);
};

let takeWhileU = (ar, pred) => {
Expand All @@ -45,7 +45,7 @@ let drop = (ar, n) => {
} else {
n;
};
sliceToEnd(ar, offset);
Js.Array2.sliceFrom(ar, offset);
};

let dropWhileU = (ar, pred) => {
Expand Down

0 comments on commit eb63a1e

Please sign in to comment.