Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

isEmpty.js 624B

1234567891011121314151617
  1. var isArray = require('./isArray.js');
  2. var keys = require('./keys.js');
  3. var _isArrayLike = require('./_isArrayLike.js');
  4. var isArguments = require('./isArguments.js');
  5. var isString = require('./isString.js');
  6. // Is a given array, string, or object empty?
  7. // An "empty" object has no enumerable own-properties.
  8. function isEmpty(obj) {
  9. if (obj == null) return true;
  10. // Skip the more expensive `toString`-based type checks if `obj` has no
  11. // `.length`.
  12. if (_isArrayLike(obj) && (isArray(obj) || isString(obj) || isArguments(obj))) return obj.length === 0;
  13. return keys(obj).length === 0;
  14. }
  15. module.exports = isEmpty;