size.js 252 B

123456789
  1. import isArrayLike from './_isArrayLike.js';
  2. import keys from './keys.js';
  3. // Return the number of elements in a collection.
  4. export default function size(obj) {
  5. if (obj == null) return 0;
  6. return isArrayLike(obj) ? obj.length : keys(obj).length;
  7. }