_baseKeysIn.js 870 B

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