object-keys-internal.js 708 B

1234567891011121314151617181920
  1. var uncurryThis = require('../internals/function-uncurry-this');
  2. var hasOwn = require('../internals/has-own-property');
  3. var toIndexedObject = require('../internals/to-indexed-object');
  4. var indexOf = require('../internals/array-includes').indexOf;
  5. var hiddenKeys = require('../internals/hidden-keys');
  6. var push = uncurryThis([].push);
  7. module.exports = function (object, names) {
  8. var O = toIndexedObject(object);
  9. var i = 0;
  10. var result = [];
  11. var key;
  12. for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  13. // Don't enum bug & hidden keys
  14. while (names.length > i) if (hasOwn(O, key = names[i++])) {
  15. ~indexOf(result, key) || push(result, key);
  16. }
  17. return result;
  18. };