Skip to content

Commit a274788

Browse files
committed
Update is-arguments implementation; don't call down legacy code path in modern engines.
1 parent e8d7e65 commit a274788

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

es6-shim.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -292,19 +292,18 @@
292292

293293
// taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js
294294
// can be replaced with require('is-arguments') if we ever use a build process instead
295-
var isArguments = function isArguments(value) {
296-
var str = _toString(value);
297-
var result = str === '[object Arguments]';
298-
if (!result) {
299-
result = str !== '[object Array]' &&
300-
value !== null &&
301-
typeof value === 'object' &&
302-
typeof value.length === 'number' &&
303-
value.length >= 0 &&
304-
_toString(value.callee) === '[object Function]';
305-
}
306-
return result;
295+
var isStandardArguments = function isArguments(value) {
296+
return _toString(value) === '[object Arguments]';
297+
};
298+
var isLegacyArguments = function isArguments(value) {
299+
return value !== null &&
300+
typeof value === 'object' &&
301+
typeof value.length === 'number' &&
302+
value.length >= 0 &&
303+
_toString(vaue) !== '[object Array]' &&
304+
_toString(value.callee) === '[object Function]';
307305
};
306+
var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments;
308307

309308
var ES = {
310309
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args

0 commit comments

Comments
 (0)