Skip to content

Commit

Permalink
fix(sort): SortOptions should extend MatchOptions (#21)
Browse files Browse the repository at this point in the history
* fix(sort): SortOptions should extend MatchOptions

* chore(package): bump to 4.0.1
  • Loading branch information
gjuchault authored Jun 30, 2019
1 parent 2a78316 commit bdf792d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,9 @@ sources.sort(fuzzy('ssjs', { sourceAccessor: source => source.name.foo, idAccess
```ts
const sort: (query: string, options?: SortOptions) => (leftSource: any, rightSource: any) => 0 | 1 | -1

type SortOptions = TestOptions & {
strategy?: ScoreStrategy
sourceAccessor?: (source: any) => string // used as an accessor if array is made of objects
idAccessor?: (source: any) => string // used as an accessor if you want fuzzy to be memoized
type SortOptions = MatchOptions & {
sourceAccessor?: Accessor // used as an accessor if array is made of objects
idAccessor?: Accessor // used as an accessor if you want fuzzy to be memoized
}
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fuzzyjs",
"version": "4.0.0",
"version": "4.0.1",
"description": "Fuzzy matching in Javascript",
"keywords": [
"fuzzy",
Expand Down
6 changes: 2 additions & 4 deletions src/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export type FilterOptions = TestOptions & {
sourceAccessor?: Accessor
}

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

export const sort = (query: string, options: SortOptions = {}) => {
const matchOptions: MatchOptions = {
caseSensitive: options.caseSensitive,
strategy: options.strategy,
...options,
withScore: true
}

Expand Down

0 comments on commit bdf792d

Please sign in to comment.