From d21741c486aaf6516ce46fa7503a45673333f361 Mon Sep 17 00:00:00 2001 From: Stefan Eckert Date: Sun, 2 Sep 2018 10:05:42 +0200 Subject: [PATCH] feat(operator): dont need createVector fn anymore calling directly assigned class constructor --- src/operator.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/operator.js b/src/operator.js index 850bd7ad..31ff7a6a 100644 --- a/src/operator.js +++ b/src/operator.js @@ -1,6 +1,7 @@ /* eslint func-names: 0 */ /* eslint no-param-reassign: 0 */ /* eslint getter-return: 0 */ +/* eslint new-cap: 0 */ const X = 0; const Y = 1; @@ -37,7 +38,7 @@ export function operatorCalc(alg, result) { const z = alg(); if (!result) { - return inVector.createVector(x, y, z); + return new inVector.constructor(x, y, z); } if (typeof result === 'function') { return result(x, y, z); @@ -57,11 +58,10 @@ export function operatorCalc(alg, result) { export function cachedValueOf(Vector) { const name = 'valueOf'; const org = Vector.prototype[name]; + Vector.prototype[name] = function () { if (inProgress === X) { - if (typeof inVector === 'undefined') { - inVector = this; - } + inVector = this; return this.x; } if (inProgress === Y) {