diff options
| author | ST-DDT <[email protected]> | 2024-11-21 23:02:39 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-11-21 22:02:39 +0000 |
| commit | 382c034c8bf55db9f64101412c7ec7523a8e86c7 (patch) | |
| tree | 67771395a5f49c8a0557e57b57839c35852ab02d | |
| parent | 4436a77af23b9fdec575dbe447aef8184012ed25 (diff) | |
| download | faker-382c034c8bf55db9f64101412c7ec7523a8e86c7.tar.xz faker-382c034c8bf55db9f64101412c7ec7523a8e86c7.zip | |
chore(word): cleanup word filtering (#3262)
| -rw-r--r-- | src/modules/word/filter-word-list-by-length.ts | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/modules/word/filter-word-list-by-length.ts b/src/modules/word/filter-word-list-by-length.ts index 53522942..6c1b25bf 100644 --- a/src/modules/word/filter-word-list-by-length.ts +++ b/src/modules/word/filter-word-list-by-length.ts @@ -38,12 +38,10 @@ const STRATEGIES = { 'any-length': (wordList: ReadonlyArray<string>): string[] => { return [...wordList]; }, -} as const; /* -satisfies Record< -string, // Parameters<filterWordListByLength>[0]['strategy'] -(wordList: string[], length: { min: number; max: number }) => string[] +} satisfies Record< + NonNullable<Parameters<typeof filterWordListByLength>[0]['strategy']>, + (wordList: string[], length: { min: number; max: number }) => string[] >; -*/ /** * Filters a string array for values with a matching length. @@ -70,7 +68,7 @@ export function filterWordListByLength(options: { }): string[] { const { wordList, length, strategy = 'any-length' } = options; - if (length) { + if (length != null) { const filter: (word: string) => boolean = typeof length === 'number' ? (word) => word.length === length |
