Skip to content

Commit d8028ee

Browse files
committed
Update JSDoc descriptions
1 parent 085069c commit d8028ee

4 files changed

Lines changed: 22 additions & 9 deletions

File tree

src/lib/clean_number.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import { BADNUM } from '../constants/numerical';
77
const JUNK = /^['"%,$#\s']+|[, ]|['"%,$#\s']+$/g;
88

99
/**
10-
* cleanNumber: remove common leading and trailing cruft
10+
* Remove common leading and trailing cruft from a value and coerce it to a number.
1111
* Always returns either a number or BADNUM.
12+
*
13+
* @param v - value to clean; strings have leading/trailing junk characters stripped before numeric coercion
1214
*/
1315
function cleanNumber(v: any): number | undefined {
1416
if (typeof v === 'string') v = v.replace(JUNK, '');

src/lib/mod.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
'use strict';
22

33
/**
4-
* sanitized modulus function that always returns in the range [0, d)
5-
* rather than (-d, 0] if v is negative
4+
* Sanitized modulus function that always returns in the range [0, d)
5+
* rather than (-d, 0] if v is negative.
6+
*
7+
* @param v - dividend
8+
* @param d - divisor (the modulus); assumed positive
69
*/
710
export function mod(v: number, d: number) {
811
const out = v % d;
912
return out < 0 ? out + d : out;
1013
}
1114

1215
/**
13-
* sanitized modulus function that always returns in the range [-d/2, d/2]
14-
* rather than (-d, 0] if v is negative
16+
* Sanitized modulus function that always returns in the range [-d/2, d/2]
17+
* rather than (-d, 0] if v is negative.
18+
*
19+
* @param v - dividend
20+
* @param d - divisor (the modulus); assumed positive
1521
*/
1622
export function modHalf(v: number, d: number) {
1723
return Math.abs(v) > d / 2 ? v - Math.round(v / d) * d : v;

src/lib/regex.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ const NUMBER_REGEX = '([2-9]|[1-9][0-9]+)?';
55
/**
66
* make a regex for matching counter ids/names ie xaxis, xaxis2, xaxis10...
77
*
8-
* @param head: the head of the pattern, eg 'x' matches 'x', 'x2', 'x10' etc.
8+
* @param head - the head of the pattern, eg 'x' matches 'x', 'x2', 'x10' etc.
99
* 'xy' is a special case for cartesian subplots: it matches 'x2y3' etc
10-
* @param tail: a fixed piece after the id
10+
* @param tail - a fixed piece after the id
1111
* eg counterRegex('scene', '.annotations') for scene2.annotations etc.
12-
* @param openEnded: if true, the string may continue past the match.
13-
* @param matchBeginning: if false, the string may start before the match.
12+
* @param openEnded - if true, the string may continue past the match.
13+
* @param matchBeginning - if false, the string may start before the match.
1414
*/
1515
export function counter(head: string, tail: string = '', openEnded: boolean, matchBeginning: boolean) {
1616
const fullTail = tail + (openEnded ? '' : '$');

src/lib/sort_object_keys.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
'use strict';
22

3+
/**
4+
* Return the keys of an object in lexicographic (default `Array.prototype.sort`) order.
5+
*
6+
* @param obj - object whose own enumerable keys will be listed and sorted
7+
*/
38
function sortObjectKeys(obj: Record<string, any>) {
49
return Object.keys(obj).sort();
510
}

0 commit comments

Comments
 (0)