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.

index.js 823B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. var slice = Array.prototype.slice;
  3. var isArgs = require('./isArguments');
  4. var origKeys = Object.keys;
  5. var keysShim = origKeys ? function keys(o) { return origKeys(o); } : require('./implementation');
  6. var originalKeys = Object.keys;
  7. keysShim.shim = function shimObjectKeys() {
  8. if (Object.keys) {
  9. var keysWorksWithArguments = (function () {
  10. // Safari 5.0 bug
  11. var args = Object.keys(arguments);
  12. return args && args.length === arguments.length;
  13. }(1, 2));
  14. if (!keysWorksWithArguments) {
  15. Object.keys = function keys(object) { // eslint-disable-line func-name-matching
  16. if (isArgs(object)) {
  17. return originalKeys(slice.call(object));
  18. }
  19. return originalKeys(object);
  20. };
  21. }
  22. } else {
  23. Object.keys = keysShim;
  24. }
  25. return Object.keys || keysShim;
  26. };
  27. module.exports = keysShim;