Skip to content

Commit 18f14c8

Browse files
authored
docs(string): improve documentation for length parameters (#3216)
1 parent c0a7e23 commit 18f14c8

File tree

1 file changed

+40
-39
lines changed

1 file changed

+40
-39
lines changed

src/modules/string/index.ts

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class StringModule extends SimpleModuleBase {
103103
*
104104
* @param characters The characters to use for the string. Can be a string or an array of characters.
105105
* If it is an array, then each element is treated as a single character even if it is a string with multiple characters.
106-
* @param length The length of the string to generate. Defaults to `1`.
106+
* @param length The length of the string to generate either as a fixed length or as a length range. Defaults to `1`.
107107
* @param length.min The minimum length of the string to generate.
108108
* @param length.max The maximum length of the string to generate.
109109
*
@@ -155,8 +155,8 @@ export class StringModule extends SimpleModuleBase {
155155
/**
156156
* Generating a string consisting of letters in the English alphabet.
157157
*
158-
* @param options Either the number of characters or an options instance.
159-
* @param options.length The number or range of characters to generate. Defaults to `1`.
158+
* @param options Either the length of the string to generate or the optional options object.
159+
* @param options.length The length of the string to generate either as a fixed length or as a length range. Defaults to `1`.
160160
* @param options.casing The casing of the characters. Defaults to `'mixed'`.
161161
* @param options.exclude An array with characters which should be excluded in the generated string. Defaults to `[]`.
162162
*
@@ -175,19 +175,19 @@ export class StringModule extends SimpleModuleBase {
175175
| number
176176
| {
177177
/**
178-
* The number or range of characters to generate.
178+
* The length of the string to generate either as a fixed length or as a length range.
179179
*
180180
* @default 1
181181
*/
182182
length?:
183183
| number
184184
| {
185185
/**
186-
* The minimum number of characters to generate.
186+
* The minimum length of the string to generate.
187187
*/
188188
min: number;
189189
/**
190-
* The maximum number of characters to generate.
190+
* The maximum length of the string to generate.
191191
*/
192192
max: number;
193193
};
@@ -249,8 +249,8 @@ export class StringModule extends SimpleModuleBase {
249249
/**
250250
* Generating a string consisting of alpha characters and digits.
251251
*
252-
* @param options Either the number of characters or an options instance.
253-
* @param options.length The number or range of characters and digits to generate. Defaults to `1`.
252+
* @param options Either the length of the string to generate or the optional options object.
253+
* @param options.length The length of the string to generate either as a fixed length or as a length range. Defaults to `1`.
254254
* @param options.casing The casing of the characters. Defaults to `'mixed'`.
255255
* @param options.exclude An array of characters and digits which should be excluded in the generated string. Defaults to `[]`.
256256
*
@@ -269,19 +269,19 @@ export class StringModule extends SimpleModuleBase {
269269
| number
270270
| {
271271
/**
272-
* The number or range of characters and digits to generate.
272+
* The length of the string to generate either as a fixed length or as a length range.
273273
*
274274
* @default 1
275275
*/
276276
length?:
277277
| number
278278
| {
279279
/**
280-
* The minimum number of characters and digits to generate.
280+
* The minimum length of the string to generate.
281281
*/
282282
min: number;
283283
/**
284-
* The maximum number of characters and digits to generate.
284+
* The maximum length of the string to generate.
285285
*/
286286
max: number;
287287
};
@@ -345,7 +345,7 @@ export class StringModule extends SimpleModuleBase {
345345
* Returns a [binary](https://en.wikipedia.org/wiki/Binary_number) string.
346346
*
347347
* @param options The optional options object.
348-
* @param options.length The number or range of characters to generate after the prefix. Defaults to `1`.
348+
* @param options.length The length of the string (excluding the prefix) to generate either as a fixed length or as a length range. Defaults to `1`.
349349
* @param options.prefix Prefix for the generated number. Defaults to `'0b'`.
350350
*
351351
* @see faker.number.binary(): For generating a binary number (within a range).
@@ -362,19 +362,19 @@ export class StringModule extends SimpleModuleBase {
362362
binary(
363363
options: {
364364
/**
365-
* The number or range of characters to generate after the prefix.
365+
* The length of the string (excluding the prefix) to generate either as a fixed length or as a length range.
366366
*
367367
* @default 1
368368
*/
369369
length?:
370370
| number
371371
| {
372372
/**
373-
* The minimum number of characters to generate.
373+
* The minimum length of the string (excluding the prefix) to generate.
374374
*/
375375
min: number;
376376
/**
377-
* The maximum number of characters to generate.
377+
* The maximum length of the string (excluding the prefix) to generate.
378378
*/
379379
max: number;
380380
};
@@ -397,7 +397,7 @@ export class StringModule extends SimpleModuleBase {
397397
* Returns an [octal](https://en.wikipedia.org/wiki/Octal) string.
398398
*
399399
* @param options The optional options object.
400-
* @param options.length The number or range of characters to generate after the prefix. Defaults to `1`.
400+
* @param options.length The length of the string (excluding the prefix) to generate either as a fixed length or as a length range. Defaults to `1`.
401401
* @param options.prefix Prefix for the generated number. Defaults to `'0o'`.
402402
*
403403
* @see faker.number.octal(): For generating an octal number (within a range).
@@ -414,19 +414,19 @@ export class StringModule extends SimpleModuleBase {
414414
octal(
415415
options: {
416416
/**
417-
* The number or range of characters to generate after the prefix.
417+
* The length of the string (excluding the prefix) to generate either as a fixed length or as a length range.
418418
*
419419
* @default 1
420420
*/
421421
length?:
422422
| number
423423
| {
424424
/**
425-
* The minimum number of characters to generate.
425+
* The minimum length of the string (excluding the prefix) to generate.
426426
*/
427427
min: number;
428428
/**
429-
* The maximum number of characters to generate.
429+
* The maximum length of the string (excluding the prefix) to generate.
430430
*/
431431
max: number;
432432
};
@@ -452,7 +452,7 @@ export class StringModule extends SimpleModuleBase {
452452
* Returns a [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) string.
453453
*
454454
* @param options The optional options object.
455-
* @param options.length The number or range of characters to generate after the prefix. Defaults to `1`.
455+
* @param options.length The length of the string (excluding the prefix) to generate either as a fixed length or as a length range. Defaults to `1`.
456456
* @param options.casing Casing of the generated number. Defaults to `'mixed'`.
457457
* @param options.prefix Prefix for the generated number. Defaults to `'0x'`.
458458
*
@@ -472,19 +472,19 @@ export class StringModule extends SimpleModuleBase {
472472
hexadecimal(
473473
options: {
474474
/**
475-
* The number or range of characters to generate after the prefix.
475+
* The length of the string (excluding the prefix) to generate either as a fixed length or as a length range.
476476
*
477477
* @default 1
478478
*/
479479
length?:
480480
| number
481481
| {
482482
/**
483-
* The minimum number of characters to generate after the prefix.
483+
* The minimum length of the string (excluding the prefix) to generate.
484484
*/
485485
min: number;
486486
/**
487-
* The maximum number of characters to generate after the prefix.
487+
* The maximum length of the string (excluding the prefix) to generate.
488488
*/
489489
max: number;
490490
};
@@ -548,8 +548,8 @@ export class StringModule extends SimpleModuleBase {
548548
/**
549549
* Generates a given length string of digits.
550550
*
551-
* @param options Either the number of characters or the options to use.
552-
* @param options.length The number or range of digits to generate. Defaults to `1`.
551+
* @param options Either the length of the string to generate or the optional options object.
552+
* @param options.length The length of the string to generate either as a fixed length or as a length range. Defaults to `1`.
553553
* @param options.allowLeadingZeros Whether leading zeros are allowed or not. Defaults to `true`.
554554
* @param options.exclude An array of digits which should be excluded in the generated string. Defaults to `[]`.
555555
*
@@ -570,19 +570,19 @@ export class StringModule extends SimpleModuleBase {
570570
| number
571571
| {
572572
/**
573-
* The number or range of digits to generate.
573+
* The length of the string to generate either as a fixed length or as a length range.
574574
*
575575
* @default 1
576576
*/
577577
length?:
578578
| number
579579
| {
580580
/**
581-
* The minimum number of digits to generate.
581+
* The minimum length of the string to generate.
582582
*/
583583
min: number;
584584
/**
585-
* The maximum number of digits to generate.
585+
* The maximum length of the string to generate.
586586
*/
587587
max: number;
588588
};
@@ -649,9 +649,9 @@ export class StringModule extends SimpleModuleBase {
649649
/**
650650
* Returns a string containing UTF-16 chars between 33 and 125 (`!` to `}`).
651651
*
652-
* @param length Length of the generated string. Defaults to `10`.
653-
* @param length.min The minimum number of characters to generate.
654-
* @param length.max The maximum number of characters to generate.
652+
* @param length The length of the string (excluding the prefix) to generate either as a fixed length or as a length range. Defaults to `10`.
653+
* @param length.min The minimum length of the string to generate.
654+
* @param length.max The maximum length of the string to generate.
655655
*
656656
* @example
657657
* faker.string.sample() // 'Zo!.:*e>wR'
@@ -665,11 +665,11 @@ export class StringModule extends SimpleModuleBase {
665665
| number
666666
| {
667667
/**
668-
* The minimum number of characters to generate.
668+
* The minimum length of the string to generate.
669669
*/
670670
min: number;
671671
/**
672-
* The maximum number of characters to generate.
672+
* The maximum length of the string to generate.
673673
*/
674674
max: number;
675675
} = 10
@@ -740,7 +740,7 @@ export class StringModule extends SimpleModuleBase {
740740
/**
741741
* Generates a [Nano ID](https://github.com/ai/nanoid).
742742
*
743-
* @param length Length of the generated string. Defaults to `21`.
743+
* @param length The length of the string to generate either as a fixed length or as a length range. Defaults to `21`.
744744
* @param length.min The minimum length of the Nano ID to generate.
745745
* @param length.max The maximum length of the Nano ID to generate.
746746
*
@@ -794,13 +794,14 @@ export class StringModule extends SimpleModuleBase {
794794

795795
/**
796796
* Returns a string containing only special characters from the following list:
797+
*
797798
* ```txt
798799
* ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
799800
* ```
800801
*
801-
* @param length Length of the generated string. Defaults to `1`.
802-
* @param length.min The minimum number of special characters to generate.
803-
* @param length.max The maximum number of special characters to generate.
802+
* @param length The length of the string to generate either as a fixed length or as a length range. Defaults to `1`.
803+
* @param length.min The minimum length of the string to generate.
804+
* @param length.max The maximum length of the string to generate.
804805
*
805806
* @example
806807
* faker.string.symbol() // '$'
@@ -814,11 +815,11 @@ export class StringModule extends SimpleModuleBase {
814815
| number
815816
| {
816817
/**
817-
* The minimum number of special characters to generate.
818+
* The minimum length of the string to generate.
818819
*/
819820
min: number;
820821
/**
821-
* The maximum number of special characters to generate.
822+
* The maximum length of the string to generate.
822823
*/
823824
max: number;
824825
} = 1

0 commit comments

Comments
 (0)