You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
776 B

пре 4 година
  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;