From e193016c3d601c804df44005e679c54b70a705e8 Mon Sep 17 00:00:00 2001 From: Jonas Schade Date: Thu, 28 Sep 2023 13:18:14 +0200 Subject: [PATCH] chore: remove incorrect types --- index.d.ts | 147 --------------------------------------------------- package.json | 2 - 2 files changed, 149 deletions(-) delete mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 031e44c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,147 +0,0 @@ -declare module "flexsearch" { - export interface Index { - readonly id: string; - readonly index: string; - readonly length: number; - - init(options?: CreateOptions): this; - info(): { - id: any; - items: any; - cache: any; - matcher: number; - worker: any; - threshold: any; - depth: any; - resolution: any; - contextual: boolean; - }; - add(o: T): this; - add(id: number, o: string): this; - - // Result without pagination -> T[] - search( - query: string, - options: number | SearchOptions, - callback: (results: T[]) => void - ): void; - search(query: string, options?: number | SearchOptions): Promise; - search( - options: SearchOptions & { query: string }, - callback: (results: T[]) => void - ): void; - search(options: SearchOptions & { query: string }): Promise; - - // Result with pagination -> SearchResults - search( - query: string, - options: number | (SearchOptions & { page?: boolean | Cursor }), - callback: (results: SearchResults) => void - ): void; - search( - query: string, - options?: number | (SearchOptions & { page?: boolean | Cursor }) - ): Promise>; - search( - options: SearchOptions & { query: string; page?: boolean | Cursor }, - callback: (results: SearchResults) => void - ): void; - search( - options: SearchOptions & { query: string; page?: boolean | Cursor } - ): Promise>; - - update(id: number, o: T): this; - remove(id: number): this; - clear(): this; - destroy(): this; - addMatcher(matcher: Matcher): this; - - where(whereObj: { [key: string]: string } | ((o: T) => boolean)): T[]; - encode(str: string): string; - export( - callback: (key: string, data: any) => any, - self?: this, - field?: string, - index_doc?: Number, - index?: Number - ): Promise; - import(exported: string): this; - } - - interface SearchOptions { - limit?: number; - suggest?: boolean; - where?: { [key: string]: string }; - field?: string | string[]; - bool?: "and" | "or" | "not"; - //TODO: Sorting - } - - interface SearchResults { - page?: Cursor; - next?: Cursor; - result: T[]; - } - - interface Document { - id: string; - field: any; - } - - export type CreateOptions = { - profile?: IndexProfile; - tokenize?: DefaultTokenizer | TokenizerFn; - split?: RegExp; - encode?: DefaultEncoder | EncoderFn | false; - cache?: boolean | number; - async?: boolean; - worker?: false | number; - depth?: false | number; - threshold?: false | number; - resolution?: number; - stemmer?: Stemmer | string | false; - filter?: FilterFn | string | false; - rtl?: boolean; - doc?: Document; - }; - - // limit number Sets the limit of results. - // suggest true, false Enables suggestions in results. - // where object Use a where-clause for non-indexed fields. - // field string, Array Sets the document fields which should be searched. When no field is set, all fields will be searched. Custom options per field are also supported. - // bool "and", "or" Sets the used logical operator when searching through multiple fields. - // page true, false, cursor Enables paginated results. - - type IndexProfile = - | "memory" - | "speed" - | "match" - | "score" - | "balance" - | "fast"; - type DefaultTokenizer = "strict" | "forward" | "reverse" | "full"; - type TokenizerFn = (str: string) => string[]; - type DefaultEncoder = "icase" | "simple" | "advanced" | "extra" | "balance"; - type EncoderFn = (str: string) => string; - type Stemmer = { [key: string]: string }; - type Matcher = { [key: string]: string }; - type FilterFn = (str: string) => boolean; - type Cursor = string; - - export default class FlexSearch { - static create(options?: CreateOptions): Index; - static registerMatcher(matcher: Matcher): typeof FlexSearch; - static registerEncoder(name: string, encoder: EncoderFn): typeof FlexSearch; - static registerLanguage( - lang: string, - options: { stemmer?: Stemmer; filter?: string[] } - ): typeof FlexSearch; - static encode(name: string, str: string): string; - } -} - -// FlexSearch.create() -// FlexSearch.registerMatcher({KEY: VALUE}) -// FlexSearch.registerEncoder(name, encoder) -// FlexSearch.registerLanguage(lang, {stemmer:{}, filter:[]}) -// FlexSearch.encode(name, string) diff --git a/package.json b/package.json index a2233be..39a0f88 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "main": "dist/flexsearch.bundle.js", "browser": "dist/flexsearch.bundle.js", "module": "dist/module/index.js", - "types": "./index.d.ts", "preferGlobal": false, "repository": { "type": "git", @@ -50,7 +49,6 @@ "dist/**", "src/**", "task/**", - "index.d.ts", "README.md", "CHANGELOG.md", "LICENSE"