Skip to content

Instantly share code, notes, and snippets.

@learntheropes
Last active February 4, 2022 07:49
Show Gist options
  • Save learntheropes/e4d33ad5892aaec80d450fcdb729b657 to your computer and use it in GitHub Desktop.
Save learntheropes/e4d33ad5892aaec80d450fcdb729b657 to your computer and use it in GitHub Desktop.
isEmpty and isFinite functions
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;
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