Skip to content

Commit 3354467

Browse files
committed
feat(operator): error handling for type dismatch
1 parent 9b91ec9 commit 3354467

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/operator.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ export function operatorCalc(alg, result) {
6565
return new inVector.constructor(x, y);
6666
}
6767
if (funRes) {
68+
if (result.length === 3) {
69+
return result(x, y, 0);
70+
}
6871
return result(x, y);
6972
}
7073

@@ -77,6 +80,9 @@ export function operatorCalc(alg, result) {
7780
return new inVector.constructor(x, y, z);
7881
}
7982
if (funRes) {
83+
if (result.length !== 3) {
84+
throw new Error('You cant use 3D Operands for a 2D Result, better use xz, xy, yz getter');
85+
}
8086
return result(x, y, z);
8187
}
8288

0 commit comments

Comments
 (0)