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 |
|
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) {
|
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;
|