Skip to content

Commit

Permalink
fix(vector): jsdocs correct @return
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTelanie committed Sep 21, 2018
1 parent 292695b commit 8b7b157
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ function square(val) {
return val * val;
}

/**
* @extends {number}
*/
class AVector {
/**
*
Expand Down Expand Up @@ -243,14 +246,26 @@ cachedGetter(AVector, 'length');
cachedGetter(AVector, 'lengthSq');

export class Vector extends AVector {
/**
*
* @param {number} x
*/
set x(x) {
this[AXES][X] = x;
}

/**
*
* @param {number} y
*/
set y(y) {
this[AXES][Y] = y;
}

/**
*
* @param {number} z
*/
set z(z) {
this[AXES][Z] = z;
}
Expand Down Expand Up @@ -297,6 +312,10 @@ export class Victor extends AVector {
return this[AXES][X];
}

/**
*
* @throws SetNotImplementedError
*/
set x(_) {
throw new Error('set x() not implemented');
}
Expand All @@ -309,6 +328,10 @@ export class Victor extends AVector {
return this[AXES][Y];
}

/**
*
* @throws SetNotImplementedError
*/
set y(_) {
throw new Error('set y() not implemented');
}
Expand All @@ -321,6 +344,10 @@ export class Victor extends AVector {
return this[AXES][Z];
}

/**
*
* @throws SetNotImplementedError
*/
set z(_) {
throw new Error('set z() not implemented');
}
Expand All @@ -329,7 +356,10 @@ export class Victor extends AVector {
return new Vector(this.x, this.y, this.z);
}
}

/**
* @param {() => number} alg
* @return {AVector | number}
*/
export function calc(alg) {
return operatorCalc(alg);
}
Expand Down
5 changes: 5 additions & 0 deletions src/operator.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ function handleProgess(progess, alg) {
return alg();
}

/**
* @param {() => number} alg
* @param {{ x: number, y: number, z: number }=} result
* @return {{ x: number, y: number, z: number } | number}
*/
export function operatorCalc(alg, result) {
if (typeof alg !== 'function') {
throw new Error('no function assigned');
Expand Down

0 comments on commit 8b7b157

Please sign in to comment.