Skip to content

Commit bdf792d

Browse files
authored
fix(sort): SortOptions should extend MatchOptions (#21)
* fix(sort): SortOptions should extend MatchOptions * chore(package): bump to 4.0.1
1 parent 2a78316 commit bdf792d

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,9 @@ sources.sort(fuzzy('ssjs', { sourceAccessor: source => source.name.foo, idAccess
166166
```ts
167167
const sort: (query: string, options?: SortOptions) => (leftSource: any, rightSource: any) => 0 | 1 | -1
168168

169-
type SortOptions = TestOptions & {
170-
strategy?: ScoreStrategy
171-
sourceAccessor?: (source: any) => string // used as an accessor if array is made of objects
172-
idAccessor?: (source: any) => string // used as an accessor if you want fuzzy to be memoized
169+
type SortOptions = MatchOptions & {
170+
sourceAccessor?: Accessor // used as an accessor if array is made of objects
171+
idAccessor?: Accessor // used as an accessor if you want fuzzy to be memoized
173172
}
174173
```
175174

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fuzzyjs",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "Fuzzy matching in Javascript",
55
"keywords": [
66
"fuzzy",

src/array.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ export type FilterOptions = TestOptions & {
77
sourceAccessor?: Accessor
88
}
99

10-
export type SortOptions = TestOptions & {
11-
strategy?: ScoreStrategy
10+
export type SortOptions = MatchOptions & {
1211
sourceAccessor?: Accessor
1312
idAccessor?: Accessor
1413
}
@@ -22,8 +21,7 @@ export const filter = (query: string, options: FilterOptions = {}) => (source: a
2221

2322
export const sort = (query: string, options: SortOptions = {}) => {
2423
const matchOptions: MatchOptions = {
25-
caseSensitive: options.caseSensitive,
26-
strategy: options.strategy,
24+
...options,
2725
withScore: true
2826
}
2927

0 commit comments

Comments
 (0)