1
0

Merge pull request #26 from rtrvrtg/feature/ts-types

Typescript types
This commit is contained in:
James Pudson
2019-03-06 11:38:45 +08:00
committed by GitHub
12 changed files with 3469 additions and 1 deletions

View File

@@ -114,6 +114,13 @@ 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` 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 in the `docs` directory.
[Browse type documentation here.](docs/README.md)
Documentation is generated using `node_modules/.bin/typedoc index.d.ts`
## Testing ## Testing
The 29 tests are written using the BDD testing framework should.js, and run with mocha. The 29 tests are written using the BDD testing framework should.js, and run with mocha.

11
docs/README.md Normal file
View File

@@ -0,0 +1,11 @@
# search-query-parser
## Index
### External modules
* ["index.d"](modules/_index_d_.md)
---

View File

@@ -0,0 +1,17 @@
[search-query-parser](../README.md) > ["index.d"](../modules/_index_d_.md) > [ISearchParserDictionary](../interfaces/_index_d_.isearchparserdictionary.md)
# Interface: ISearchParserDictionary
## Hierarchy
**ISearchParserDictionary**
↳ [SearchParserResult](_index_d_.searchparserresult.md)
## Indexable
\[key: `string`\]: `any`
## Index
---

View File

@@ -0,0 +1,58 @@
[search-query-parser](../README.md) > ["index.d"](../modules/_index_d_.md) > [SearchParserOffset](../interfaces/_index_d_.searchparseroffset.md)
# Interface: SearchParserOffset
## Hierarchy
**SearchParserOffset**
## Index
### Properties
* [keyword](_index_d_.searchparseroffset.md#keyword)
* [offsetEnd](_index_d_.searchparseroffset.md#offsetend)
* [offsetStart](_index_d_.searchparseroffset.md#offsetstart)
* [value](_index_d_.searchparseroffset.md#value)
---
## Properties
<a id="keyword"></a>
### keyword
**● keyword**: *`string`*
*Defined in [index.d.ts:20](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L20)*
___
<a id="offsetend"></a>
### offsetEnd
**● offsetEnd**: *`number`*
*Defined in [index.d.ts:23](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L23)*
___
<a id="offsetstart"></a>
### offsetStart
**● offsetStart**: *`number`*
*Defined in [index.d.ts:22](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L22)*
___
<a id="value"></a>
### `<Optional>` value
**● value**: *`string`*
*Defined in [index.d.ts:21](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L21)*
___

View File

@@ -0,0 +1,68 @@
[search-query-parser](../README.md) > ["index.d"](../modules/_index_d_.md) > [SearchParserOptions](../interfaces/_index_d_.searchparseroptions.md)
# Interface: SearchParserOptions
## Hierarchy
**SearchParserOptions**
## Index
### Properties
* [alwaysArray](_index_d_.searchparseroptions.md#alwaysarray)
* [keywords](_index_d_.searchparseroptions.md#keywords)
* [offsets](_index_d_.searchparseroptions.md#offsets)
* [ranges](_index_d_.searchparseroptions.md#ranges)
* [tokenize](_index_d_.searchparseroptions.md#tokenize)
---
## Properties
<a id="alwaysarray"></a>
### `<Optional>` alwaysArray
**● alwaysArray**: *`boolean`*
*Defined in [index.d.ts:12](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L12)*
___
<a id="keywords"></a>
### `<Optional>` keywords
**● keywords**: *`string`[]*
*Defined in [index.d.ts:10](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L10)*
___
<a id="offsets"></a>
### `<Optional>` offsets
**● offsets**: *`boolean`*
*Defined in [index.d.ts:8](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L8)*
___
<a id="ranges"></a>
### `<Optional>` ranges
**● ranges**: *`string`[]*
*Defined in [index.d.ts:11](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L11)*
___
<a id="tokenize"></a>
### `<Optional>` tokenize
**● tokenize**: *`boolean`*
*Defined in [index.d.ts:9](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L9)*
___

View File

@@ -0,0 +1,53 @@
[search-query-parser](../README.md) > ["index.d"](../modules/_index_d_.md) > [SearchParserResult](../interfaces/_index_d_.searchparserresult.md)
# Interface: SearchParserResult
## Hierarchy
[ISearchParserDictionary](_index_d_.isearchparserdictionary.md)
**↳ SearchParserResult**
## Indexable
\[key: `string`\]:&nbsp;`any`
## Index
### Properties
* [exclude](_index_d_.searchparserresult.md#exclude)
* [offsets](_index_d_.searchparserresult.md#offsets)
* [text](_index_d_.searchparserresult.md#text)
---
## Properties
<a id="exclude"></a>
### `<Optional>` exclude
**● exclude**: *[ISearchParserDictionary](_index_d_.isearchparserdictionary.md)*
*Defined in [index.d.ts:29](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L29)*
___
<a id="offsets"></a>
### `<Optional>` offsets
**● offsets**: *[SearchParserOffset](_index_d_.searchparseroffset.md)[]*
*Defined in [index.d.ts:28](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L28)*
___
<a id="text"></a>
### `<Optional>` text
**● text**: *`string` \| `string`[]*
*Defined in [index.d.ts:27](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L27)*
___

40
docs/modules/_index_d_.md Normal file
View File

@@ -0,0 +1,40 @@
[search-query-parser](../README.md) > ["index.d"](../modules/_index_d_.md)
# External module: "index.d"
## Index
### Interfaces
* [ISearchParserDictionary](../interfaces/_index_d_.isearchparserdictionary.md)
* [SearchParserOffset](../interfaces/_index_d_.searchparseroffset.md)
* [SearchParserOptions](../interfaces/_index_d_.searchparseroptions.md)
* [SearchParserResult](../interfaces/_index_d_.searchparserresult.md)
### Functions
* [parse](_index_d_.md#parse)
---
## Functions
<a id="parse"></a>
### parse
**parse**(string: *`string`*, options?: *[SearchParserOptions](../interfaces/_index_d_.searchparseroptions.md)*): `string` \| [SearchParserResult](../interfaces/_index_d_.searchparserresult.md)
*Defined in [index.d.ts:32](https://github.com/rtrvrtg/search-query-parser/blob/e4a7ccc/index.d.ts#L32)*
**Parameters:**
| Name | Type |
| ------ | ------ |
| string | `string` |
| `Optional` options | [SearchParserOptions](../interfaces/_index_d_.searchparseroptions.md) |
**Returns:** `string` \| [SearchParserResult](../interfaces/_index_d_.searchparserresult.md)
___

32
index.d.ts vendored Normal file
View File

@@ -0,0 +1,32 @@
// @file
// Type definitions for search-query-parser.
// Project: https://github.com/nepsilon/search-query-parser
// Definitions by: Geoffrey Roberts <g.roberts@blackicemedia.com>
// Definitions: https://github.com/nepsilon/search-query-parser
export interface SearchParserOptions {
offsets?: boolean;
tokenize?: boolean;
keywords?: string[];
ranges?: string[];
alwaysArray?: boolean;
}
export interface ISearchParserDictionary {
[key: string]: any;
}
export interface SearchParserOffset {
keyword: string;
value?: string;
offsetStart: number;
offsetEnd: number;
}
export interface SearchParserResult extends ISearchParserDictionary {
text?: string | string[];
offsets?: SearchParserOffset[];
exclude?: ISearchParserDictionary;
}
export function parse(string: string, options?: SearchParserOptions): string | SearchParserResult;

3151
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,10 @@
}, },
"homepage": "https://github.com/nepsilon/search-query-parser", "homepage": "https://github.com/nepsilon/search-query-parser",
"devDependencies": { "devDependencies": {
"mocha": "*",
"should": "^3.2.0", "should": "^3.2.0",
"mocha": "*" "typedoc": "^0.14.2",
"typedoc-plugin-markdown": "^1.1.27",
"typescript": "^3.3.3333"
} }
} }

25
tsconfig.json Normal file
View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"composite": true,
"sourceMap": true,
"declaration": true,
"declarationMap": true
},
"include": [
"./lib/**/*"
],
"exclude": [],
"typedocOptions": {
"mode": "modules",
"out": "docs",
"include": "./lib",
"exclude": ["./node_modules/**/*"],
"module": "commonjs",
"target": "es5",
"includeDeclarations": true,
"theme": "markdown",
"readme": "none"
}
}

3
tslint.json Normal file
View File

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