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