Skip to content

Commit f924c5e

Browse files
committed
fix(src): change undefined to args
1 parent b512d81 commit f924c5e

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/point.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ function square(val) {
2525
}
2626

2727
class APoint {
28-
constructor(x = undefined, y = undefined) {
29-
if (typeof x === 'function') {
30-
operatorCalc(x, (nx, ny) => {
28+
constructor(...args) {
29+
if (typeof args[0] === 'function') {
30+
operatorCalc(args[0], (nx, ny) => {
3131
this[AXES] = [nx, ny];
3232
});
33-
} else if (isArray(x)) {
34-
this[AXES] = [...x];
35-
} else if (x && isNumber(x.x)) {
36-
this[AXES] = [x.x || 0, x.y || 0];
33+
} else if (isArray(args[0])) {
34+
this[AXES] = [...args[0]];
35+
} else if (args[0] && isNumber(args[0].x)) {
36+
this[AXES] = [args[0].x || 0, args[0].y || 0];
3737
} else {
38-
this[AXES] = [x || 0, y || 0];
38+
this[AXES] = [args[0] || 0, args[1] || 0];
3939
}
4040
}
4141

src/vector.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ function square(val) {
2020
}
2121

2222
class AVector {
23-
constructor(x = undefined, y = undefined, z = undefined) {
24-
if (typeof x === 'function') {
25-
operatorCalc(x, (nx, ny, nz) => {
23+
constructor(...args) {
24+
if (typeof args[0] === 'function') {
25+
operatorCalc(args[0], (nx, ny, nz) => {
2626
this[AXES] = [nx, ny, nz];
2727
});
28-
} else if (isArray(x)) {
29-
this[AXES] = [...x];
30-
} else if (x && isNumber(x.x)) {
31-
this[AXES] = [x.x || 0, x.y || 0, x.z || 0];
28+
} else if (isArray(args[0])) {
29+
this[AXES] = [...args[0]];
30+
} else if (args[0] && isNumber(args[0].x)) {
31+
this[AXES] = [args[0].x || 0, args[0].y || 0, args[0].z || 0];
3232
} else {
33-
this[AXES] = [x || 0, y || 0, z || 0];
33+
this[AXES] = [args[0] || 0, args[1] || 0, args[2] || 0];
3434
}
3535
}
3636

0 commit comments

Comments
 (0)