From 9b31503785304a6c3ae521f84a39cf4162eb231d Mon Sep 17 00:00:00 2001 From: bent10 Date: Fri, 29 Apr 2022 23:24:42 +0700 Subject: [PATCH] feat(types): accepts `readonly string[]` for `candidates` param --- dist/index.d.ts | 4 ++-- src/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index 5cf4165..6790ba1 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -53,7 +53,7 @@ export declare type Options = { * @param options - Options for the function. * @returns An array of similar words. */ -export declare function findSimilar(word: string, candidates: string[], options?: Options): string[]; +export declare function findSimilar(word: string, candidates: readonly string[] | string[], options?: Options): string[]; /** * Suggests similar words in a list of words. * @@ -62,4 +62,4 @@ export declare function findSimilar(word: string, candidates: string[], options? * @param options - Options for the function. * @returns A string of suggested words. */ -export declare function didYouMean(word: string, candidates: string[], options?: Options): string; +export declare function didYouMean(word: string, candidates: readonly string[] | string[], options?: Options): string; diff --git a/src/index.ts b/src/index.ts index 33be1a7..a4e4134 100644 --- a/src/index.ts +++ b/src/index.ts @@ -61,7 +61,7 @@ export type Options = { */ export function findSimilar( word: string, - candidates: string[], + candidates: readonly string[] | string[], options: Options = {} ) { let { maxScore = 3 } = options @@ -96,7 +96,7 @@ export function findSimilar( */ export function didYouMean( word: string, - candidates: string[], + candidates: readonly string[] | string[], options: Options = {} ) { const matches = findSimilar(word, candidates, options)