Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / lang / isEmpty.js
1 var isArguments = require('./isArguments'),
2     isArray = require('./isArray'),
3     isArrayLike = require('../internal/isArrayLike'),
4     isFunction = require('./isFunction'),
5     isObjectLike = require('../internal/isObjectLike'),
6     isString = require('./isString'),
7     keys = require('../object/keys');
8
9 /**
10  * Checks if `value` is empty. A value is considered empty unless it's an
11  * `arguments` object, array, string, or jQuery-like collection with a length
12  * greater than `0` or an object with own enumerable properties.
13  *
14  * @static
15  * @memberOf _
16  * @category Lang
17  * @param {Array|Object|string} value The value to inspect.
18  * @returns {boolean} Returns `true` if `value` is empty, else `false`.
19  * @example
20  *
21  * _.isEmpty(null);
22  * // => true
23  *
24  * _.isEmpty(true);
25  * // => true
26  *
27  * _.isEmpty(1);
28  * // => true
29  *
30  * _.isEmpty([1, 2, 3]);
31  * // => false
32  *
33  * _.isEmpty({ 'a': 1 });
34  * // => false
35  */
36 function isEmpty(value) {
37   if (value == null) {
38     return true;
39   }
40   if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) ||
41       (isObjectLike(value) && isFunction(value.splice)))) {
42     return !value.length;
43   }
44   return !keys(value).length;
45 }
46
47 module.exports = isEmpty;