UNPKG

713 BTypeScriptView Raw
1// TypeScript Version: 3.0
2
3export interface ASTNode {
4 type: 'root' | 'bracket';
5 nodes: ASTNode[];
6 stash: string[];
7}
8
9export interface State {
10 input: string;
11 separator: string;
12 stack: ASTNode[];
13 bos(): boolean;
14 eos(): boolean;
15 prev(): string;
16 next(): string;
17}
18
19export interface Options {
20 brackets?: { [key: string]: string } | boolean;
21 quotes?: string[] | boolean;
22 separator?: string;
23 strict?: boolean;
24 keep?(value: string, state: State): boolean;
25}
26
27type SplitFunc = (state: State) => boolean;
28
29declare function split(input: string, options?: Options | SplitFunc): string[];
30declare function split(input: string, options: Options, fn: SplitFunc): string[];
31
32export default split;