@promptctl/go-template-js 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -8
- package/dist/index.d.ts +136 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2157 -264
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -125,6 +125,7 @@ Supported:
|
|
|
125
125
|
|
|
126
126
|
- All actions: `{{ pipeline }}`, `{{- ... -}}` trim markers, `{{/* comments */}}`.
|
|
127
127
|
- All control flow: `if/else if/else/end`, `range/else/end` (with index/value forms `range $i, $v := …`), `with/else/end`.
|
|
128
|
+
- Range-body control: `{{break}}` exits the innermost `{{range}}`; `{{continue}}` skips to its next iteration. Both are parse errors outside a lexically-enclosing `{{range}}` (including inside a `{{define}}` or `{{block}}` body, even if those are nested in a range — sub-template bodies are independent parse contexts, matching Go's `text/template`).
|
|
128
129
|
- All sub-template forms: `define`, `template`, `block`.
|
|
129
130
|
- Variable assignment: `$x := pipe` and `$x = pipe`.
|
|
130
131
|
- All literals: strings (interpreted + raw backtick), runes, integers (decimal/hex/octal/binary), floats (with exponents and hex-float `p` exponents), booleans, `nil`.
|
|
@@ -135,9 +136,9 @@ Supported:
|
|
|
135
136
|
|
|
136
137
|
All of Go template's runtime built-ins:
|
|
137
138
|
|
|
138
|
-
`and` `or` `not` · `eq` `ne` `lt` `le` `gt` `ge` · `len` `index` `slice` · `print` `println` `printf` · `call`
|
|
139
|
+
`and` `or` `not` · `eq` `ne` `lt` `le` `gt` `ge` · `len` `index` `slice` · `print` `println` `printf` · `call` · `html` · `js` · `urlquery`
|
|
139
140
|
|
|
140
|
-
`and`/`or` short-circuit (the engine passes thunks for those). `printf` supports `%s`, `%d`, `%v`, `%q`, `%f` (precision-aware), `%t`, `%x`, plus width and `-` left-align flags.
|
|
141
|
+
`and`/`or` short-circuit (the engine passes thunks for those). `printf` supports `%s`, `%d`, `%v`, `%q`, `%f` (precision-aware), `%t`, `%x`, plus width and `-` left-align flags. `html` flattens its arguments like `print` (via the engine's `toString`) and then escapes the six HTML-significant characters (`\0` → `�`, `"` → `"`, `'` → `'`, `&` → `&`, `<` → `<`, `>` → `>`) — matching Go's `text/template.HTMLEscaper` byte-for-byte. `js` shares the same flatten pipeline and emits JavaScript-literal-safe output: `\` → `\\`, `'` → `\'`, `"` → `\"`, `<` → `\u003C`, `>` → `\u003E`, `&` → `\u0026`, `=` → `\u003D`, ASCII control chars (< 0x20) and non-printable runes (incl. U+2028/U+2029) → `\u%04X` uppercase — matching Go's `text/template.JSEscaper`. `urlquery` shares the same flatten pipeline and percent-encodes the UTF-8 byte stream per Go's `net/url.QueryEscape`: the unreserved set `[A-Za-z0-9-._~]` passes through, space becomes `+`, every other byte becomes `%XX` uppercase hex (so a literal `+` round-trips as `%2B`, and `α` encodes to `%CE%B1`).
|
|
141
142
|
|
|
142
143
|
### Sprig subset
|
|
143
144
|
|
|
@@ -147,12 +148,21 @@ Imported from `@promptctl/go-template-js` as category-scoped `FuncMap` factories
|
|
|
147
148
|
| --- | --- | --- |
|
|
148
149
|
| Defaults | `sprigDefaults()` | default, empty, coalesce, ternary, fromJson, toJson, toPrettyJson |
|
|
149
150
|
| Strings | `sprigStrings()` | trim, trimAll, trimPrefix, trimSuffix, upper, lower, title, untitle, repeat, substr, trunc, contains, hasPrefix, hasSuffix, replace, split, splitList, splitn, join, quote, squote, cat, indent, nindent, wrap, wrapWith, abbrev, abbrevboth, initials, nospace, snakecase, camelcase, kebabcase, swapcase, plural, regexQuoteMeta |
|
|
150
|
-
| Math | `sprigMath()` | add, sub, mul, div, mod, min, max, floor, ceil, round, addf, subf, mulf, divf |
|
|
151
|
-
| Lists | `sprigLists()` | list, first, last, rest, initial, len, reverse, uniq, without, has, compact, slice, concat, chunk, prepend, append |
|
|
151
|
+
| Math | `sprigMath()` | add, sub, mul, div, mod, min, max, floor, ceil, round, addf, subf, mulf, divf, add1, add1f, maxf, minf, biggest, seq, until, untilStep |
|
|
152
|
+
| Lists | `sprigLists()` | list, first, last, rest, initial, len, reverse, uniq, without, has, compact, slice, concat, chunk, prepend, append, sortAlpha, push, tuple, dig, all, any |
|
|
152
153
|
| Dicts | `sprigDicts()` | dict, get, set, unset, keys, values, pluck, pick, omit, hasKey, merge, mergeOverwrite |
|
|
153
154
|
| Regex | `sprigRegex()` | regexMatch, regexFind, regexFindAll, regexReplaceAll, regexReplaceAllLiteral, regexSplit |
|
|
154
155
|
| Types | `sprigTypes()` | kindOf, kindIs, typeOf, typeIs, typeIsLike, deepEqual, deepCopy |
|
|
155
156
|
| Conversions | `sprigConversions()` | atoi, int, int64, float64, toString, toStrings, toDecimal, toRawJson |
|
|
157
|
+
| Semver | `sprigSemver()` | semver, semverCompare |
|
|
158
|
+
| Flow | `sprigFlow()` | fail |
|
|
159
|
+
| Random | `sprigRandom(random?)` | randInt, randAlpha, randAlphaNum, randNumeric, randAscii, shuffle |
|
|
160
|
+
| Hash / Encoding | `sprigHash()` | b64enc, b64dec, b32enc, b32dec, sha1sum, sha256sum, sha512sum, adler32sum, uuidv4 |
|
|
161
|
+
| Date / Time | `sprigDatetime(clock?)` | now, date, dateInZone, dateModify, htmlDate, htmlDateInZone, duration, durationRound, toDate, ago, unixEpoch |
|
|
162
|
+
|
|
163
|
+
**Runtime floor for `sprigHash()`:** This package requires Node ≥ 20.19.0 (per `engines.node`). `uuidv4` requires `globalThis.crypto.randomUUID`, guaranteed in that environment. SHA-* use [`@noble/hashes`](https://github.com/paulmillr/noble-hashes) — audited, zero-dep, sync, pure JS.
|
|
164
|
+
|
|
165
|
+
**`sprigDatetime(clock?)`:** All date/time functions accept Go's reference-time format strings (`Mon Jan 2 15:04:05 MST 2006`). Pass `clock: () => Date` to freeze "now" for deterministic templates. The `date` and `dateInZone` functions accept `Date`, number (Unix seconds), or string as the time value. Go template integer literals hit sprig's type-switch default branch (returning `"0s"` from `duration`) — prefer string literals or scope-injected values for portable templates.
|
|
156
166
|
|
|
157
167
|
## Composing funcs from multiple sources
|
|
158
168
|
|
|
@@ -178,13 +188,16 @@ The engine matches Go's `text/template` semantics aggressively. The remaining di
|
|
|
178
188
|
- **Numeric typing.** Go has `int`, `float64`, and friends as distinct runtime types; JavaScript has one `number`. The numeric-verb type label reflects JS's view: integer JS numbers report as `int`, fractional as `float64`, `bigint` as `int64`. Non-numeric values into `%d`/`%f`/`%x` produce a Go-style `%!<verb>(<type>=<value>)` diagnostic — e.g. `printf "%d" "foo"` → `%!d(string=foo)`.
|
|
179
189
|
- **Regex semantics.** `sprigRegex()` uses ECMAScript regex, not Go's RE2. Lookbehind syntax, Unicode property escapes, and certain catastrophic-backtracking patterns differ.
|
|
180
190
|
- **String length.** Go strings are UTF-8 byte sequences; `len("é")` is `2` in Go. JS strings are UTF-16 code units; `len("é")` is `1` here. Choose grapheme libraries on the JS side if you need byte/grapheme counts.
|
|
181
|
-
- **Field access.** Walks JS objects, Maps, and arrays using JS property semantics, not Go reflection. Named-field access on an array is a `MissingFieldError`
|
|
191
|
+
- **Field access.** Walks JS objects, Maps, and arrays using JS property semantics, not Go reflection. Named-field access on an array is a missing field — silently `<no value>` under the default `missingKey: "default"` policy, or a `MissingFieldError` under `missingKey: "error"`. There is no `length` / `[N]` magic; use the `index` and `len` built-ins.
|
|
192
|
+
- **`missingkey=zero`.** Accepted as a config value (`missingKey: "zero"`) for API parity with Go's `Option("missingkey=zero")`, but JavaScript erases value-types at runtime — there is no `reflect.New(elemType).Elem()` analogue, so `"zero"` produces the same observable behavior as `"default"` (silent `<no value>`). To force a typed-zero substitute at the use site, use sprig: `{{ .missing | default "" }}`.
|
|
182
193
|
- **Type mismatches at function boundaries are runtime errors, not compile errors.** By design: the engine does not know your `T` shape statically, so it surfaces the architectural commitment when the bad flow happens. See `TypeMismatchError`.
|
|
183
194
|
- **printf verbs** beyond `%s %d %v %q %f %t %x` are rendered as `%!<verb>(<type>=<value>)`. If you need more, register your own formatter via the `funcs` registry.
|
|
184
195
|
|
|
185
196
|
Notable parity statements (places where users sometimes expect divergence and there isn't one):
|
|
186
197
|
|
|
187
198
|
- A nil/undefined pipeline emits the literal `<no value>` string, matching Go's `text/template`.
|
|
199
|
+
- **Missing field/map-key access** follows Go's `Option("missingkey=...")`. Defaults to `"default"` (silent `<no value>`); set `missingKey: "error"` in `EngineConfig` to throw `MissingFieldError` instead. The `"zero"` value is accepted; see the divergence note above.
|
|
200
|
+
- **Custom delimiters** are supported via `EngineConfig.delims`, mirroring Go's `Template.Delims(left, right)`. Pass `{ left: "<%", right: "%>" }` to make the engine recognise `<% ... %>` actions instead of `{{ ... }}`. Trim markers follow Go: with `<%`/`%>` they become `<%-` and `-%>`. Both sides are required if you set the field — neither may be empty. Default `{{` / `}}` are used when the field is omitted.
|
|
188
201
|
- Range over a Map / plain object iterates in **sorted-by-key order** in both engines (Go's `internal/fmtsort`; ours mirrors it).
|
|
189
202
|
- Sprig `set` and `unset` mutate the receiver and return it — same as Go sprig.
|
|
190
203
|
- `{{ "key" | get .dict }}` composes correctly: last-arg piping puts the key in the trailing slot, which is `get(d, key)`'s second parameter. The form `{{ .dict | get "key" }}` does *not* work in either engine — the dict ends up in the key slot.
|
|
@@ -219,9 +232,9 @@ Every error carries `pos`, `source`, and a `kind` discriminator. `.toString()` p
|
|
|
219
232
|
|
|
220
233
|
The package exports exactly the following from `"@promptctl/go-template-js"` — anything else is internal and may change at any time:
|
|
221
234
|
|
|
222
|
-
- Engine: `createEngine`, `Engine`, `Template`, `EngineConfig`, `FuncMap`, `TemplateFunc`, `ArgType`.
|
|
223
|
-
- Errors: `TemplateError`, `ParseError`, `EvalError`, `FuncNotFoundError`, `TypeMismatchError`, `MissingFieldError`, `ErrorKind`.
|
|
224
|
-
- Sprig categories: `sprigDefaults`, `sprigStrings`, `sprigMath`, `sprigLists`, `sprigDicts`, `sprigRegex`, `sprigTypes`, `sprigConversions`.
|
|
235
|
+
- Engine: `createEngine`, `Engine`, `Template`, `EngineConfig`, `FuncMap`, `TemplateFunc`, `ArgType`, `MissingKeyOption`, `Delims`.
|
|
236
|
+
- Errors: `TemplateError`, `ParseError`, `EvalError`, `FuncNotFoundError`, `TypeMismatchError`, `MissingFieldError`, `FailError`, `ErrorKind`.
|
|
237
|
+
- Sprig categories: `sprigDefaults`, `sprigStrings`, `sprigMath`, `sprigLists`, `sprigDicts`, `sprigRegex`, `sprigTypes`, `sprigConversions`, `sprigSemver`, `sprigFlow`, `sprigRandom`, `sprigHash`, `sprigDatetime`.
|
|
225
238
|
|
|
226
239
|
Reaching into `dist/` subpaths or `src/` deep imports is unsupported.
|
|
227
240
|
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ interface Pos {
|
|
|
16
16
|
}
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/errors.d.ts
|
|
19
|
-
type ErrorKind = "ParseError" | "EvalError" | "FuncNotFoundError" | "TypeMismatchError" | "MissingFieldError";
|
|
19
|
+
type ErrorKind = "ParseError" | "EvalError" | "FuncNotFoundError" | "TypeMismatchError" | "MissingFieldError" | "FailError";
|
|
20
20
|
interface TemplateErrorContext {
|
|
21
21
|
readonly source?: string | undefined;
|
|
22
22
|
}
|
|
@@ -75,6 +75,37 @@ declare class MissingFieldError extends EvalError {
|
|
|
75
75
|
readonly path: readonly string[];
|
|
76
76
|
constructor(path: readonly string[], pos: Pos, ctx?: TemplateErrorContext);
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Thrown when a template calls `fail "message"`. Consumers can catch
|
|
80
|
+
* this specifically to distinguish intentional template failures from
|
|
81
|
+
* engine bugs. The message comes from the template author.
|
|
82
|
+
*
|
|
83
|
+
* [LAW:single-enforcer] One class, one place. The `fail` sprig function
|
|
84
|
+
* is the only producer; catch `FailError` to handle it distinctly from
|
|
85
|
+
* TypeMismatchError or other eval errors.
|
|
86
|
+
*/
|
|
87
|
+
declare class FailError extends EvalError {
|
|
88
|
+
readonly name = "FailError";
|
|
89
|
+
readonly kind: ErrorKind;
|
|
90
|
+
constructor(message: string, pos?: Pos, ctx?: TemplateErrorContext);
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/parser/lexer.d.ts
|
|
94
|
+
/**
|
|
95
|
+
* Action delimiters. Default is Go's `{{` / `}}`. Trim-marker forms are
|
|
96
|
+
* derived mechanically: `<left>-` opens with-trim and `-<right>` closes
|
|
97
|
+
* with-trim, matching Go's `text/template`.
|
|
98
|
+
*
|
|
99
|
+
* [LAW:types-are-the-program] Both sides are required if specified —
|
|
100
|
+
* neither may be empty. This is a stronger theorem than Go's API
|
|
101
|
+
* (which lets one side default while the other is set) and forbids
|
|
102
|
+
* the half-configured state that would otherwise have to be defended
|
|
103
|
+
* against at every internal use site.
|
|
104
|
+
*/
|
|
105
|
+
interface Delims {
|
|
106
|
+
readonly left: string;
|
|
107
|
+
readonly right: string;
|
|
108
|
+
}
|
|
78
109
|
//#endregion
|
|
79
110
|
//#region src/evaluator/evaluator.d.ts
|
|
80
111
|
/**
|
|
@@ -136,7 +167,7 @@ declare class MissingFieldError extends EvalError {
|
|
|
136
167
|
* `"callable"`). The history for this decision lives in epic
|
|
137
168
|
* template-laws-3gt.
|
|
138
169
|
*/
|
|
139
|
-
type ArgType = "string" | "number" | "bool" | "T" | "ordered" | "list" | "dict" | "sized" | "comparable" | "stringifiable" | "liftable" | "callable" | "collection" | "index-key" | "sliceable" | "truthy" | "reflective" | "value" | "serializable";
|
|
170
|
+
type ArgType = "string" | "number" | "int" | "float" | "bool" | "T" | "ordered" | "list" | "dict" | "sized" | "comparable" | "stringifiable" | "liftable" | "callable" | "collection" | "index-key" | "sliceable" | "truthy" | "reflective" | "value" | "serializable";
|
|
140
171
|
interface TemplateFunc {
|
|
141
172
|
/**
|
|
142
173
|
* The function body. Parameter types are *contravariant-bottom*
|
|
@@ -182,6 +213,24 @@ interface TemplateFunc {
|
|
|
182
213
|
readonly argTypePattern?: "alternating";
|
|
183
214
|
}
|
|
184
215
|
type FuncMap = Record<string, TemplateFunc>;
|
|
216
|
+
/**
|
|
217
|
+
* Policy for missing field/map-key access — mirrors Go's
|
|
218
|
+
* `text/template` `Option("missingkey=...")`:
|
|
219
|
+
*
|
|
220
|
+
* - `"default"` (Go's `missingkey=default` / `missingkey=invalid`):
|
|
221
|
+
* missing access yields `undefined`; emitted output is `<no value>`.
|
|
222
|
+
* This is the engine default, matching Go's `text/template` default.
|
|
223
|
+
* - `"zero"` (Go's `missingkey=zero`): in Go, returns the zero value of
|
|
224
|
+
* the map's element type. JavaScript has no static value-type info,
|
|
225
|
+
* so the runtime cannot synthesize a typed zero — the option is
|
|
226
|
+
* accepted for API parity and behaves identically to `"default"`.
|
|
227
|
+
* Use sprig `default` (`{{ .x | default "" }}`) when you want a
|
|
228
|
+
* typed-zero substitute at the use site.
|
|
229
|
+
* - `"error"` (Go's `missingkey=error`): missing access throws
|
|
230
|
+
* `MissingFieldError`. Use this in environments where a missing key
|
|
231
|
+
* indicates a scope-construction bug that should fail loud.
|
|
232
|
+
*/
|
|
233
|
+
type MissingKeyOption = "default" | "zero" | "error";
|
|
185
234
|
interface EngineConfig<T> {
|
|
186
235
|
/** Convert a text literal (or string-returning function result) into T. */
|
|
187
236
|
readonly fromString: (s: string) => T;
|
|
@@ -202,6 +251,49 @@ interface EngineConfig<T> {
|
|
|
202
251
|
* `"stringifiable"` slot encounters a T value — never silently.
|
|
203
252
|
*/
|
|
204
253
|
readonly toString?: (value: T) => string;
|
|
254
|
+
/**
|
|
255
|
+
* PRNG source for `sprigRandom` functions. Defaults to `Math.random`.
|
|
256
|
+
* Supply a seeded generator for reproducible templates.
|
|
257
|
+
*
|
|
258
|
+
* [LAW:single-enforcer] One config field owns the randomness source;
|
|
259
|
+
* pass this to `sprigRandom(config.random)` when composing a full
|
|
260
|
+
* sprig engine so the seam is wired once, not per-function.
|
|
261
|
+
*/
|
|
262
|
+
readonly random?: () => number;
|
|
263
|
+
/**
|
|
264
|
+
* Clock source for `sprigDatetime` functions. Defaults to
|
|
265
|
+
* `() => new Date()`. Supply a frozen clock for deterministic test
|
|
266
|
+
* output.
|
|
267
|
+
*
|
|
268
|
+
* [LAW:single-enforcer] One config field owns the time source; pass
|
|
269
|
+
* this to `sprigDatetime(config.clock)` when composing a full sprig
|
|
270
|
+
* engine so the seam is wired once, not per-function.
|
|
271
|
+
*/
|
|
272
|
+
readonly clock?: () => Date;
|
|
273
|
+
/**
|
|
274
|
+
* Policy for missing field / map-key access. Defaults to `"default"`
|
|
275
|
+
* (matching Go's `text/template` default — silent `<no value>`). See
|
|
276
|
+
* `MissingKeyOption` for the full enum semantics.
|
|
277
|
+
*
|
|
278
|
+
* [LAW:single-enforcer] One config field owns the policy; the
|
|
279
|
+
* `resolveFieldChain` gate is the only site that consults it.
|
|
280
|
+
* [LAW:dataflow-not-control-flow] The policy is data flowing into a
|
|
281
|
+
* fixed gate, not a branch sprinkled across accessors.
|
|
282
|
+
*/
|
|
283
|
+
readonly missingKey?: MissingKeyOption;
|
|
284
|
+
/**
|
|
285
|
+
* Optional override for the template action delimiters. Mirrors
|
|
286
|
+
* Go's `text/template.Template.Delims(left, right)`. Both sides
|
|
287
|
+
* are required if specified — neither may be empty.
|
|
288
|
+
*
|
|
289
|
+
* [LAW:single-enforcer] Validated once at construct time and
|
|
290
|
+
* threaded into the parser as immutable data; no re-validation
|
|
291
|
+
* along the call chain.
|
|
292
|
+
* [LAW:dataflow-not-control-flow] The delim pair is data flowing
|
|
293
|
+
* into the fixed lexer state machine — no new modes, no new
|
|
294
|
+
* branches, just different constant values seeded at construction.
|
|
295
|
+
*/
|
|
296
|
+
readonly delims?: Delims;
|
|
205
297
|
/** Optional registry of named functions usable in pipelines. */
|
|
206
298
|
readonly funcs?: FuncMap;
|
|
207
299
|
}
|
|
@@ -215,6 +307,8 @@ declare class Engine<T> {
|
|
|
215
307
|
private readonly fromString;
|
|
216
308
|
private readonly toString;
|
|
217
309
|
private readonly funcs;
|
|
310
|
+
private readonly missingKey;
|
|
311
|
+
private readonly delims;
|
|
218
312
|
constructor(config: EngineConfig<T>);
|
|
219
313
|
/**
|
|
220
314
|
* Parse a template source into a reusable Template handle.
|
|
@@ -260,26 +354,65 @@ declare function createEngine<T>(config: EngineConfig<T>): Engine<T>;
|
|
|
260
354
|
//#region src/sprig/conversions/index.d.ts
|
|
261
355
|
declare function sprigConversions(): FuncMap;
|
|
262
356
|
//#endregion
|
|
357
|
+
//#region src/sprig/datetime/_clock.d.ts
|
|
358
|
+
/**
|
|
359
|
+
* Clock seam for all date/time functions.
|
|
360
|
+
*
|
|
361
|
+
* [LAW:single-enforcer] Every function that reads "now" accepts a Clock
|
|
362
|
+
* parameter injected by the factory closure — never calls `new Date()`
|
|
363
|
+
* directly. One seam, not eleven.
|
|
364
|
+
*/
|
|
365
|
+
type Clock = () => Date;
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region src/sprig/datetime/index.d.ts
|
|
368
|
+
/**
|
|
369
|
+
* Build the sprig date/time FuncMap.
|
|
370
|
+
*
|
|
371
|
+
* @param clock - Source of "current time". Defaults to `() => new Date()`.
|
|
372
|
+
* Pass a frozen clock for deterministic test output (mirrors
|
|
373
|
+
* `EngineConfig.clock`).
|
|
374
|
+
*/
|
|
375
|
+
declare function sprigDatetime(clock?: Clock): FuncMap;
|
|
376
|
+
//#endregion
|
|
263
377
|
//#region src/sprig/defaults/index.d.ts
|
|
264
378
|
declare function sprigDefaults(): FuncMap;
|
|
265
379
|
//#endregion
|
|
266
380
|
//#region src/sprig/dicts/index.d.ts
|
|
267
381
|
declare function sprigDicts(): FuncMap;
|
|
268
382
|
//#endregion
|
|
383
|
+
//#region src/sprig/flow/index.d.ts
|
|
384
|
+
declare function sprigFlow(): FuncMap;
|
|
385
|
+
//#endregion
|
|
386
|
+
//#region src/sprig/hash/index.d.ts
|
|
387
|
+
/** Build the sprig hash/encoding FuncMap. */
|
|
388
|
+
declare function sprigHash(): FuncMap;
|
|
389
|
+
//#endregion
|
|
269
390
|
//#region src/sprig/lists/index.d.ts
|
|
270
391
|
declare function sprigLists(): FuncMap;
|
|
271
392
|
//#endregion
|
|
272
393
|
//#region src/sprig/math/index.d.ts
|
|
273
394
|
declare function sprigMath(): FuncMap;
|
|
274
395
|
//#endregion
|
|
396
|
+
//#region src/sprig/random/index.d.ts
|
|
397
|
+
/**
|
|
398
|
+
* Build the sprig random FuncMap.
|
|
399
|
+
*
|
|
400
|
+
* @param random - PRNG source. Defaults to `Math.random`. Pass a seeded
|
|
401
|
+
* generator for reproducible templates (matches `EngineConfig.random`).
|
|
402
|
+
*/
|
|
403
|
+
declare function sprigRandom(random?: () => number): FuncMap;
|
|
404
|
+
//#endregion
|
|
275
405
|
//#region src/sprig/regex/index.d.ts
|
|
276
406
|
declare function sprigRegex(): FuncMap;
|
|
277
407
|
//#endregion
|
|
408
|
+
//#region src/sprig/semver/index.d.ts
|
|
409
|
+
declare function sprigSemver(): FuncMap;
|
|
410
|
+
//#endregion
|
|
278
411
|
//#region src/sprig/strings/index.d.ts
|
|
279
412
|
declare function sprigStrings(): FuncMap;
|
|
280
413
|
//#endregion
|
|
281
414
|
//#region src/sprig/types/index.d.ts
|
|
282
415
|
declare function sprigTypes(): FuncMap;
|
|
283
416
|
//#endregion
|
|
284
|
-
export { type ArgType, Engine, type EngineConfig, type ErrorKind, EvalError, type FuncMap, FuncNotFoundError, MissingFieldError, ParseError, Template, TemplateError, type TemplateFunc, TypeMismatchError, createEngine, sprigConversions, sprigDefaults, sprigDicts, sprigLists, sprigMath, sprigRegex, sprigStrings, sprigTypes };
|
|
417
|
+
export { type ArgType, type Delims, Engine, type EngineConfig, type ErrorKind, EvalError, FailError, type FuncMap, FuncNotFoundError, MissingFieldError, type MissingKeyOption, ParseError, Template, TemplateError, type TemplateFunc, TypeMismatchError, createEngine, sprigConversions, sprigDatetime, sprigDefaults, sprigDicts, sprigFlow, sprigHash, sprigLists, sprigMath, sprigRandom, sprigRegex, sprigSemver, sprigStrings, sprigTypes };
|
|
285
418
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/parser/pos.ts","../src/errors.ts","../src/evaluator/evaluator.ts","../src/sprig/conversions/index.ts","../src/sprig/defaults/index.ts","../src/sprig/dicts/index.ts","../src/sprig/lists/index.ts","../src/sprig/math/index.ts","../src/sprig/regex/index.ts","../src/sprig/strings/index.ts","../src/sprig/types/index.ts"],"mappings":";;AAUA;;;;;;;;;UAAiB,GAAA;EAAA,SACN,IAAA;EAAA,SACA,MAAA;EAAA,SACA,MAAA;AAAA;;;KCSC,SAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/parser/pos.ts","../src/errors.ts","../src/parser/lexer.ts","../src/evaluator/evaluator.ts","../src/sprig/conversions/index.ts","../src/sprig/datetime/_clock.ts","../src/sprig/datetime/index.ts","../src/sprig/defaults/index.ts","../src/sprig/dicts/index.ts","../src/sprig/flow/index.ts","../src/sprig/hash/index.ts","../src/sprig/lists/index.ts","../src/sprig/math/index.ts","../src/sprig/random/index.ts","../src/sprig/regex/index.ts","../src/sprig/semver/index.ts","../src/sprig/strings/index.ts","../src/sprig/types/index.ts"],"mappings":";;AAUA;;;;;;;;;UAAiB,GAAA;EAAA,SACN,IAAA;EAAA,SACA,MAAA;EAAA,SACA,MAAA;AAAA;;;KCSC,SAAA;AAAA,UAQK,oBAAA;EAAA,SACN,MAAA;AAAA;AAAA,cAOE,aAAA,SAAsB,KAAA;EAAA,SACf,IAAA;EAAA,SACT,IAAA,EAAM,SAAA;EAAA,SACN,GAAA,EAAK,GAAA;EAAA,SACL,MAAA;cAEG,OAAA,UAAiB,GAAA,EAAK,GAAA,EAAK,GAAA,GAAK,oBAAA;EANX;EAAA,IAa7B,aAAA,CAAA;EAIK,QAAA,CAAA;AAAA;AAAA,UAWM,iBAAA,SAA0B,oBAAA;EAAA,SAChC,QAAA;EAAA,SACA,KAAA;AAAA;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