Skip to content

Instantly share code, notes, and snippets.

@greyaperez
Created March 1, 2016 14:40
Show Gist options
  • Save greyaperez/539ddc87c0c614bf3e63 to your computer and use it in GitHub Desktop.
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.
/**
* 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 <tim.adam.perez@gmail.com>
*/
(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