Skip to content

Commit

Permalink
Update is-arguments implementation; don't call down legacy code pat…
Browse files Browse the repository at this point in the history
…h in modern engines.
  • Loading branch information
ljharb committed Sep 6, 2015
1 parent e8d7e65 commit a274788
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions es6-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a274788

Please sign in to comment.