Skip to content

Commit

Permalink
feat(operator): dont need createVector fn anymore
Browse files Browse the repository at this point in the history
calling directly assigned class constructor
  • Loading branch information
MrTelanie committed Sep 2, 2018
1 parent d37ee4f commit d21741c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/operator.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit d21741c

Please sign in to comment.