Last active
February 4, 2022 07:49
-
-
Save learntheropes/e4d33ad5892aaec80d450fcdb729b657 to your computer and use it in GitHub Desktop.
isEmpty and isFinite functions
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
function isEmpty(value){ | |
return value === undefined || | |
value === null || | |
(typeof value === "object" && Object.keys(value).length === 0) || | |
(typeof value === "string" && value.trim().length === 0) | |
} | |
module.exports = 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
function isFinite(value) { | |
return typeof value == 'number' && (isNaN(value) || | |
value == Number.POSITIVE_INFINITY || | |
value == Number.NEGATIVE_INFINITY); | |
} | |
module.exports = isFinite; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment