Add @types/frecency (#35742)

* add @types/frecency

* update
This commit is contained in:
swyx 2019-05-28 17:27:19 -04:00 committed by Sheetal Nandi
parent 4e081f6fc7
commit 32d0440d31
3 changed files with 45 additions and 0 deletions

28
types/frecency/index.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
// Type definitions for frecency 1.3
// Project: https://github.com/mixmaxhq/frecency#readme
// Definitions by: swyx <https://github.com/sw-yx>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
export type idAttrFn = (result: string) => string;
export default class Frecency<T = any> {
constructor(constructOpts: {
key: string;
idAttribute?: string | idAttrFn;
timeStampsLimit?: number;
recentSelectionsLimit?: number;
storageProvider?: object;
exactQueryMatchWeight?: number;
subQueryMatchWeight?: number;
recentSelectionsMatchWeight?: number;
});
save: (arg: { searchQuery: T; selectedId: string }) => void;
sort:
| ((arg: { searchQuery: T; searchResults: T[] }) => T[])
| ((arg: {
searchQuery: T;
searchResults: T[];
keepScores?: boolean;
}) => Array<T & { _frecencyScore?: number }>);
}

View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts"]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }