env_ref.ts

env_ref — a reference to an operator environment variable, for a recipe.

A config declares a reference with zap.env('NAME'). A recipe is a pure function with no builder in hand, so it calls env_ref('NAME') for the same thing: the two return the same string, and a recipe's result drops into a config's resource as the config's own reference would.

The string is a marker — the variable's name between two Unicode noncharacters, behind a fixed mixed-case prefix. The config's builder converts every marked string to a typed reference before the engine reads the config, and the engine resolves it from the operator's environment when the value is used. Until then the string is opaque: it can be interpolated into a template literal or concatenated, and nothing else. A marker that was sliced, split, case-changed, or encoded no longer reads as a reference: the config fails to evaluate when part of the marker survives, and otherwise the result is ordinary text. It never names another variable.

view source

Declarations
#

env_ref
#

env_ref.ts view source

(name: string): string import {env_ref} from '@fuzdev/zap/env_ref.js';

A reference to the operator environment variable name, as a string a recipe places in a field that takes a reference — whole, interpolated, or concatenated.

name

the variable's name: a letter or _, then letters, digits, or _

type string

returns

string

the marked string zap.env(name) returns

throws

  • Error - if `name` is not an environment variable's name

Imported by
#