From a2747883e77f1d7bda64e93337d5ec76bf21c790 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 6 Sep 2015 16:39:23 +0900 Subject: [PATCH] Update `is-arguments` implementation; don't call down legacy code path in modern engines. --- es6-shim.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/es6-shim.js b/es6-shim.js index 339ac336..36c269bf 100644 --- a/es6-shim.js +++ b/es6-shim.js @@ -292,19 +292,18 @@ // taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js // can be replaced with require('is-arguments') if we ever use a build process instead - var isArguments = function isArguments(value) { - var str = _toString(value); - var result = str === '[object Arguments]'; - if (!result) { - result = str !== '[object Array]' && - value !== null && - typeof value === 'object' && - typeof value.length === 'number' && - value.length >= 0 && - _toString(value.callee) === '[object Function]'; - } - return result; + var isStandardArguments = function isArguments(value) { + return _toString(value) === '[object Arguments]'; + }; + var isLegacyArguments = function isArguments(value) { + return value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + _toString(vaue) !== '[object Array]' && + _toString(value.callee) === '[object Function]'; }; + var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments; var ES = { // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args