Skip to content

Commit ea7900d

Browse files
authored
chore: align coding style of word module (#3319)
1 parent 99b9c3d commit ea7900d

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

src/modules/word/index.ts

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ export class WordModule extends ModuleBase {
6767
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
6868
} = {}
6969
): string {
70-
const opts = typeof options === 'number' ? { length: options } : options;
70+
if (typeof options === 'number') {
71+
options = { length: options };
72+
}
73+
7174
return this.faker.helpers.arrayElement(
7275
filterWordListByLength({
73-
...opts,
76+
...options,
7477
wordList: this.faker.definitions.word.adjective,
7578
})
7679
);
@@ -137,10 +140,13 @@ export class WordModule extends ModuleBase {
137140
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
138141
} = {}
139142
): string {
140-
const opts = typeof options === 'number' ? { length: options } : options;
143+
if (typeof options === 'number') {
144+
options = { length: options };
145+
}
146+
141147
return this.faker.helpers.arrayElement(
142148
filterWordListByLength({
143-
...opts,
149+
...options,
144150
wordList: this.faker.definitions.word.adverb,
145151
})
146152
);
@@ -207,10 +213,13 @@ export class WordModule extends ModuleBase {
207213
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
208214
} = {}
209215
): string {
210-
const opts = typeof options === 'number' ? { length: options } : options;
216+
if (typeof options === 'number') {
217+
options = { length: options };
218+
}
219+
211220
return this.faker.helpers.arrayElement(
212221
filterWordListByLength({
213-
...opts,
222+
...options,
214223
wordList: this.faker.definitions.word.conjunction,
215224
})
216225
);
@@ -277,10 +286,13 @@ export class WordModule extends ModuleBase {
277286
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
278287
} = {}
279288
): string {
280-
const opts = typeof options === 'number' ? { length: options } : options;
289+
if (typeof options === 'number') {
290+
options = { length: options };
291+
}
292+
281293
return this.faker.helpers.arrayElement(
282294
filterWordListByLength({
283-
...opts,
295+
...options,
284296
wordList: this.faker.definitions.word.interjection,
285297
})
286298
);
@@ -347,10 +359,13 @@ export class WordModule extends ModuleBase {
347359
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
348360
} = {}
349361
): string {
350-
const opts = typeof options === 'number' ? { length: options } : options;
362+
if (typeof options === 'number') {
363+
options = { length: options };
364+
}
365+
351366
return this.faker.helpers.arrayElement(
352367
filterWordListByLength({
353-
...opts,
368+
...options,
354369
wordList: this.faker.definitions.word.noun,
355370
})
356371
);
@@ -417,10 +432,13 @@ export class WordModule extends ModuleBase {
417432
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
418433
} = {}
419434
): string {
420-
const opts = typeof options === 'number' ? { length: options } : options;
435+
if (typeof options === 'number') {
436+
options = { length: options };
437+
}
438+
421439
return this.faker.helpers.arrayElement(
422440
filterWordListByLength({
423-
...opts,
441+
...options,
424442
wordList: this.faker.definitions.word.preposition,
425443
})
426444
);
@@ -487,10 +505,13 @@ export class WordModule extends ModuleBase {
487505
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
488506
} = {}
489507
): string {
490-
const opts = typeof options === 'number' ? { length: options } : options;
508+
if (typeof options === 'number') {
509+
options = { length: options };
510+
}
511+
491512
return this.faker.helpers.arrayElement(
492513
filterWordListByLength({
493-
...opts,
514+
...options,
494515
wordList: this.faker.definitions.word.verb,
495516
})
496517
);

0 commit comments

Comments
 (0)