aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2024-11-21 23:02:39 +0100
committerGitHub <[email protected]>2024-11-21 22:02:39 +0000
commit382c034c8bf55db9f64101412c7ec7523a8e86c7 (patch)
tree67771395a5f49c8a0557e57b57839c35852ab02d /src/modules
parent4436a77af23b9fdec575dbe447aef8184012ed25 (diff)
downloadfaker-382c034c8bf55db9f64101412c7ec7523a8e86c7.tar.xz
faker-382c034c8bf55db9f64101412c7ec7523a8e86c7.zip
chore(word): cleanup word filtering (#3262)
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/word/filter-word-list-by-length.ts10
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