Valuetypetype Value = string | number | boolean | null;A value of a row.
Running (commons lang-sql 0010-aide FR-008): compile turns an expression into a closure (row) => value with the logic of SQL (null where a value is not known, AND and OR with their three values), LIKE with its like-words, and the functions of an environment, and run applies a plan, or the residual of a split, to the rows of an iterable or an async iterable. No code is generated: a closure is composed of closures, so the same module runs on Bun, Node 26 and in a browser.
Valuetypetype Value = string | number | boolean | null;A value of a row.
Rowtypetype Row = Readonly<Record<string, Value>>;A row: values by column name.
Fntypeno test imports ittype Fn = (args: readonly Value[]) => Value;A function of the environment.
Environmentinterfaceno test imports itinterface EnvironmentWhat an expression may use.
| Member | Type | What it is |
|---|---|---|
functions? | ReadonlyMap<string, Fn> | |
params? | readonly Value[] | The values of ? and $n parameters. |
CompileErrorinterfaceno test imports itinterface CompileErrorWhat cannot be compiled.
| Member | Type | What it is |
|---|---|---|
start | number | |
end | number | |
message | string |
likeRegexfunctionno test imports itfunction likeRegex(pattern: string, escape: string | undefined, caseless: boolean): RegExpA SQL LIKE pattern as a regular expression.
globRegexfunctionno test imports itfunction globRegex(pattern: string): RegExpA GLOB pattern (*, ?, [a-z], [!a-z]; * matches any characters, / included) as a regular expression.
BUILTINSconstno test imports itconst BUILTINS: ReadonlyMap<string, Fn>The functions every environment has.
compilefunctionfunction compile(expr: Expr, env?: Environment): Result<(row: Readonly<Record<string, Value>>) => Value, readonly CompileError[]>An expression as a closure over a row; an error value for a construct that is not compiled or a function that is not known.
runfunctionfunction run(plan: Plan, rows: AsyncIterable<Readonly<Record<string, Value>>> | Iterable<Readonly<Record<string, Value>>>, env?: Environment): Promise<Result<readonly Readonly<Record<string, Value>>[], readonly CompileError[]>>Runs a plan over rows (an iterable or an async iterable of rows) and gives the rows it selects; an error value for an expression that is not compiled.