Skip to content

Commit

Permalink
feat: add isNonEmptyArray
Browse files Browse the repository at this point in the history
  • Loading branch information
chouchouji committed Oct 27, 2024
1 parent 2fc649b commit 6fcf91d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,3 @@ export function sum(arr: number[]) {
export function sumBy<T>(arr: T[], fn: (val: T) => number) {
return arr.reduce((ret, val) => ret + fn(val), 0)
}

export function isNonEmptyArray(val: unknown): boolean {
return isArray(val) && !!val.length
}
4 changes: 4 additions & 0 deletions src/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@ export function getGlobalThis() {

return typeof global !== 'undefined' ? global : self
}

export function isNonEmptyArray(val: unknown): val is Array<any> {
return isArray(val) && !!val.length
}

0 comments on commit 6fcf91d

Please sign in to comment.