_baseKeysIn.js 988 B

123456789101112131415161718192021222324252627282930313233343536
  1. import Reflect from './_Reflect';
  2. import iteratorToArray from './_iteratorToArray';
  3. /** Used for built-in method references. */
  4. var objectProto = Object.prototype;
  5. /** Built-in value references. */
  6. var enumerate = Reflect ? Reflect.enumerate : undefined,
  7. propertyIsEnumerable = objectProto.propertyIsEnumerable;
  8. /**
  9. * The base implementation of `_.keysIn` which doesn't skip the constructor
  10. * property of prototypes or treat sparse arrays as dense.
  11. *
  12. * @private
  13. * @param {Object} object The object to query.
  14. * @returns {Array} Returns the array of property names.
  15. */
  16. function baseKeysIn(object) {
  17. object = object == null ? object : Object(object);
  18. var result = [];
  19. for (var key in object) {
  20. result.push(key);
  21. }
  22. return result;
  23. }
  24. // Fallback for IE < 9 with es6-shim.
  25. if (enumerate && !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf')) {
  26. baseKeysIn = function(object) {
  27. return iteratorToArray(enumerate(object));
  28. };
  29. }
  30. export default baseKeysIn;