Skip to content

Commit

Permalink
common: fix first() function
Browse files Browse the repository at this point in the history
  • Loading branch information
capt-nemo429 committed Jun 23, 2023
1 parent 027fbe2 commit d59dc22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/thick-llamas-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fleet-sdk/common": patch
---

fix `first()` function when the first item is equal to zero.
2 changes: 1 addition & 1 deletion packages/common/src/utils/arrayUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function first<T>(array?: ArrayLike<T> | Uint8Array): T | number | undefi
return;
}

if (!array[0]) {
if (array.length < 1) {
throw Error("Empty array.");
}

Expand Down

0 comments on commit d59dc22

Please sign in to comment.