Skip to content

Commit d21741c

Browse files
committed
feat(operator): dont need createVector fn anymore
calling directly assigned class constructor
1 parent d37ee4f commit d21741c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/operator.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint func-names: 0 */
22
/* eslint no-param-reassign: 0 */
33
/* eslint getter-return: 0 */
4+
/* eslint new-cap: 0 */
45

56
const X = 0;
67
const Y = 1;
@@ -37,7 +38,7 @@ export function operatorCalc(alg, result) {
3738
const z = alg();
3839

3940
if (!result) {
40-
return inVector.createVector(x, y, z);
41+
return new inVector.constructor(x, y, z);
4142
}
4243
if (typeof result === 'function') {
4344
return result(x, y, z);
@@ -57,11 +58,10 @@ export function operatorCalc(alg, result) {
5758
export function cachedValueOf(Vector) {
5859
const name = 'valueOf';
5960
const org = Vector.prototype[name];
61+
6062
Vector.prototype[name] = function () {
6163
if (inProgress === X) {
62-
if (typeof inVector === 'undefined') {
63-
inVector = this;
64-
}
64+
inVector = this;
6565
return this.x;
6666
}
6767
if (inProgress === Y) {

0 commit comments

Comments
 (0)