Skip to content

Commit 06ad72c

Browse files
committed
feat(vector): continue prepare code for docs
1 parent 6366a76 commit 06ad72c

File tree

3 files changed

+92
-29
lines changed

3 files changed

+92
-29
lines changed

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ export {
1616

1717
/**
1818
* @param {() => number} alg
19-
* @return {(Vector | Victor | IVector | Point | IPoint) & number}
19+
* @return {(Vector | Victor | IVector | Point | IPoint) & number | number}
2020
*/
2121
export function calc(alg) {
2222
return operatorCalc(alg);
2323
}
2424

2525
export default Vector;
26+
27+
export const Export = {
28+
Vector, Victor, IVector, Point, IPoint
29+
};

src/point.js

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import formatNumber from './formatter';
1111

1212
/* eslint class-methods-use-this: 0 */
1313
/* eslint-disable no-unused-vars */
14+
/* eslint-disable no-dupe-keys */
1415

1516
const X = 0;
1617
const Y = 1;
@@ -56,6 +57,7 @@ class APoint {
5657
/**
5758
* @param {number | (Alg)} x
5859
* @param {number} [y]
60+
* @hidden
5961
*/
6062
constructor(x, y) {
6163
if (typeof x === 'function') {
@@ -147,14 +149,14 @@ class APoint {
147149
/**
148150
* @param {(point: APointType) => number} alg
149151
* @returns {this}
150-
* @throws NotImplementedError
152+
* @throws NotImplementedError
151153
*/
152154
calc(alg) {
153155
throw new Error('calc() not implemented');
154156
}
155157

156158
/**
157-
* @throws NotImplementedError
159+
* @throws NotImplementedError
158160
* @returns {APoint}
159161
*/
160162
clone() {
@@ -272,8 +274,14 @@ cachedGetter(APoint, 'lengthSq');
272274
/**
273275
* Point
274276
*
277+
* **constructor**
278+
* ___
275279
* new Point(x: *number*, y: *number*): [[Point]]
276280
*
281+
*
282+
*
283+
* **constructor**
284+
* ___
277285
* new Point(alg: (*function*(): *number*)): [[Point]]
278286
*
279287
*/
@@ -329,6 +337,8 @@ export class Point extends APoint {
329337
/**
330338
* IPoint
331339
*
340+
* **constructors**
341+
* ___
332342
* new IPoint(x: *number*, y: *number*): [[IPoint]]
333343
*
334344
* new IPoint(alg: (*function*(): *number*)): [[IPoint]]
@@ -346,6 +356,7 @@ export class IPoint extends APoint {
346356
/**
347357
* @param {Alg} alg
348358
* @return {PointType | IPointType}
359+
* @hidden
349360
*/
350361
export function calc(alg) {
351362
return operatorCalc(alg);
@@ -354,29 +365,52 @@ export function calc(alg) {
354365
const pointFactory = cachedFactory(Point);
355366

356367
/**
357-
* *function* point(x: *number*, y: *number*): [[Point]] & *number*
358-
*
359-
* *function* point(alg: (*function*(): *number*)): [[Point]] & *number*
360-
*
361368
* @typedef {(alg: Alg) => PointType} PointAlg
362369
* @typedef {(x: number , y: number) => PointType} PointCon
363-
* @typedef {PointAlg & PointCon}
370+
* @typedef {PointAlg & PointCon} point
371+
* @type {point}
372+
* @hidden
364373
*/
365-
export const point = function point(x, y) {
374+
export function point(x, y) {
366375
return pointFactory(x, y);
367-
};
376+
}
368377

369378
const ipointFactory = cachedFactory(IPoint);
370379

371380
/**
372-
* *function* ipoint(x: *number*, y: *number*): [[IPoint]] & *number*
373-
*
374-
* *function* ipoint(alg: (*function*(): *number*)): [[IPoint]] & *number*
375-
*
376381
* @typedef {(alg: Alg) => IPointType} IPointAlg
377382
* @typedef {(x: number , y: number) => IPointType} IPointCon
378383
* @typedef {IPointAlg & IPointCon}
379-
*/
380-
export const ipoint = function ipoint(x, y) {
384+
* @hidden
385+
*/
386+
export function ipoint(x, y) {
381387
return ipointFactory(x, y);
388+
}
389+
390+
export const Export = {
391+
/**
392+
* @param {Alg} alg
393+
* @return {PointType | IPointType}
394+
*/
395+
calc: alg => operatorCalc(alg),
396+
397+
/**
398+
* @type {PointAlg}
399+
*/
400+
point: alg => pointFactory(alg),
401+
402+
/**
403+
* @type {PointCon}
404+
*/
405+
point: (x, y) => pointFactory(x, y),
406+
407+
/**
408+
* @type {IPointAlg}
409+
*/
410+
ipoint: alg => ipointFactory(alg),
411+
412+
/**
413+
* @type {IPointCon}
414+
*/
415+
ipoint: (x, y) => ipointFactory(x, y)
382416
};

src/vector.js

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { ipoint } from './point';
1212

1313
/* eslint class-methods-use-this: 0 */
1414
/* eslint-disable no-unused-vars */
15+
/* eslint-disable no-dupe-keys */
1516

1617
const X = 0;
1718
const Y = 1;
@@ -45,6 +46,7 @@ class AVector {
4546
}
4647
}
4748

49+
4850
/**
4951
* @returns {number}
5052
*/
@@ -191,15 +193,15 @@ class AVector {
191193
/**
192194
* @param {(vector: AVectorType) => number} arg
193195
* @returns {this}
194-
* @throws NotImplementedError
196+
* @throws NotImplementedError
195197
*/
196198
calc(arg) {
197199
throw new Error('calc() not implemented');
198200
}
199201

200202
/**
201203
*
202-
* @throws NotImplementedError
204+
* @throws NotImplementedError
203205
* @return {AVectorType}
204206
*/
205207
clone() {
@@ -462,6 +464,7 @@ export class Victor extends AVector {
462464
/**
463465
* @param {Alg} alg
464466
* @return {VectorType | VictorType}
467+
* @hidden
465468
*/
466469
export function calc(alg) {
467470
return operatorCalc(alg);
@@ -470,29 +473,51 @@ export function calc(alg) {
470473
const vectorFactory = cachedFactory(Vector);
471474

472475
/**
473-
* *function* vector(x: *number*, y: *number*, z: *number*): [[Vector]] & *number*
474-
*
475-
* *function* vector(alg: (*function*(): *number*)): [[Vector]] & *number*
476-
*
477476
* @typedef {(alg: Alg) => VectorType} VectorAlg
478477
* @typedef {(x: number , y: number, z: number) => VectorType} VectorCon
479478
* @typedef {VectorAlg & VectorCon}
479+
* @hidden
480480
*/
481-
export const vector = function vector(x, y, z) {
481+
export function vector(x, y, z) {
482482
return vectorFactory(x, y, z);
483-
};
483+
}
484484

485485
const victorFactory = cachedFactory(Victor);
486486

487487
/**
488-
* *function* victor(x: *number*, y: *number*, z: *number*): [[Victor]] & *number*
489-
*
490-
* *function* victor(alg: (*function*(): *number*)): [[Victor]] & *number*
491-
*
492488
* @typedef {(alg: Alg) => VictorType} VictorAlg
493489
* @typedef {(x: number , y: number, z: number) => VictorType} VictorCon
494490
* @typedef {VictorAlg & VictorCon}
491+
* @hidden
495492
*/
496-
export const victor = function victor(x, y, z) {
493+
export function victor(x, y, z) {
497494
return victorFactory(x, y, z);
495+
}
496+
497+
export const Export = {
498+
/**
499+
* @param {Alg} alg
500+
* @return {VectorType | VictorType}
501+
*/
502+
calc: alg => operatorCalc(alg),
503+
504+
/**
505+
* @type {VectorAlg}
506+
*/
507+
vector: alg => vectorFactory(alg),
508+
509+
/**
510+
* @type {VectorCon}
511+
*/
512+
vector: (x, y) => vectorFactory(x, y),
513+
514+
/**
515+
* @type {VictorAlg}
516+
*/
517+
victor: alg => victorFactory(alg),
518+
519+
/**
520+
* @type {VictorCon}
521+
*/
522+
victor: (x, y) => victorFactory(x, y)
498523
};

0 commit comments

Comments
 (0)