Skip to content

Commit

Permalink
fuse.js: Support $ReadOnlyArray (#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronjensen authored and gantoine committed Jan 5, 2018
1 parent 95b3e05 commit 1064726
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module 'fuse.js' {
declare module "fuse.js" {
declare type FuseOptions = {
caseSensitive?: boolean,
includeScore?: boolean,
Expand All @@ -17,12 +17,12 @@ declare module 'fuse.js' {
getFn?: (obj: any, path: string) => any,
sortFn?: (a: any, b: any) => boolean,
verbose?: boolean,
tokenSeparator?: RegExp,
}
tokenSeparator?: RegExp
};
declare class Fuse<T> {
constructor(items: Array<T>, options?: FuseOptions): Fuse<T>,
search(pattern: string): Array<T>,
setCollection<U: Array<T>>(list: U): U,
constructor(items: Array<T>, options?: FuseOptions): Fuse<T>;
search(pattern: string): Array<T>;
setCollection<U: Array<T>>(list: U): U;
}
declare module.exports: typeof Fuse
declare module.exports: typeof Fuse;
}
28 changes: 28 additions & 0 deletions definitions/npm/fuse.js_v3.x.x/flow_v0.38.x-/fuse.js_v3.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
declare module "fuse.js" {
declare type FuseOptions = {
caseSensitive?: boolean,
includeScore?: boolean,
includeMatches?: boolean,
minMatchCharLength?: number,
shouldSort?: boolean,
tokenize?: boolean,
matchAllTokens?: boolean,
findAllMatches?: boolean,
id?: string,
keys?: $ReadOnlyArray<any>,
location?: number,
threshold?: number,
distance?: number,
maxPatternLength?: number,
getFn?: (obj: any, path: string) => any,
sortFn?: (a: any, b: any) => boolean,
verbose?: boolean,
tokenSeparator?: RegExp
};
declare class Fuse<T> {
constructor(items: $ReadOnlyArray<T>, options?: FuseOptions): Fuse<T>;
search(pattern: string): Array<T>;
setCollection<U: $ReadOnlyArray<T>>(list: U): U;
}
declare module.exports: typeof Fuse;
}
6 changes: 3 additions & 3 deletions definitions/npm/fuse.js_v3.x.x/test_fuse.js_v3.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @flow
import Fuse from 'fuse.js';
import Fuse from "fuse.js";

const fuse: Fuse<number> = Fuse([1, 2]);
fuse.search('foo');
const fuse: Fuse<number> = new Fuse([1, 2]);
fuse.search("foo");

// $ExpectError
const A: number[] = fuse.search(1);
Expand Down

0 comments on commit 1064726

Please sign in to comment.