Created
March 1, 2016 14:40
-
-
Save greyaperez/539ddc87c0c614bf3e63 to your computer and use it in GitHub Desktop.
lodash mixin: _.isSet() - Checks whether a value is undefined, null, empty string, empty array, or empty object.
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
/** | |
* Lodash Mixin Util: isSet | |
* @description Returns flag whether value is - undefined null, empty string, empty array, or empty object | |
* @param {*} val - Value to Check | |
* @author Timothy A. Perez <[email protected]> | |
*/ | |
(function () { | |
function isSet(val) { | |
return (! ((_.isUndefined(val) || val === null) || (_.isArray(val) && val.length === 0) || (_.isObject(val) && _.isEmpty(val)) || (_.isString(val) && val === '')) ); | |
} | |
_.mixin({'isSet': isSet}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment