@@ -22,11 +22,9 @@ export class Lorem {
2222 * @method faker.lorem.word
2323 * @param length length of the word that should be returned. Defaults to a random length
2424 */
25- word ( length ) {
26- var hasRightLength = ( word ) => {
27- return word . length === length ;
28- } ;
29- var properLengthWords ;
25+ word ( length ?: number ) : string {
26+ const hasRightLength = ( word : string ) => word . length === length ;
27+ let properLengthWords : string [ ] ;
3028 if ( typeof length === 'undefined' ) {
3129 properLengthWords = this . faker . definitions . lorem . words ;
3230 } else {
@@ -42,12 +40,12 @@ export class Lorem {
4240 * @method faker.lorem.words
4341 * @param num number of words, defaults to 3
4442 */
45- words ( num ) {
43+ words ( num ?: number ) : string {
4644 if ( typeof num == 'undefined' ) {
4745 num = 3 ;
4846 }
49- var words = [ ] ;
50- for ( var i = 0 ; i < num ; i ++ ) {
47+ const words : string [ ] = [ ] ;
48+ for ( let i = 0 ; i < num ; i ++ ) {
5149 words . push ( this . faker . lorem . word ( ) ) ;
5250 }
5351 return words . join ( ' ' ) ;
@@ -60,7 +58,8 @@ export class Lorem {
6058 * @param wordCount defaults to a random number between 3 and 10
6159 * @param range
6260 */
63- sentence ( wordCount , range ) {
61+ // TODO @Shinigami 92 2022-01-11: `range` is not in use
62+ sentence ( wordCount ?: number , range ?: number ) : string {
6463 if ( typeof wordCount == 'undefined' ) {
6564 wordCount = this . faker . datatype . number ( { min : 3 , max : 10 } ) ;
6665 }
@@ -69,7 +68,7 @@ export class Lorem {
6968 // strange issue with the node_min_test failing for capitalize, please fix and add faker.lorem.back
7069 //return faker.lorem.words(wordCount + Helpers.randomNumber(range)).join(' ').capitalize();
7170
72- var sentence = this . faker . lorem . words ( wordCount ) ;
71+ const sentence = this . faker . lorem . words ( wordCount ) ;
7372 return sentence . charAt ( 0 ) . toUpperCase ( ) + sentence . slice ( 1 ) + '.' ;
7473 }
7574
@@ -79,8 +78,8 @@ export class Lorem {
7978 * @method faker.lorem.slug
8079 * @param wordCount number of words, defaults to 3
8180 */
82- slug ( wordCount ) {
83- var words = this . faker . lorem . words ( wordCount ) ;
81+ slug ( wordCount ?: number ) {
82+ const words = this . faker . lorem . words ( wordCount ) ;
8483 return this . Helpers . slugify ( words ) ;
8584 }
8685
@@ -91,14 +90,14 @@ export class Lorem {
9190 * @param sentenceCount defaults to a random number between 2 and 6
9291 * @param separator defaults to `' '`
9392 */
94- sentences ( sentenceCount , separator ) {
93+ sentences ( sentenceCount ?: number , separator ?: string ) {
9594 if ( typeof sentenceCount === 'undefined' ) {
9695 sentenceCount = this . faker . datatype . number ( { min : 2 , max : 6 } ) ;
9796 }
9897 if ( typeof separator == 'undefined' ) {
9998 separator = ' ' ;
10099 }
101- var sentences = [ ] ;
100+ const sentences : string [ ] = [ ] ;
102101 for ( sentenceCount ; sentenceCount > 0 ; sentenceCount -- ) {
103102 sentences . push ( this . faker . lorem . sentence ( ) ) ;
104103 }
@@ -111,10 +110,7 @@ export class Lorem {
111110 * @method faker.lorem.paragraph
112111 * @param sentenceCount defaults to 3
113112 */
114- paragraph ( sentenceCount ) {
115- if ( typeof sentenceCount == 'undefined' ) {
116- sentenceCount = 3 ;
117- }
113+ paragraph ( sentenceCount : number = 3 ) : string {
118114 return this . faker . lorem . sentences (
119115 sentenceCount + this . faker . datatype . number ( 3 )
120116 ) ;
@@ -127,14 +123,8 @@ export class Lorem {
127123 * @param paragraphCount defaults to 3
128124 * @param separator defaults to `'\n \r'`
129125 */
130- paragraphs ( paragraphCount , separator ) {
131- if ( typeof separator === 'undefined' ) {
132- separator = '\n \r' ;
133- }
134- if ( typeof paragraphCount == 'undefined' ) {
135- paragraphCount = 3 ;
136- }
137- var paragraphs = [ ] ;
126+ paragraphs ( paragraphCount : number = 3 , separator : string = '\n \r' ) : string {
127+ const paragraphs : string [ ] = [ ] ;
138128 for ( paragraphCount ; paragraphCount > 0 ; paragraphCount -- ) {
139129 paragraphs . push ( this . faker . lorem . paragraph ( ) ) ;
140130 }
@@ -149,8 +139,9 @@ export class Lorem {
149139 */
150140 // TODO @Shinigami 92 2022-01-11: Is this a function-name alias?
151141 // Or can we just remove the `loremText`?
152- text = function loremText ( times ) {
153- var loremMethods = [
142+ // TODO @Shinigami 92 2022-01-11: `times` is not in use
143+ text = function loremText ( times ?: number ) {
144+ const loremMethods = [
154145 'lorem.word' ,
155146 'lorem.words' ,
156147 'lorem.sentence' ,
@@ -159,7 +150,7 @@ export class Lorem {
159150 'lorem.paragraphs' ,
160151 'lorem.lines' ,
161152 ] ;
162- var randomLoremMethod = this . faker . random . arrayElement ( loremMethods ) ;
153+ const randomLoremMethod = this . faker . random . arrayElement ( loremMethods ) ;
163154 return this . faker . fake ( '{{' + randomLoremMethod + '}}' ) ;
164155 } ;
165156
@@ -169,7 +160,7 @@ export class Lorem {
169160 * @method faker.lorem.lines
170161 * @param lineCount defaults to a random number between 1 and 5
171162 */
172- lines ( lineCount ) {
163+ lines ( lineCount ?: number ) : string {
173164 if ( typeof lineCount === 'undefined' ) {
174165 lineCount = this . faker . datatype . number ( { min : 1 , max : 5 } ) ;
175166 }
0 commit comments