Skip to content

Commit

Permalink
Make just-zip-it and just-split types accept readonly arrays (#470)
Browse files Browse the repository at this point in the history
* feat: make just-group-by types accept readonly arrays

* feat: make just-split types accept readonly array

* test: add test for just-group-by

* test: add test for just-split

Co-authored-by: angus croll <[email protected]>
  • Loading branch information
zomysan and angus-c authored Jul 18, 2022
1 parent fc0ef7a commit 74ee4b3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/array-split/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default function split<T>(arr: T[], n?: number | null): Array<T[]>
export default function split<T>(arr: readonly T[], n?: number | null): Array<T[]>
1 change: 1 addition & 0 deletions packages/array-split/index.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ split([1, 2, 3, 4, 5], null); // [[1, 2, 3, 4, 5]]
split([1, 2, 3, 4, 5, 6, 7, 8, 9], 3); // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
split(['a', 'b', 'c', 'd', 'e'], 2); // [['a', 'b'], ['c', 'd'], ['e']]
split([1, 2, 3, 4, 5, 6, 7, 8], 3); // [[1, 2, 3], [4, 5, 6], [7, 8]]
split([1, 2, 3, 4, 5, 6, 7, 8] as const, 3); // [[1, 2, 3], [4, 5, 6], [7, 8]]

// return types should match input type
const numberArray = split([1, 2, 3, 4, 5]); // [[1, 2, 3, 4, 5]]
Expand Down

0 comments on commit 74ee4b3

Please sign in to comment.