diff options
Diffstat (limited to 'deps/npm/node_modules/cli-table2/node_modules/lodash/lang/isEmpty.js')
-rw-r--r-- | deps/npm/node_modules/cli-table2/node_modules/lodash/lang/isEmpty.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/deps/npm/node_modules/cli-table2/node_modules/lodash/lang/isEmpty.js b/deps/npm/node_modules/cli-table2/node_modules/lodash/lang/isEmpty.js new file mode 100644 index 0000000000..6b344a0b37 --- /dev/null +++ b/deps/npm/node_modules/cli-table2/node_modules/lodash/lang/isEmpty.js @@ -0,0 +1,47 @@ +var isArguments = require('./isArguments'), + isArray = require('./isArray'), + isArrayLike = require('../internal/isArrayLike'), + isFunction = require('./isFunction'), + isObjectLike = require('../internal/isObjectLike'), + isString = require('./isString'), + keys = require('../object/keys'); + +/** + * Checks if `value` is empty. A value is considered empty unless it's an + * `arguments` object, array, string, or jQuery-like collection with a length + * greater than `0` or an object with own enumerable properties. + * + * @static + * @memberOf _ + * @category Lang + * @param {Array|Object|string} value The value to inspect. + * @returns {boolean} Returns `true` if `value` is empty, else `false`. + * @example + * + * _.isEmpty(null); + * // => true + * + * _.isEmpty(true); + * // => true + * + * _.isEmpty(1); + * // => true + * + * _.isEmpty([1, 2, 3]); + * // => false + * + * _.isEmpty({ 'a': 1 }); + * // => false + */ +function isEmpty(value) { + if (value == null) { + return true; + } + if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) || + (isObjectLike(value) && isFunction(value.splice)))) { + return !value.length; + } + return !keys(value).length; +} + +module.exports = isEmpty; |