Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isEmpty function #1

Merged
merged 2 commits into from
Oct 17, 2021
Merged

Add isEmpty function #1

merged 2 commits into from
Oct 17, 2021

Conversation

jonahsnider
Copy link
Contributor

Check whether an array is empty.
Helpful type guard to have since TypeScript array type definitions aren't very safe.

declare function isEmpty(array: readonly unknown[]): array is [];

isEmpty([1, 2, 3]);
//=> false

isEmpty([]);
//=> true

index.ts Show resolved Hide resolved
@sindresorhus sindresorhus changed the title Add isEmpty function Add isEmpty function Oct 16, 2021
@sindresorhus sindresorhus merged commit b0f8c29 into sindresorhus:main Oct 17, 2021
@sindresorhus
Copy link
Owner

Thanks :)

@jonahsnider jonahsnider deleted the feat/is-empty branch October 17, 2021 12:42
@ritikbheda ritikbheda mentioned this pull request Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants