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