| /** |
| * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> |
| * Build: `lodash modularize underscore exports="node" -o ./underscore/` |
| * 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 isArray = require('./isArray'), |
| isString = require('./isString'); |
| |
| /** Used for native method references */ |
| var objectProto = Object.prototype; |
| |
| /** Native method shortcuts */ |
| var hasOwnProperty = objectProto.hasOwnProperty; |
| |
| /** |
| * 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) { |
| if (!value) { |
| return true; |
| } |
| if (isArray(value) || isString(value)) { |
| return !value.length; |
| } |
| for (var key in value) { |
| if (hasOwnProperty.call(value, key)) { |
| return false; |
| } |
| } |
| return true; |
| } |
| |
| module.exports = isEmpty; |