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

isEmpty.js 595B

123456789101112131415
  1. import isArrayLike from './_isArrayLike.js';
  2. import isArray from './isArray.js';
  3. import isString from './isString.js';
  4. import isArguments from './isArguments.js';
  5. import keys from './keys.js';
  6. // Is a given array, string, or object empty?
  7. // An "empty" object has no enumerable own-properties.
  8. export default 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. }