Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

_baseKeys.js 776B

123456789101112131415161718192021222324252627282930
  1. var isPrototype = require('./_isPrototype'),
  2. nativeKeys = require('./_nativeKeys');
  3. /** Used for built-in method references. */
  4. var objectProto = Object.prototype;
  5. /** Used to check objects for own properties. */
  6. var hasOwnProperty = objectProto.hasOwnProperty;
  7. /**
  8. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  9. *
  10. * @private
  11. * @param {Object} object The object to query.
  12. * @returns {Array} Returns the array of property names.
  13. */
  14. function baseKeys(object) {
  15. if (!isPrototype(object)) {
  16. return nativeKeys(object);
  17. }
  18. var result = [];
  19. for (var key in Object(object)) {
  20. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  21. result.push(key);
  22. }
  23. }
  24. return result;
  25. }
  26. module.exports = baseKeys;