keysIn.js 778 B

123456789101112131415161718192021222324252627282930313233
  1. var arrayLikeKeys = require('./_arrayLikeKeys'),
  2. baseKeysIn = require('./_baseKeysIn'),
  3. isArrayLike = require('./isArrayLike');
  4. /**
  5. * Creates an array of the own and inherited enumerable property names of `object`.
  6. *
  7. * **Note:** Non-object values are coerced to objects.
  8. *
  9. * @static
  10. * @memberOf _
  11. * @since 3.0.0
  12. * @category Object
  13. * @param {Object} object The object to query.
  14. * @returns {Array} Returns the array of property names.
  15. * @example
  16. *
  17. * function Foo() {
  18. * this.a = 1;
  19. * this.b = 2;
  20. * }
  21. *
  22. * Foo.prototype.c = 3;
  23. *
  24. * _.keysIn(new Foo);
  25. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  26. */
  27. function keysIn(object) {
  28. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  29. }
  30. module.exports = keysIn;