Projekt

Obecné

Profil

Stáhnout (823 Bajtů) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
'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;