_indexKeys.js 722 B

123456789101112131415161718192021222324
  1. var baseTimes = require('./_baseTimes'),
  2. isArguments = require('./isArguments'),
  3. isArray = require('./isArray'),
  4. isLength = require('./isLength'),
  5. isString = require('./isString');
  6. /**
  7. * Creates an array of index keys for `object` values of arrays,
  8. * `arguments` objects, and strings, otherwise `null` is returned.
  9. *
  10. * @private
  11. * @param {Object} object The object to query.
  12. * @returns {Array|null} Returns index keys, else `null`.
  13. */
  14. function indexKeys(object) {
  15. var length = object ? object.length : undefined;
  16. if (isLength(length) &&
  17. (isArray(object) || isString(object) || isArguments(object))) {
  18. return baseTimes(length, String);
  19. }
  20. return null;
  21. }
  22. module.exports = indexKeys;