Skip to content

Commit

Permalink
Merge aa814ef into 9648316
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaong committed Jul 22, 2019
2 parents 9648316 + aa814ef commit 57be7da
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 2 deletions.
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -40,6 +40,7 @@
"regenerator-runtime": "^0.13.1",
"snazzy": "^8.0.0",
"standard": "^12.0.1",
"typescript": "^3.5.3",
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0",
"webpack-merge": "^4.2.1"
Expand All @@ -65,5 +66,6 @@
"lint": "standard --verbose 'app/**/*.{js,jsx}' | snazzy",
"lintfix": "standard --fix 'app/**/*.{js,jsx}'",
"prepublishOnly": "yarn test && yarn build"
}
},
"typings": "./src/index.d.ts"
}
80 changes: 80 additions & 0 deletions src/index.d.ts
@@ -0,0 +1,80 @@
// Type definitions for MiniSearch

export as namespace MiniSearch;
export = MiniSearch;

declare class MiniSearch {
constructor(options: object);

documentCount: number;

add(document: object): void;

addAll(documents: object[]): void;

addAllAsync(documents: object[], options: { chunkSize?: number }): Promise<undefined>;

autoSuggest(query: string, options: SearchOptions): Suggestion[];

remove(document: object): void;

search(query: string, options: SearchOptions): SearchResult[];

toJSON(): object;

static getDefault(optionName: string): any;

static loadJSON(json: string, options: Options): MiniSearch;
}

interface SearchOptions {
fields?: string[],

boost?: { [fieldName: string]: number },

prefix?: boolean
| ((term: string, index: number, terms: string[]) => boolean),

fuzzy?: boolean
| ((term: string, index: number, terms: string[]) => boolean | number),

combineWith?: string,

extractField?: (document: object, fieldName: string) => string,

tokenize?: (text: string) => string[],

processTerm?: (term: string) => string | null | undefined | false
}

interface Options {
fields: string[],

idField?: string,

extractField?: (document: object, fieldName: string) => string,

tokenize?: (text: string, fieldName: string) => string[],

processTerm?: (term: string, fieldName: string) => string | null | undefined | false,

searchOptions?: SearchOptions
}

interface Suggestion {
suggestion: string,

score: number
}

interface MatchInfo {
[term: string]: string[]
}

interface SearchResult {
id: any,

score: number,

match: MatchInfo
}
2 changes: 1 addition & 1 deletion src/index.js
@@ -1,3 +1,3 @@
import MiniSearch from './MiniSearch.js'

export default MiniSearch
export default MiniSearch
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -6574,6 +6574,11 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@^3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==

uglify-js@^3.1.4:
version "3.6.0"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5"
Expand Down

0 comments on commit 57be7da

Please sign in to comment.