mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Changed the Namespace to Standard format (To upper case) * Added generic type parameters for Fuse * Added Export Statements to work with System Js setup * Added test to varify generic parameters
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
// Type definitions for Fuse.js 2.5.0
|
|
// Project: https://github.com/krisk/Fuse
|
|
// Definitions by: Greg Smith <https://github.com/smrq/>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
declare class Fuse<T> {
|
|
constructor(list: T[], options?: Fuse.Options<T>);
|
|
search(pattern: string): T[];
|
|
}
|
|
|
|
declare namespace Fuse {
|
|
interface SearchFnConstructor {
|
|
new (pattern: string, options?: SearchOptions): SearchFn;
|
|
}
|
|
|
|
interface SearchFn {
|
|
search(text: string): SearchResult;
|
|
}
|
|
|
|
interface SearchResult {
|
|
readonly isMatch: boolean;
|
|
readonly score: number;
|
|
}
|
|
|
|
interface SearchOptions {
|
|
location?: number;
|
|
distance?: number;
|
|
threshold?: number;
|
|
maxPatternLength?: number;
|
|
}
|
|
|
|
interface Options<T> {
|
|
id?: string;
|
|
caseSensitive?: boolean;
|
|
include?: string[];
|
|
shouldSort?: boolean;
|
|
searchFn?: SearchFnConstructor;
|
|
sortFn?: (a: {score: number}, b: {score: number}) => number;
|
|
keys?: string[] | { name:string; weight:number} [];
|
|
verbose?:boolean;
|
|
tokenize?: boolean;
|
|
tokenSeparator? : RegExp;
|
|
matchAllTokens?: boolean;
|
|
location?: number;
|
|
distance?: number;
|
|
threshold?: number;
|
|
maxPatternLength?: number;
|
|
includeScore?: boolean;
|
|
getFn?: (obj: T, path: string) => string;
|
|
}
|
|
}
|
|
|
|
export = Fuse;
|
|
export as namespace Fuse;
|