Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
823 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var slice = Array.prototype.slice;
|
---|
| 4 | var isArgs = require('./isArguments');
|
---|
| 5 |
|
---|
| 6 | var origKeys = Object.keys;
|
---|
| 7 | var keysShim = origKeys ? function keys(o) { return origKeys(o); } : require('./implementation');
|
---|
| 8 |
|
---|
| 9 | var originalKeys = Object.keys;
|
---|
| 10 |
|
---|
| 11 | keysShim.shim = function shimObjectKeys() {
|
---|
| 12 | if (Object.keys) {
|
---|
| 13 | var keysWorksWithArguments = (function () {
|
---|
| 14 | // Safari 5.0 bug
|
---|
| 15 | var args = Object.keys(arguments);
|
---|
| 16 | return args && args.length === arguments.length;
|
---|
| 17 | }(1, 2));
|
---|
| 18 | if (!keysWorksWithArguments) {
|
---|
| 19 | Object.keys = function keys(object) { // eslint-disable-line func-name-matching
|
---|
| 20 | if (isArgs(object)) {
|
---|
| 21 | return originalKeys(slice.call(object));
|
---|
| 22 | }
|
---|
| 23 | return originalKeys(object);
|
---|
| 24 | };
|
---|
| 25 | }
|
---|
| 26 | } else {
|
---|
| 27 | Object.keys = keysShim;
|
---|
| 28 | }
|
---|
| 29 | return Object.keys || keysShim;
|
---|
| 30 | };
|
---|
| 31 |
|
---|
| 32 | module.exports = keysShim;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.