main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
823 bytes
|
Line | |
---|
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.