Skip to content

Commit

Permalink
feat: πŸ”₯ return empty array if length is 0
Browse files Browse the repository at this point in the history
βœ… Closes: #220
  • Loading branch information
Ryan Smee committed Apr 19, 2022
1 parent 67c4f5f commit 2b84b1a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/falso/src/lib/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export function fake<T, Options extends FakeOptions>(
comparisonFunction: (item: T, items: T[]) => boolean = primitiveValueIsUnique,
comparisonKeys?: string[]
): Return<T, Options> {
if (options?.length === 0) {
return [] as any;
}

if (Array.isArray(data)) {
return fakeFromArray(data, options) as any;
}
Expand Down

0 comments on commit 2b84b1a

Please sign in to comment.