File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -58,11 +58,27 @@ const { cap } = cap;
5858### Example:
5959
6060``` javascript
61- cap (23 , 0 , 1 ); // returns: 1
61+ const min = 1 ;
62+ const max = 5 ;
63+ cap (7 , min, max); // returns: 5
6264
65+ cap (3 , 0 , 6 ); // returns: 3
6366cap (- 5 , 1 , - 4 ); // returns: -4
6467```
6568
69+ ### Function declaration
70+
71+ ``` ts
72+ /**
73+ * Limits value to range from min to max.
74+ * If max is omitted min will be used as max, without a min range limit.
75+ * @value value to limit
76+ * @min minimum value
77+ * @max maximum value (optional)
78+ */
79+ function cap(value : number , min : number , max ? : number ): number ;
80+ ```
81+
6682## Run tests
6783
6884``` sh
Original file line number Diff line number Diff line change 11/**
2- * Limits value to range from min to max
2+ * Limits value to range from min to max.
3+ * If max is omitted min will be used as max, without a min range limit.
4+ * @value value to limit
5+ * @min minimum value
6+ * @max maximum value (optional)
37 */
48export function cap ( value : number , min : number , max ?: number ) : number {
59 if ( max === undefined ) return Math . min ( value , min ) ;
You can’t perform that action at this time.
0 commit comments