3
3
*
4
4
* Give an input string, strictly parses a boolean value.
5
5
*
6
- * @param value The boolean string to parse.
6
+ * @param value - The boolean string to parse.
7
7
* @returns true for "true", false for "false", otherwise an error is thrown.
8
8
*/
9
9
export const parseBoolean = ( value : string ) : boolean => {
@@ -24,7 +24,7 @@ export const parseBoolean = (value: string): boolean => {
24
24
* Casts strings and numbers with a warning if there is evidence that they were
25
25
* intended to be booleans.
26
26
*
27
- * @param value A value that is expected to be a boolean.
27
+ * @param value - A value that is expected to be a boolean.
28
28
* @returns The value if it's a boolean, undefined if it's null/undefined,
29
29
* otherwise an error is thrown.
30
30
*/
@@ -68,7 +68,7 @@ export const expectBoolean = (value: any): boolean | undefined => {
68
68
* Casts strings with a warning if the string is a parseable number.
69
69
* This is to unblock slight API definition/implementation inconsistencies.
70
70
*
71
- * @param value A value that is expected to be a number.
71
+ * @param value - A value that is expected to be a number.
72
72
* @returns The value if it's a number, undefined if it's null/undefined,
73
73
* otherwise an error is thrown.
74
74
*/
@@ -98,7 +98,7 @@ const MAX_FLOAT = Math.ceil(2 ** 127 * (2 - 2 ** -23));
98
98
*
99
99
* Asserts a value is a 32-bit float and returns it.
100
100
*
101
- * @param value A value that is expected to be a 32-bit float.
101
+ * @param value - A value that is expected to be a 32-bit float.
102
102
* @returns The value if it's a float, undefined if it's null/undefined,
103
103
* otherwise an error is thrown.
104
104
*/
@@ -149,7 +149,7 @@ export const expectFloat32 = (value: any): number | undefined => {
149
149
*
150
150
* Asserts a value is an integer and returns it.
151
151
*
152
- * @param value A value that is expected to be an integer.
152
+ * @param value - A value that is expected to be an integer.
153
153
* @returns The value if it's an integer, undefined if it's null/undefined,
154
154
* otherwise an error is thrown.
155
155
*/
@@ -175,7 +175,7 @@ export const expectInt = expectLong;
175
175
*
176
176
* Asserts a value is a 32-bit integer and returns it.
177
177
*
178
- * @param value A value that is expected to be an integer.
178
+ * @param value - A value that is expected to be an integer.
179
179
* @returns The value if it's an integer, undefined if it's null/undefined,
180
180
* otherwise an error is thrown.
181
181
*/
@@ -186,7 +186,7 @@ export const expectInt32 = (value: any): number | undefined => expectSizedInt(va
186
186
*
187
187
* Asserts a value is a 16-bit integer and returns it.
188
188
*
189
- * @param value A value that is expected to be an integer.
189
+ * @param value - A value that is expected to be an integer.
190
190
* @returns The value if it's an integer, undefined if it's null/undefined,
191
191
* otherwise an error is thrown.
192
192
*/
@@ -197,7 +197,7 @@ export const expectShort = (value: any): number | undefined => expectSizedInt(va
197
197
*
198
198
* Asserts a value is an 8-bit integer and returns it.
199
199
*
200
- * @param value A value that is expected to be an integer.
200
+ * @param value - A value that is expected to be an integer.
201
201
* @returns The value if it's an integer, undefined if it's null/undefined,
202
202
* otherwise an error is thrown.
203
203
*/
@@ -229,8 +229,8 @@ const castInt = (value: number, size: IntSize) => {
229
229
*
230
230
* Asserts a value is not null or undefined and returns it, or throws an error.
231
231
*
232
- * @param value A value that is expected to be defined
233
- * @param location The location where we're expecting to find a defined object (optional)
232
+ * @param value - A value that is expected to be defined
233
+ * @param location - The location where we're expecting to find a defined object (optional)
234
234
* @returns The value if it's not undefined, otherwise throws an error
235
235
*/
236
236
export const expectNonNull = < T > ( value : T | null | undefined , location ?: string ) : T => {
@@ -249,7 +249,7 @@ export const expectNonNull = <T>(value: T | null | undefined, location?: string)
249
249
* Asserts a value is an JSON-like object and returns it. This is expected to be used
250
250
* with values parsed from JSON (arrays, objects, numbers, strings, booleans).
251
251
*
252
- * @param value A value that is expected to be an object
252
+ * @param value - A value that is expected to be an object
253
253
* @returns The value if it's an object, undefined if it's null/undefined,
254
254
* otherwise an error is thrown.
255
255
*/
@@ -270,7 +270,7 @@ export const expectObject = (value: any): Record<string, any> | undefined => {
270
270
* Asserts a value is a string and returns it.
271
271
* Numbers and boolean will be cast to strings with a warning.
272
272
*
273
- * @param value A value that is expected to be a string.
273
+ * @param value - A value that is expected to be a string.
274
274
* @returns The value if it's a string, undefined if it's null/undefined,
275
275
* otherwise an error is thrown.
276
276
*/
@@ -294,9 +294,9 @@ export const expectString = (value: any): string | undefined => {
294
294
* Asserts a value is a JSON-like object with only one non-null/non-undefined key and
295
295
* returns it.
296
296
*
297
- * @param value A value that is expected to be an object with exactly one non-null,
297
+ * @param value - A value that is expected to be an object with exactly one non-null,
298
298
* non-undefined key.
299
- * @return the value if it's a union, undefined if it's null/undefined, otherwise
299
+ * @returns the value if it's a union, undefined if it's null/undefined, otherwise
300
300
* an error is thrown.
301
301
*/
302
302
export const expectUnion = ( value : unknown ) : Record < string , any > | undefined => {
@@ -329,7 +329,7 @@ export const expectUnion = (value: unknown): Record<string, any> | undefined =>
329
329
* "NaN", any implicit Nan values will result in an error being thrown. If any
330
330
* other type is provided, an exception will be thrown.
331
331
*
332
- * @param value A number or string representation of a double.
332
+ * @param value - A number or string representation of a double.
333
333
* @returns The value as a number, or undefined if it's null/undefined.
334
334
*/
335
335
export const strictParseDouble = ( value : string | number ) : number | undefined => {
@@ -355,7 +355,7 @@ export const strictParseFloat = strictParseDouble;
355
355
* "NaN", any implicit Nan values will result in an error being thrown. If any
356
356
* other type is provided, an exception will be thrown.
357
357
*
358
- * @param value A number or string representation of a float.
358
+ * @param value - A number or string representation of a float.
359
359
* @returns The value as a number, or undefined if it's null/undefined.
360
360
*/
361
361
export const strictParseFloat32 = ( value : string | number ) : number | undefined => {
@@ -390,7 +390,7 @@ const parseNumber = (value: string): number => {
390
390
* being thrown. Null or undefined will be returned as undefined. Any other
391
391
* type will result in an exception being thrown.
392
392
*
393
- * @param value A number or string representation of a non-numeric float.
393
+ * @param value - A number or string representation of a non-numeric float.
394
394
* @returns The value as a number, or undefined if it's null/undefined.
395
395
*/
396
396
export const limitedParseDouble = ( value : string | number ) : number | undefined => {
@@ -423,7 +423,7 @@ export const limitedParseFloat = limitedParseDouble;
423
423
* being thrown. Null or undefined will be returned as undefined. Any other
424
424
* type will result in an exception being thrown.
425
425
*
426
- * @param value A number or string representation of a non-numeric float.
426
+ * @param value - A number or string representation of a non-numeric float.
427
427
* @returns The value as a number, or undefined if it's null/undefined.
428
428
*/
429
429
export const limitedParseFloat32 = ( value : string | number ) : number | undefined => {
@@ -455,7 +455,7 @@ const parseFloatString = (value: string): number => {
455
455
* an integer, or the raw value is any type other than a string or number, an
456
456
* exception will be thrown.
457
457
*
458
- * @param value A number or string representation of an integer.
458
+ * @param value - A number or string representation of an integer.
459
459
* @returns The value as a number, or undefined if it's null/undefined.
460
460
*/
461
461
export const strictParseLong = ( value : string | number ) : number | undefined => {
@@ -483,7 +483,7 @@ export const strictParseInt = strictParseLong;
483
483
* an integer, or the raw value is any type other than a string or number, an
484
484
* exception will be thrown.
485
485
*
486
- * @param value A number or string representation of a 32-bit integer.
486
+ * @param value - A number or string representation of a 32-bit integer.
487
487
* @returns The value as a number, or undefined if it's null/undefined.
488
488
*/
489
489
export const strictParseInt32 = ( value : string | number ) : number | undefined => {
@@ -504,7 +504,7 @@ export const strictParseInt32 = (value: string | number): number | undefined =>
504
504
* an integer, or the raw value is any type other than a string or number, an
505
505
* exception will be thrown.
506
506
*
507
- * @param value A number or string representation of a 16-bit integer.
507
+ * @param value - A number or string representation of a 16-bit integer.
508
508
* @returns The value as a number, or undefined if it's null/undefined.
509
509
*/
510
510
export const strictParseShort = ( value : string | number ) : number | undefined => {
@@ -525,7 +525,7 @@ export const strictParseShort = (value: string | number): number | undefined =>
525
525
* an integer, or the raw value is any type other than a string or number, an
526
526
* exception will be thrown.
527
527
*
528
- * @param value A number or string representation of an 8-bit integer.
528
+ * @param value - A number or string representation of an 8-bit integer.
529
529
* @returns The value as a number, or undefined if it's null/undefined.
530
530
*/
531
531
export const strictParseByte = ( value : string | number ) : number | undefined => {
@@ -551,7 +551,7 @@ const stackTraceWarning = (message: string): string => {
551
551
} ;
552
552
553
553
/**
554
- * @private
554
+ * @internal
555
555
*/
556
556
export const logger = {
557
557
warn : console . warn ,
0 commit comments