From 1ea7f265388b2254fac76f54846b94e0a2c202ea Mon Sep 17 00:00:00 2001 From: Take Weiland Date: Wed, 15 Sep 2021 17:10:22 +0200 Subject: [PATCH 1/2] feat: allow ReadonlyArray as input --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index b5e4dbb..66118da 100644 --- a/src/index.ts +++ b/src/index.ts @@ -82,7 +82,7 @@ const defaultBaseSortFn: BaseSorter = (a, b) => * @return {Array} - the new sorted array */ function matchSorter( - items: Array, + items: ReadonlyArray, value: string, options: MatchSorterOptions = {}, ): Array { From 3a49b4391ba40515d7a9e83b56b458d7097b4b62 Mon Sep 17 00:00:00 2001 From: Take Weiland Date: Wed, 15 Sep 2021 17:17:14 +0200 Subject: [PATCH 2/2] feat: allow ReadonlyArray for keys option --- src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 66118da..7a20218 100644 --- a/src/index.ts +++ b/src/index.ts @@ -48,7 +48,7 @@ type KeyOption = | string interface MatchSorterOptions { - keys?: Array> + keys?: ReadonlyArray> threshold?: Ranking baseSort?: BaseSorter keepDiacritics?: boolean @@ -120,7 +120,7 @@ function matchSorter( */ function getHighestRanking( item: ItemType, - keys: Array> | undefined, + keys: ReadonlyArray> | undefined, value: string, options: MatchSorterOptions, ): RankingInfo { @@ -445,7 +445,7 @@ function getNestedValues( */ function getAllValuesToRank( item: ItemType, - keys: Array>, + keys: ReadonlyArray>, ) { const allValues: Array<{itemValue: string; attributes: KeyAttributes}> = [] for (let j = 0, J = keys.length; j < J; j++) {