| /** |
| * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> |
| * Build: `lodash modularize modern exports="node" -o ./modern/` |
| * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> |
| * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> |
| * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors |
| * Available under MIT license <http://lodash.com/license> |
| */ |
| var forOwn = require('./forOwn'), |
| isFunction = require('./isFunction'); |
| |
| /** `Object#toString` result shortcuts */ |
| var argsClass = '[object Arguments]', |
| arrayClass = '[object Array]', |
| objectClass = '[object Object]', |
| stringClass = '[object String]'; |
| |
| /** Used for native method references */ |
| var objectProto = Object.prototype; |
| |
| /** Used to resolve the internal [[Class]] of values */ |
| var toString = objectProto.toString; |
| |
| /** |
| * Checks if `value` is empty. Arrays, strings, or `arguments` objects with a |
| * length of `0` and objects with no own enumerable properties are considered |
| * "empty". |
| * |
| * @static |
| * @memberOf _ |
| * @category Objects |
| * @param {Array|Object|string} value The value to inspect. |
| * @returns {boolean} Returns `true` if the `value` is empty, else `false`. |
| * @example |
| * |
| * _.isEmpty([1, 2, 3]); |
| * // => false |
| * |
| * _.isEmpty({}); |
| * // => true |
| * |
| * _.isEmpty(''); |
| * // => true |
| */ |
| function isEmpty(value) { |
| var result = true; |
| if (!value) { |
| return result; |
| } |
| var className = toString.call(value), |
| length = value.length; |
| |
| if ((className == arrayClass || className == stringClass || className == argsClass ) || |
| (className == objectClass && typeof length == 'number' && isFunction(value.splice))) { |
| return !length; |
| } |
| forOwn(value, function() { |
| return (result = false); |
| }); |
| return result; |
| } |
| |
| module.exports = isEmpty; |