From 6ed7e1c87a6593d96d516f008d8ea543abd72827 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Thu, 14 Nov 2024 12:39:53 +0100 Subject: [PATCH] chore(word): cleanup word filtering --- src/modules/word/filter-word-list-by-length.ts | 10 ++++------ 1 file 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 5352294205b..6c1b25bf39d 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[] => { return [...wordList]; }, -} as const; /* -satisfies Record< -string, // Parameters[0]['strategy'] -(wordList: string[], length: { min: number; max: number }) => string[] +} satisfies Record< + NonNullable[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