-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.d.mts
More file actions
41 lines (33 loc) · 1.05 KB
/
Copy pathindex.d.mts
File metadata and controls
41 lines (33 loc) · 1.05 KB
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
// ESM declarations. Mirror of index.d.ts (the CommonJS `export =` form), but
// expressed as native ES module exports so `import { LogicalCompilerError }`
// and `import type { Expression } from 'logical-compiler'` type-check.
// Keep in sync with index.d.ts.
export type Callback = () => boolean | Promise<boolean>;
export type Fn = (...args: any[]) => boolean | Promise<boolean>;
export type Expression =
| boolean
| Callback
| { $and: Expression[] }
| { $or: Expression[] }
| { $nor: Expression[] }
| { $not: Expression }
| { [fn: string]: any };
export interface Options {
fns?: Record<string, Fn>;
}
export type ErrorCode =
| 'UNRECOGNIZED_OPERATOR'
| 'UNDEFINED_FUNCTION'
| 'UNEXPECTED_TOKEN'
| 'UNEXPECTED_RETURN_TYPE'
| 'EXPECTED_EXPRESSION';
export declare class LogicalCompilerError extends Error {
constructor(message: string, code: ErrorCode);
name: 'LogicalCompilerError';
code: ErrorCode;
}
declare function compile(
expression: Expression,
options?: Options,
): boolean | Promise<boolean>;
export default compile;