Skip to content

Commit

Permalink
chore: align coding style of word module
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Dec 3, 2024
1 parent ecb5cb4 commit 989fb82
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions src/modules/word/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
);
Expand Down Expand Up @@ -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,
})
);
Expand Down Expand Up @@ -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,
})
);
Expand Down Expand Up @@ -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,
})
);
Expand Down Expand Up @@ -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,
})
);
Expand Down Expand Up @@ -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,
})
);
Expand Down Expand Up @@ -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,
})
);
Expand Down

0 comments on commit 989fb82

Please # to comment.