Skip to content

Commit

Permalink
remove arguments shortcuts - old webkit bug, close #150
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 17, 2015
1 parent 5d2a566 commit 059446f
Show file tree
Hide file tree
Showing 26 changed files with 84 additions and 110 deletions.
3 changes: 1 addition & 2 deletions library/modules/_array-copy-within.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ module.exports = [].copyWithin || function copyWithin(target/*= 0*/, start/*= 0,
, len = toLength(O.length)
, to = toIndex(target, len)
, from = toIndex(start, len)
, $$ = arguments
, end = $$.length > 2 ? $$[2] : undefined
, end = arguments.length > 2 ? arguments[2] : undefined
, count = Math.min((end === undefined ? len : toIndex(end, len)) - from, len - to)
, inc = 1;
if(from < to && to < from + count){
Expand Down
7 changes: 3 additions & 4 deletions library/modules/_array-fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ var toObject = require('./_to-object')
module.exports = function fill(value /*, start = 0, end = @length */){
var O = toObject(this)
, length = toLength(O.length)
, $$ = arguments
, $$len = $$.length
, index = toIndex($$len > 1 ? $$[1] : undefined, length)
, end = $$len > 2 ? $$[2] : undefined
, aLen = arguments.length
, index = toIndex(aLen > 1 ? arguments[1] : undefined, length)
, end = aLen > 2 ? arguments[2] : undefined
, endPos = end === undefined ? length : toIndex(end, length);
while(endPos > index)O[index++] = value;
return O;
Expand Down
7 changes: 3 additions & 4 deletions library/modules/_object-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ module.exports = require('./_fails')(function(){
return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K;
}) ? function assign(target, source){ // eslint-disable-line no-unused-vars
var T = toObject(target)
, $$ = arguments
, $$len = $$.length
, aLen = arguments.length
, index = 1
, getKeys = $.getKeys
, getSymbols = $.getSymbols
, isEnum = $.isEnum;
while($$len > index){
var S = IObject($$[index++])
while(aLen > index){
var S = IObject(arguments[index++])
, keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S)
, length = keys.length
, j = 0
Expand Down
11 changes: 5 additions & 6 deletions library/modules/_partial.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ module.exports = function(/* ...pargs */){
, holder = false;
while(length > i)if((pargs[i] = arguments[i++]) === _)holder = true;
return function(/* ...args */){
var that = this
, $$ = arguments
, $$len = $$.length
var that = this
, aLen = arguments.length
, j = 0, k = 0, args;
if(!holder && !$$len)return invoke(fn, pargs, that);
if(!holder && !aLen)return invoke(fn, pargs, that);
args = pargs.slice();
if(holder)for(;length > j; j++)if(args[j] === _)args[j] = $$[k++];
while($$len > k)args.push($$[k++]);
if(holder)for(;length > j; j++)if(args[j] === _)args[j] = arguments[k++];
while(aLen > k)args.push(arguments[k++]);
return invoke(fn, args, that);
};
};
7 changes: 3 additions & 4 deletions library/modules/_typed-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ if(require('./_descriptors')){

var $from = function from(source /*, mapfn, thisArg */){
var O = toObject(source)
, $$ = arguments
, $$len = $$.length
, mapfn = $$len > 1 ? $$[1] : undefined
, aLen = arguments.length
, mapfn = aLen > 1 ? arguments[1] : undefined
, mapping = mapfn !== undefined
, iterFn = getIterFn(O)
, i, length, values, result, step, iterator;
Expand All @@ -139,7 +138,7 @@ if(require('./_descriptors')){
values.push(step.value);
} O = values;
}
if(mapping && $$len > 2)mapfn = ctx(mapfn, $$[2], 2);
if(mapping && aLen > 2)mapfn = ctx(mapfn, arguments[2], 2);
for(i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++){
result[i] = mapping ? mapfn(O[i], i) : O[i];
}
Expand Down
7 changes: 3 additions & 4 deletions library/modules/es6.array.from.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ $export($export.S + $export.F * !require('./_iter-detect')(function(iter){ Array
from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
var O = toObject(arrayLike)
, C = typeof this == 'function' ? this : Array
, $$ = arguments
, $$len = $$.length
, mapfn = $$len > 1 ? $$[1] : undefined
, aLen = arguments.length
, mapfn = aLen > 1 ? arguments[1] : undefined
, mapping = mapfn !== undefined
, index = 0
, iterFn = getIterFn(O)
, length, result, step, iterator;
if(mapping)mapfn = ctx(mapfn, $$len > 2 ? $$[2] : undefined, 2);
if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
// if object isn't iterable or it's array with default iterator - use simple case
if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){
for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){
Expand Down
9 changes: 4 additions & 5 deletions library/modules/es6.array.of.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ $export($export.S + $export.F * require('./_fails')(function(){
// 22.1.2.3 Array.of( ...items)
of: function of(/* ...args */){
var index = 0
, $$ = arguments
, $$len = $$.length
, result = new (typeof this == 'function' ? this : Array)($$len);
while($$len > index)result[index] = $$[index++];
result.length = $$len;
, aLen = arguments.length
, result = new (typeof this == 'function' ? this : Array)(aLen);
while(aLen > index)result[index] = arguments[index++];
result.length = aLen;
return result;
}
});
13 changes: 6 additions & 7 deletions library/modules/es6.math.hypot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ var $export = require('./_export')

$export($export.S, 'Math', {
hypot: function hypot(value1, value2){ // eslint-disable-line no-unused-vars
var sum = 0
, i = 0
, $$ = arguments
, $$len = $$.length
, larg = 0
var sum = 0
, i = 0
, aLen = arguments.length
, larg = 0
, arg, div;
while(i < $$len){
arg = abs($$[i++]);
while(i < aLen){
arg = abs(arguments[i++]);
if(larg < arg){
div = larg / arg;
sum = sum * div * div + 1;
Expand Down
3 changes: 1 addition & 2 deletions library/modules/es6.string.ends-with.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ var $export = require('./_export')
$export($export.P + $export.F * require('./_fails-is-regexp')(ENDS_WITH), 'String', {
endsWith: function endsWith(searchString /*, endPosition = @length */){
var that = context(this, searchString, ENDS_WITH)
, $$ = arguments
, endPosition = $$.length > 1 ? $$[1] : undefined
, endPosition = arguments.length > 1 ? arguments[1] : undefined
, len = toLength(that.length)
, end = endPosition === undefined ? len : Math.min(toLength(endPosition), len)
, search = String(searchString);
Expand Down
11 changes: 5 additions & 6 deletions library/modules/es6.string.from-code-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ var $export = require('./_export')
$export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
// 21.1.2.2 String.fromCodePoint(...codePoints)
fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars
var res = []
, $$ = arguments
, $$len = $$.length
, i = 0
var res = []
, aLen = arguments.length
, i = 0
, code;
while($$len > i){
code = +$$[i++];
while(aLen > i){
code = +arguments[i++];
if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point');
res.push(code < 0x10000
? fromCharCode(code)
Expand Down
13 changes: 6 additions & 7 deletions library/modules/es6.string.raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ var $export = require('./_export')
$export($export.S, 'String', {
// 21.1.2.4 String.raw(callSite, ...substitutions)
raw: function raw(callSite){
var tpl = toIObject(callSite.raw)
, len = toLength(tpl.length)
, $$ = arguments
, $$len = $$.length
, res = []
, i = 0;
var tpl = toIObject(callSite.raw)
, len = toLength(tpl.length)
, aLen = arguments.length
, res = []
, i = 0;
while(len > i){
res.push(String(tpl[i++]));
if(i < $$len)res.push(String($$[i]));
if(i < aLen)res.push(String(arguments[i]));
} return res.join('');
}
});
3 changes: 1 addition & 2 deletions library/modules/es6.string.starts-with.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ var $export = require('./_export')
$export($export.P + $export.F * require('./_fails-is-regexp')(STARTS_WITH), 'String', {
startsWith: function startsWith(searchString /*, position = 0 */){
var that = context(this, searchString, STARTS_WITH)
, $$ = arguments
, index = toLength(Math.min($$.length > 1 ? $$[1] : undefined, that.length))
, index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length))
, search = String(searchString);
return $startsWith
? $startsWith.call(that, search, index)
Expand Down
3 changes: 1 addition & 2 deletions library/modules/es6.symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ var $stringify = function stringify(it){
if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined
var args = [it]
, i = 1
, $$ = arguments
, replacer, $replacer;
while($$.length > i)args.push($$[i++]);
while(arguments.length > i)args.push(arguments[i++]);
replacer = args[1];
if(typeof replacer == 'function')$replacer = replacer;
if($replacer || !isArray(replacer))replacer = function(key, value){
Expand Down
3 changes: 1 addition & 2 deletions modules/_array-copy-within.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ module.exports = [].copyWithin || function copyWithin(target/*= 0*/, start/*= 0,
, len = toLength(O.length)
, to = toIndex(target, len)
, from = toIndex(start, len)
, $$ = arguments
, end = $$.length > 2 ? $$[2] : undefined
, end = arguments.length > 2 ? arguments[2] : undefined
, count = Math.min((end === undefined ? len : toIndex(end, len)) - from, len - to)
, inc = 1;
if(from < to && to < from + count){
Expand Down
7 changes: 3 additions & 4 deletions modules/_array-fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ var toObject = require('./_to-object')
module.exports = function fill(value /*, start = 0, end = @length */){
var O = toObject(this)
, length = toLength(O.length)
, $$ = arguments
, $$len = $$.length
, index = toIndex($$len > 1 ? $$[1] : undefined, length)
, end = $$len > 2 ? $$[2] : undefined
, aLen = arguments.length
, index = toIndex(aLen > 1 ? arguments[1] : undefined, length)
, end = aLen > 2 ? arguments[2] : undefined
, endPos = end === undefined ? length : toIndex(end, length);
while(endPos > index)O[index++] = value;
return O;
Expand Down
7 changes: 3 additions & 4 deletions modules/_object-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ module.exports = require('./_fails')(function(){
return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K;
}) ? function assign(target, source){ // eslint-disable-line no-unused-vars
var T = toObject(target)
, $$ = arguments
, $$len = $$.length
, aLen = arguments.length
, index = 1
, getKeys = $.getKeys
, getSymbols = $.getSymbols
, isEnum = $.isEnum;
while($$len > index){
var S = IObject($$[index++])
while(aLen > index){
var S = IObject(arguments[index++])
, keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S)
, length = keys.length
, j = 0
Expand Down
11 changes: 5 additions & 6 deletions modules/_partial.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ module.exports = function(/* ...pargs */){
, holder = false;
while(length > i)if((pargs[i] = arguments[i++]) === _)holder = true;
return function(/* ...args */){
var that = this
, $$ = arguments
, $$len = $$.length
var that = this
, aLen = arguments.length
, j = 0, k = 0, args;
if(!holder && !$$len)return invoke(fn, pargs, that);
if(!holder && !aLen)return invoke(fn, pargs, that);
args = pargs.slice();
if(holder)for(;length > j; j++)if(args[j] === _)args[j] = $$[k++];
while($$len > k)args.push($$[k++]);
if(holder)for(;length > j; j++)if(args[j] === _)args[j] = arguments[k++];
while(aLen > k)args.push(arguments[k++]);
return invoke(fn, args, that);
};
};
7 changes: 3 additions & 4 deletions modules/_typed-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ if(require('./_descriptors')){

var $from = function from(source /*, mapfn, thisArg */){
var O = toObject(source)
, $$ = arguments
, $$len = $$.length
, mapfn = $$len > 1 ? $$[1] : undefined
, aLen = arguments.length
, mapfn = aLen > 1 ? arguments[1] : undefined
, mapping = mapfn !== undefined
, iterFn = getIterFn(O)
, i, length, values, result, step, iterator;
Expand All @@ -139,7 +138,7 @@ if(require('./_descriptors')){
values.push(step.value);
} O = values;
}
if(mapping && $$len > 2)mapfn = ctx(mapfn, $$[2], 2);
if(mapping && aLen > 2)mapfn = ctx(mapfn, arguments[2], 2);
for(i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++){
result[i] = mapping ? mapfn(O[i], i) : O[i];
}
Expand Down
7 changes: 3 additions & 4 deletions modules/es6.array.from.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ $export($export.S + $export.F * !require('./_iter-detect')(function(iter){ Array
from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
var O = toObject(arrayLike)
, C = typeof this == 'function' ? this : Array
, $$ = arguments
, $$len = $$.length
, mapfn = $$len > 1 ? $$[1] : undefined
, aLen = arguments.length
, mapfn = aLen > 1 ? arguments[1] : undefined
, mapping = mapfn !== undefined
, index = 0
, iterFn = getIterFn(O)
, length, result, step, iterator;
if(mapping)mapfn = ctx(mapfn, $$len > 2 ? $$[2] : undefined, 2);
if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
// if object isn't iterable or it's array with default iterator - use simple case
if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){
for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){
Expand Down
9 changes: 4 additions & 5 deletions modules/es6.array.of.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ $export($export.S + $export.F * require('./_fails')(function(){
// 22.1.2.3 Array.of( ...items)
of: function of(/* ...args */){
var index = 0
, $$ = arguments
, $$len = $$.length
, result = new (typeof this == 'function' ? this : Array)($$len);
while($$len > index)result[index] = $$[index++];
result.length = $$len;
, aLen = arguments.length
, result = new (typeof this == 'function' ? this : Array)(aLen);
while(aLen > index)result[index] = arguments[index++];
result.length = aLen;
return result;
}
});
13 changes: 6 additions & 7 deletions modules/es6.math.hypot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ var $export = require('./_export')

$export($export.S, 'Math', {
hypot: function hypot(value1, value2){ // eslint-disable-line no-unused-vars
var sum = 0
, i = 0
, $$ = arguments
, $$len = $$.length
, larg = 0
var sum = 0
, i = 0
, aLen = arguments.length
, larg = 0
, arg, div;
while(i < $$len){
arg = abs($$[i++]);
while(i < aLen){
arg = abs(arguments[i++]);
if(larg < arg){
div = larg / arg;
sum = sum * div * div + 1;
Expand Down
3 changes: 1 addition & 2 deletions modules/es6.string.ends-with.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ var $export = require('./_export')
$export($export.P + $export.F * require('./_fails-is-regexp')(ENDS_WITH), 'String', {
endsWith: function endsWith(searchString /*, endPosition = @length */){
var that = context(this, searchString, ENDS_WITH)
, $$ = arguments
, endPosition = $$.length > 1 ? $$[1] : undefined
, endPosition = arguments.length > 1 ? arguments[1] : undefined
, len = toLength(that.length)
, end = endPosition === undefined ? len : Math.min(toLength(endPosition), len)
, search = String(searchString);
Expand Down
11 changes: 5 additions & 6 deletions modules/es6.string.from-code-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ var $export = require('./_export')
$export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
// 21.1.2.2 String.fromCodePoint(...codePoints)
fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars
var res = []
, $$ = arguments
, $$len = $$.length
, i = 0
var res = []
, aLen = arguments.length
, i = 0
, code;
while($$len > i){
code = +$$[i++];
while(aLen > i){
code = +arguments[i++];
if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point');
res.push(code < 0x10000
? fromCharCode(code)
Expand Down
Loading

0 comments on commit 059446f

Please sign in to comment.