size.js 263 B

123456789101112
  1. define(['./_isArrayLike', './keys'], function (_isArrayLike, keys) {
  2. // Return the number of elements in a collection.
  3. function size(obj) {
  4. if (obj == null) return 0;
  5. return _isArrayLike(obj) ? obj.length : keys(obj).length;
  6. }
  7. return size;
  8. });