-
-
Save crittelmeyer/7df1b3fd07ffb66a433bfc9e8c1dc179 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