Last active
February 28, 2024 16:36
-
-
Save inPhoenix/45a9f9e2568126d206f1125caebcd122 to your computer and use it in GitHub Desktop.
Alternative to lodash _.isEmpty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isEmpty = value => { | |
return ( | |
value == null || // From standard.js: Always use === - but obj == null is allowed to check null || undefined | |
(typeof value === 'object' && Object.keys(value).length === 0) || | |
(typeof value === 'string' && value.trim().length === 0) | |
) | |
} | |
export default isEmpty |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice..