Skip to content

Commit 2c4502e

Browse files
committed
fix: do not use rest parameters
1 parent a029ffd commit 2c4502e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/matrix.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,20 +1338,20 @@ var staticMethod = `
13381338
`;
13391339

13401340
var inplaceMethodWithArgs = `
1341-
(function %name%(...args) {
1341+
(function %name%(%args%) {
13421342
for (var i = 0; i < this.rows; i++) {
13431343
for (var j = 0; j < this.columns; j++) {
1344-
this[i][j] = %method%(this[i][j], ...args);
1344+
this[i][j] = %method%(this[i][j], %args%);
13451345
}
13461346
}
13471347
return this;
13481348
})
13491349
`;
13501350

13511351
var staticMethodWithArgs = `
1352-
(function %name%(matrix, ...args) {
1352+
(function %name%(matrix, %args%) {
13531353
var newMatrix = new Matrix(matrix);
1354-
return newMatrix.%name%(...args);
1354+
return newMatrix.%name%(%args%);
13551355
})
13561356
`;
13571357

@@ -1406,13 +1406,17 @@ for (var method of methods) {
14061406
}
14071407

14081408
var methodsWithArgs = [
1409-
['Math.pow', 'pow']
1409+
['Math.pow', 1, 'pow']
14101410
];
14111411

14121412
for (var methodWithArg of methodsWithArgs) {
1413-
var inplaceMethWithArgs = eval(fillTemplateFunction(inplaceMethodWithArgs, {name: methodWithArg[1], method: methodWithArg[0]}));
1414-
var staticMethWithArgs = eval(fillTemplateFunction(staticMethodWithArgs, {name: methodWithArg[1]}));
1415-
for (var i = 1; i < methodWithArg.length; i++) {
1413+
var args = 'arg0';
1414+
for (var i = 1; i < methodWithArg[1]; i++) {
1415+
args += `, arg${i}`;
1416+
}
1417+
var inplaceMethWithArgs = eval(fillTemplateFunction(inplaceMethodWithArgs, {name: methodWithArg[2], method: methodWithArg[0], args: args}));
1418+
var staticMethWithArgs = eval(fillTemplateFunction(staticMethodWithArgs, {name: methodWithArg[2], args: args}));
1419+
for (var i = 2; i < methodWithArg.length; i++) {
14161420
Matrix.prototype[methodWithArg[i]] = inplaceMethWithArgs;
14171421
Matrix[methodWithArg[i]] = staticMethWithArgs;
14181422
}

0 commit comments

Comments
 (0)