From 6d4653c7c4029d286eff04cd98c883e5adea220d Mon Sep 17 00:00:00 2001 From: Jason Killian Date: Thu, 25 Aug 2016 14:09:15 -0400 Subject: [PATCH] fuzzaldrin-plus typings --- fuzzaldrin-plus/fuzzaldrin-plus-tests.ts | 20 ++++++++++++++++ fuzzaldrin-plus/index.d.ts | 29 ++++++++++++++++++++++++ fuzzaldrin-plus/tsconfig.json | 19 ++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 fuzzaldrin-plus/fuzzaldrin-plus-tests.ts create mode 100644 fuzzaldrin-plus/index.d.ts create mode 100644 fuzzaldrin-plus/tsconfig.json diff --git a/fuzzaldrin-plus/fuzzaldrin-plus-tests.ts b/fuzzaldrin-plus/fuzzaldrin-plus-tests.ts new file mode 100644 index 0000000000..97730fe2e5 --- /dev/null +++ b/fuzzaldrin-plus/fuzzaldrin-plus-tests.ts @@ -0,0 +1,20 @@ +import * as fz from "fuzzaldrin-plus"; + +const candidates = [ + 'Find And Replace: Select All', + 'Settings View: Uninstall Packages', + 'Settings View: View Installed Themes', + 'Application: Install Update', + 'Install' +] +const objectCandidates = candidates.map(s => ({ foo: s })); + +fz.filter(candidates, 'install'); +fz.filter(objectCandidates, 'install', { key: 'foo' }); + +const prepQuery = fz.prepQuery('install'); +fz.score('Application: Install Update', 'install'); +fz.score('Application: Install Update', 'install', prepQuery); + +fz.match('Application: Install Update', 'install'); +fz.match('Application: Install Update', 'install', prepQuery); diff --git a/fuzzaldrin-plus/index.d.ts b/fuzzaldrin-plus/index.d.ts new file mode 100644 index 0000000000..34d6949ace --- /dev/null +++ b/fuzzaldrin-plus/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for fuzzaldrin-plus +// Project: https://github.com/jeancroy/fuzzaldrin-plus/ +// Definitions by: Jean Christophe Roy , Jason Killian +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace fuzzaldrin; + +export interface IQueryOptions { + pathSeparator?: string; + optCharRegEx?: RegExp; +} + +export interface IScoringOptions extends IQueryOptions { + allowErrors?: boolean; + isPath?: boolean; + useExtensionBonus?: boolean; +} + +export interface IFilterOptions extends IScoringOptions { + key?: string; + maxResults?: number; +} + +export type PreparedQuery = { __internalAPIBrand: string; }; + +export function filter(data: T[], query: string, options?: IFilterOptions): T[]; +export function score(str: string, query: string, preparedQuery?: PreparedQuery, options?: IScoringOptions): number; +export function match(str: string, query: string, preparedQuery?: PreparedQuery, options?: IScoringOptions): number[]; +export function prepQuery(query: string, options?: IQueryOptions): PreparedQuery; diff --git a/fuzzaldrin-plus/tsconfig.json b/fuzzaldrin-plus/tsconfig.json new file mode 100644 index 0000000000..ce458c2f00 --- /dev/null +++ b/fuzzaldrin-plus/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "fuzzaldrin-plus-tests.ts" + ] +}