-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
55 lines (42 loc) · 1.91 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Expression, SequenceExpression } from 'estree';
/** Parse a JavaScript *expression* string and return the resulting abstract syntax tree in the ESTree format */
export function parseExpression(expression: string): Expression | SequenceExpression;
export interface CodegenOptions {
/** A hash of allowed top-level constant values */
constants?: { [cn: string]: string };
/** A function that is given an AST visitor instance as input and returns an object of allowed functions */
functions?: (
astVisitor: any
) => { [fn: string]: string | ((args: any) => string) };
/** An array of variable names that may not be referenced within the expression scope */
forbidden?: string[];
/** An array of variable names that may be referenced within the expression scope */
allowed?: string[];
/** The name of the primary data input argument within the generated expression function */
fieldvar?: string;
/** The name of the variable upon which to lookup global variables */
globalvar: string | ((id: string) => string);
}
/** Create a new output code generator configured according to the provided options */
export function codegenExpression(
options: CodegenOptions
): (
ast: any
) => {
/** The generated code as a string */
code: string;
/** A hash of all properties referenced within the _fieldvar_ scope */
fields: string[];
/** A hash of all properties referenced outside a provided allowed list */
globals: string[];
};
/** An object defining default constant values for the Vega expression language */
export const constants: { [cn: string]: string };
/** Given a *codegen* instance as input, returns an object defining all valid function names for use within an expression */
export function functions(
codegen: any
): {
[fn: string]: string | (() => string);
};
/** Constructor for a node in an expression abstract syntax tree (AST) */
export function ASTNode(type: string): void;