Skip to main content

Module js

Module js 

Source
Expand description

Read plain data out of Dataform JavaScript without running it.

Mirrors kumosql.js_literals: strings, arrays and objects written as literals, the exports of a module, require bindings and loop substitution. Anything computed is reported as computed (JsValue::Expression in lenient parsing, None in strict parsing), never guessed.

Enums§

JsValue
A JavaScript value read from source text.

Functions§

local_constants
Literal const values defined once in this file.
module_exports
What a module offers a require: {"": whole export, "name": member}, literals only.
parse_complete
Like parse_literal, but the literal must end its expression ([...].map(f) is not one).
parse_lenient
Parse a value leniently: comments are skipped, trailing commas and unquoted keys allowed, and anything computed becomes JsValue::Expression. Returns the value and where it ends.
parse_literal
Parse one literal value at byte index (strings, arrays, objects, numbers, booleans, null): (value, end), or None when the value is computed or malformed.
required_bindings
Names this file binds from require: const x = require("m") and const { a, b } = require("m"). A name bound more than once is left out.
resolve_module
The exports of require(spec) from the project-relative file from_file, if known.
source_items
The items a loop ranges over when expression is a literal array, a name in scope or name.member; None when unknown.
strip_comments
text without // and /* */ comments (string contents are left alone).
substitute
config with the loop variable replaced by this item’s literals; None when a member is missing or not a string, or the variable is still used afterwards.