diff --git a/README.md b/README.md index d56b9fe..cb3fb66 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,10 @@ var parsedQueryWithOptions = searchQuery.parse(query, options); The offsets object could become pretty huge with long search queries which could be an unnecessary use of space if no functionality depends on it. It can simply be turned off using the option `offsets: false` +## Typescript + +Typescript types are available for this library. + ## Testing The 29 tests are written using the BDD testing framework should.js, and run with mocha. diff --git a/index.d.ts b/index.d.ts index 0d00b01..b545a83 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,26 +1,34 @@ -export interface SearchParserOptions { - offsets?: boolean; - tokenize?: boolean; - keywords?: string[]; - ranges?: string[]; - alwaysArray?: boolean; -} +// @file +// Type definitions for search-query-parser. +// Project: https://github.com/nepsilon/search-query-parser +// Definitions by: Geoffrey Roberts +// Definitions: https://github.com/nepsilon/search-query-parser -export interface ISearchParserDictionary { - [key: string]: any; -} +export module SearchQueryParser { + export interface SearchParserOptions { + offsets?: boolean; + tokenize?: boolean; + keywords?: string[]; + ranges?: string[]; + alwaysArray?: boolean; + } -export interface SearchParserOffset { - keyword: string; - value?: string; - offsetStart: number; - offsetEnd: number; -} + export interface ISearchParserDictionary { + [key: string]: any; + } -export interface SearchParserResult extends ISearchParserDictionary { - text?: string | string[]; - offsets?: SearchParserOffset[]; - exclude?: ISearchParserDictionary; -} + export interface SearchParserOffset { + keyword: string; + value?: string; + offsetStart: number; + offsetEnd: number; + } -export function parse(string: string, options?: SearchParserOptions): string | SearchParserResult; + export interface SearchParserResult extends ISearchParserDictionary { + text?: string | string[]; + offsets?: SearchParserOffset[]; + exclude?: ISearchParserDictionary; + } + + export function parse(string: string, options?: SearchParserOptions): string | SearchParserResult; +}