diff options
| author | ST-DDT <[email protected]> | 2024-12-09 23:37:53 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-12-09 23:37:53 +0100 |
| commit | ea7900ded55d05c683d52c7a2d7e4c009ae83695 (patch) | |
| tree | ee4670724d8d2592e8982d1ec722903952e5a09f /src/modules | |
| parent | 99b9c3df849ba4083b27ecf90a95301f5e09fd7f (diff) | |
| download | faker-ea7900ded55d05c683d52c7a2d7e4c009ae83695.tar.xz faker-ea7900ded55d05c683d52c7a2d7e4c009ae83695.zip | |
chore: align coding style of word module (#3319)
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/word/index.ts | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/src/modules/word/index.ts b/src/modules/word/index.ts index ce46210b..6713eec0 100644 --- a/src/modules/word/index.ts +++ b/src/modules/word/index.ts @@ -67,10 +67,13 @@ export class WordModule extends ModuleBase { strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length'; } = {} ): string { - const opts = typeof options === 'number' ? { length: options } : options; + if (typeof options === 'number') { + options = { length: options }; + } + return this.faker.helpers.arrayElement( filterWordListByLength({ - ...opts, + ...options, wordList: this.faker.definitions.word.adjective, }) ); @@ -137,10 +140,13 @@ export class WordModule extends ModuleBase { strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length'; } = {} ): string { - const opts = typeof options === 'number' ? { length: options } : options; + if (typeof options === 'number') { + options = { length: options }; + } + return this.faker.helpers.arrayElement( filterWordListByLength({ - ...opts, + ...options, wordList: this.faker.definitions.word.adverb, }) ); @@ -207,10 +213,13 @@ export class WordModule extends ModuleBase { strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length'; } = {} ): string { - const opts = typeof options === 'number' ? { length: options } : options; + if (typeof options === 'number') { + options = { length: options }; + } + return this.faker.helpers.arrayElement( filterWordListByLength({ - ...opts, + ...options, wordList: this.faker.definitions.word.conjunction, }) ); @@ -277,10 +286,13 @@ export class WordModule extends ModuleBase { strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length'; } = {} ): string { - const opts = typeof options === 'number' ? { length: options } : options; + if (typeof options === 'number') { + options = { length: options }; + } + return this.faker.helpers.arrayElement( filterWordListByLength({ - ...opts, + ...options, wordList: this.faker.definitions.word.interjection, }) ); @@ -347,10 +359,13 @@ export class WordModule extends ModuleBase { strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length'; } = {} ): string { - const opts = typeof options === 'number' ? { length: options } : options; + if (typeof options === 'number') { + options = { length: options }; + } + return this.faker.helpers.arrayElement( filterWordListByLength({ - ...opts, + ...options, wordList: this.faker.definitions.word.noun, }) ); @@ -417,10 +432,13 @@ export class WordModule extends ModuleBase { strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length'; } = {} ): string { - const opts = typeof options === 'number' ? { length: options } : options; + if (typeof options === 'number') { + options = { length: options }; + } + return this.faker.helpers.arrayElement( filterWordListByLength({ - ...opts, + ...options, wordList: this.faker.definitions.word.preposition, }) ); @@ -487,10 +505,13 @@ export class WordModule extends ModuleBase { strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length'; } = {} ): string { - const opts = typeof options === 'number' ? { length: options } : options; + if (typeof options === 'number') { + options = { length: options }; + } + return this.faker.helpers.arrayElement( filterWordListByLength({ - ...opts, + ...options, wordList: this.faker.definitions.word.verb, }) ); |
