@promptctl/go-template-js 0.9.0 → 0.10.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 +43 -7
- package/dist/index.d.ts +164 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +608 -221
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var TemplateError = class extends Error {
|
|
|
8
8
|
pos;
|
|
9
9
|
source;
|
|
10
10
|
constructor(message, pos, ctx = {}) {
|
|
11
|
-
super(message);
|
|
11
|
+
super(message, { cause: ctx.cause });
|
|
12
12
|
this.pos = pos;
|
|
13
13
|
this.source = ctx.source;
|
|
14
14
|
}
|
|
@@ -55,6 +55,29 @@ var FuncNotFoundError = class extends EvalError {
|
|
|
55
55
|
this.suggestions = suggestions;
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Thrown when a func is called with a number of arguments its declared
|
|
60
|
+
* arity does not accept — `{{ upper "a" "b" }}`, `{{ min }}`.
|
|
61
|
+
*
|
|
62
|
+
* The message mirrors Go's `text/template`, which reports a fixed-arity
|
|
63
|
+
* signature as `want N` and a variadic one as `want at least N`. That
|
|
64
|
+
* distinction is read off `accepted`, not passed in, so the two phrasings
|
|
65
|
+
* cannot disagree about which one a given func gets.
|
|
66
|
+
*/
|
|
67
|
+
var ArgCountError = class extends EvalError {
|
|
68
|
+
name = "ArgCountError";
|
|
69
|
+
kind = "ArgCountError";
|
|
70
|
+
funcName;
|
|
71
|
+
accepted;
|
|
72
|
+
got;
|
|
73
|
+
constructor(funcName, accepted, got, pos, ctx = {}) {
|
|
74
|
+
const want = accepted.minimum === accepted.maximum ? `${accepted.minimum}` : `at least ${accepted.minimum}`;
|
|
75
|
+
super(`wrong number of args for ${funcName}: want ${want} got ${got}`, pos, ctx);
|
|
76
|
+
this.funcName = funcName;
|
|
77
|
+
this.accepted = accepted;
|
|
78
|
+
this.got = got;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
58
81
|
var TypeMismatchError = class extends EvalError {
|
|
59
82
|
name = "TypeMismatchError";
|
|
60
83
|
kind = "TypeMismatchError";
|
|
@@ -71,6 +94,21 @@ var TypeMismatchError = class extends EvalError {
|
|
|
71
94
|
this.receivedSummary = receivedSummary;
|
|
72
95
|
}
|
|
73
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* An integer slot refused a number that is not a safe integer. Still a
|
|
99
|
+
* `TypeMismatchError` (the slot's type refused the value), but worded
|
|
100
|
+
* with the value and the reason: a fractional is Go's own refusal,
|
|
101
|
+
* `expected integer; found 2.7`, and an integer past 2^53 is
|
|
102
|
+
* `integer out of range: <n>`, since JS cannot carry it exactly. The
|
|
103
|
+
* generic wording would say a number was expected and a number arrived,
|
|
104
|
+
* and suggest flattening a styled value that was never there.
|
|
105
|
+
*/
|
|
106
|
+
var NotIntegerError = class extends TypeMismatchError {
|
|
107
|
+
constructor(funcName, argIndex, value, pos, ctx = {}) {
|
|
108
|
+
super(funcName, argIndex, "integer", String(value), pos, ctx);
|
|
109
|
+
this.message = Number.isInteger(Number(value)) ? `integer out of range: ${String(value)}` : `expected integer; found ${String(value)}`;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
74
112
|
var MissingFieldError = class extends EvalError {
|
|
75
113
|
name = "MissingFieldError";
|
|
76
114
|
kind = "MissingFieldError";
|
|
@@ -1408,31 +1446,38 @@ function eagerBuiltins(toString, isT) {
|
|
|
1408
1446
|
return {
|
|
1409
1447
|
eq: {
|
|
1410
1448
|
fn: (a, ...rest) => rest.some((r) => goEqPair(a, r)),
|
|
1411
|
-
argTypes: ["comparable"]
|
|
1449
|
+
argTypes: ["comparable", "comparable"],
|
|
1450
|
+
arity: { kind: "variadic" }
|
|
1412
1451
|
},
|
|
1413
1452
|
ne: {
|
|
1414
1453
|
fn: (a, b) => !goEqPair(a, b),
|
|
1415
|
-
argTypes: ["comparable", "comparable"]
|
|
1454
|
+
argTypes: ["comparable", "comparable"],
|
|
1455
|
+
arity: { kind: "exact" }
|
|
1416
1456
|
},
|
|
1417
1457
|
lt: {
|
|
1418
1458
|
fn: (a, b) => compare(a, b) < 0,
|
|
1419
|
-
argTypes: ["ordered", "ordered"]
|
|
1459
|
+
argTypes: ["ordered", "ordered"],
|
|
1460
|
+
arity: { kind: "exact" }
|
|
1420
1461
|
},
|
|
1421
1462
|
le: {
|
|
1422
1463
|
fn: (a, b) => compare(a, b) <= 0,
|
|
1423
|
-
argTypes: ["ordered", "ordered"]
|
|
1464
|
+
argTypes: ["ordered", "ordered"],
|
|
1465
|
+
arity: { kind: "exact" }
|
|
1424
1466
|
},
|
|
1425
1467
|
gt: {
|
|
1426
1468
|
fn: (a, b) => compare(a, b) > 0,
|
|
1427
|
-
argTypes: ["ordered", "ordered"]
|
|
1469
|
+
argTypes: ["ordered", "ordered"],
|
|
1470
|
+
arity: { kind: "exact" }
|
|
1428
1471
|
},
|
|
1429
1472
|
ge: {
|
|
1430
1473
|
fn: (a, b) => compare(a, b) >= 0,
|
|
1431
|
-
argTypes: ["ordered", "ordered"]
|
|
1474
|
+
argTypes: ["ordered", "ordered"],
|
|
1475
|
+
arity: { kind: "exact" }
|
|
1432
1476
|
},
|
|
1433
1477
|
len: {
|
|
1434
1478
|
fn: (v) => goLen(v),
|
|
1435
|
-
argTypes: ["sized"]
|
|
1479
|
+
argTypes: ["sized"],
|
|
1480
|
+
arity: { kind: "exact" }
|
|
1436
1481
|
},
|
|
1437
1482
|
index: {
|
|
1438
1483
|
fn: (collection, ...keys) => {
|
|
@@ -1440,69 +1485,78 @@ function eagerBuiltins(toString, isT) {
|
|
|
1440
1485
|
for (const k of keys) cur = goIndex(cur, k);
|
|
1441
1486
|
return cur;
|
|
1442
1487
|
},
|
|
1443
|
-
argTypes: ["collection", "index-key"]
|
|
1488
|
+
argTypes: ["collection", "index-key"],
|
|
1489
|
+
arity: { kind: "variadic" }
|
|
1444
1490
|
},
|
|
1445
1491
|
slice: {
|
|
1446
|
-
fn: (collection, ...indices) =>
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
return typeof collection === "string" ? collection.slice(i, j) : collection.slice(i, j);
|
|
1450
|
-
},
|
|
1451
|
-
argTypes: ["sliceable", "int"]
|
|
1492
|
+
fn: (collection, ...indices) => goSlice(collection, indices),
|
|
1493
|
+
argTypes: ["sliceable", "int"],
|
|
1494
|
+
arity: { kind: "variadic" }
|
|
1452
1495
|
},
|
|
1453
1496
|
print: {
|
|
1454
1497
|
fn: (...args) => goPrint(args, toString),
|
|
1455
1498
|
argTypes: ["stringifiable"],
|
|
1499
|
+
arity: { kind: "variadic" },
|
|
1456
1500
|
returnType: "string"
|
|
1457
1501
|
},
|
|
1458
1502
|
println: {
|
|
1459
1503
|
fn: (...args) => `${goPrint(args, toString)}\n`,
|
|
1460
1504
|
argTypes: ["stringifiable"],
|
|
1505
|
+
arity: { kind: "variadic" },
|
|
1461
1506
|
returnType: "string"
|
|
1462
1507
|
},
|
|
1463
1508
|
printf: {
|
|
1464
1509
|
fn: (format, ...args) => sprintf(format, args, toString, isT),
|
|
1465
1510
|
argTypes: ["string", "stringifiable"],
|
|
1511
|
+
arity: { kind: "variadic" },
|
|
1466
1512
|
returnType: "string"
|
|
1467
1513
|
},
|
|
1468
1514
|
toString: {
|
|
1469
1515
|
fn: (v) => formatV(v, toString, isT),
|
|
1470
1516
|
argTypes: ["value"],
|
|
1517
|
+
arity: { kind: "exact" },
|
|
1471
1518
|
returnType: "string"
|
|
1472
1519
|
},
|
|
1473
1520
|
toStrings: {
|
|
1474
1521
|
fn: (list) => list.map((v) => formatV(v, toString, isT)),
|
|
1475
|
-
argTypes: ["list"]
|
|
1522
|
+
argTypes: ["list"],
|
|
1523
|
+
arity: { kind: "exact" }
|
|
1476
1524
|
},
|
|
1477
1525
|
call: {
|
|
1478
1526
|
fn: (fn, ...args) => fn(...args),
|
|
1479
|
-
argTypes: ["callable", "value"]
|
|
1527
|
+
argTypes: ["callable", "value"],
|
|
1528
|
+
arity: { kind: "variadic" }
|
|
1480
1529
|
},
|
|
1481
1530
|
html: {
|
|
1482
1531
|
fn: (...args) => htmlEscape(goPrint(args, toString)),
|
|
1483
1532
|
argTypes: ["stringifiable"],
|
|
1533
|
+
arity: { kind: "variadic" },
|
|
1484
1534
|
returnType: "string"
|
|
1485
1535
|
},
|
|
1486
1536
|
js: {
|
|
1487
1537
|
fn: (...args) => jsEscape(goPrint(args, toString)),
|
|
1488
1538
|
argTypes: ["stringifiable"],
|
|
1539
|
+
arity: { kind: "variadic" },
|
|
1489
1540
|
returnType: "string"
|
|
1490
1541
|
},
|
|
1491
1542
|
urlquery: {
|
|
1492
1543
|
fn: (...args) => urlQueryEscape(goPrint(args, toString)),
|
|
1493
1544
|
argTypes: ["stringifiable"],
|
|
1545
|
+
arity: { kind: "variadic" },
|
|
1494
1546
|
returnType: "string"
|
|
1495
1547
|
},
|
|
1496
1548
|
not: {
|
|
1497
1549
|
fn: (v) => !isTruthy(v),
|
|
1498
|
-
argTypes: ["truthy"]
|
|
1550
|
+
argTypes: ["truthy"],
|
|
1551
|
+
arity: { kind: "exact" }
|
|
1499
1552
|
}
|
|
1500
1553
|
};
|
|
1501
1554
|
}
|
|
1502
1555
|
function lazyBuiltins() {
|
|
1503
1556
|
return {
|
|
1504
1557
|
and: markLazy({
|
|
1505
|
-
argTypes: ["truthy"],
|
|
1558
|
+
argTypes: ["truthy", "truthy"],
|
|
1559
|
+
arity: { kind: "variadic" },
|
|
1506
1560
|
fn: (...thunks) => {
|
|
1507
1561
|
let last = true;
|
|
1508
1562
|
for (const t of thunks) {
|
|
@@ -1513,7 +1567,8 @@ function lazyBuiltins() {
|
|
|
1513
1567
|
}
|
|
1514
1568
|
}),
|
|
1515
1569
|
or: markLazy({
|
|
1516
|
-
argTypes: ["truthy"],
|
|
1570
|
+
argTypes: ["truthy", "truthy"],
|
|
1571
|
+
arity: { kind: "variadic" },
|
|
1517
1572
|
fn: (...thunks) => {
|
|
1518
1573
|
let last = false;
|
|
1519
1574
|
for (const t of thunks) {
|
|
@@ -1555,20 +1610,41 @@ function goLen(value) {
|
|
|
1555
1610
|
return Object.keys(value).length;
|
|
1556
1611
|
}
|
|
1557
1612
|
function goIndex(collection, key) {
|
|
1558
|
-
if (Array.isArray(collection)) {
|
|
1559
|
-
const i =
|
|
1560
|
-
if (
|
|
1561
|
-
if (i < 0 || i >= collection.length) throw new Error(`index: out of range [${i}] with length ${collection.length}`);
|
|
1613
|
+
if (Array.isArray(collection) || typeof collection === "string") {
|
|
1614
|
+
const i = indexArg(key, collection.length);
|
|
1615
|
+
if (i === collection.length) throw new Error(`index out of range: ${i}`);
|
|
1562
1616
|
return collection[i];
|
|
1563
1617
|
}
|
|
1564
1618
|
if (collection instanceof Map) return collection.get(key);
|
|
1565
|
-
if (typeof collection === "string") return collection[Number(key)];
|
|
1566
1619
|
if (collection !== null && typeof collection === "object") {
|
|
1567
1620
|
if (typeof key !== "string") throw new Error(`index: object index must be string, got ${describeType(key)}`);
|
|
1568
1621
|
return collection[key];
|
|
1569
1622
|
}
|
|
1570
1623
|
throw new Error(`index: cannot index ${describeType(collection)}`);
|
|
1571
1624
|
}
|
|
1625
|
+
function indexArg(key, cap) {
|
|
1626
|
+
const x = typeof key === "bigint" ? Number(key) : key;
|
|
1627
|
+
if (typeof x !== "number" || !Number.isInteger(x)) throw new Error(`cannot index slice/array with type ${goPrintfType(key)}`);
|
|
1628
|
+
if (x < 0 || x > cap) throw new Error(`index out of range: ${String(key)}`);
|
|
1629
|
+
return x;
|
|
1630
|
+
}
|
|
1631
|
+
function goSlice(collection, indices) {
|
|
1632
|
+
if (indices.length > 3) throw new Error(`too many slice indexes: ${indices.length}`);
|
|
1633
|
+
if (typeof collection === "string" && indices.length > 2) throw new Error("cannot 3-index slice a string");
|
|
1634
|
+
const cap = collection.length;
|
|
1635
|
+
const bounds = [
|
|
1636
|
+
0,
|
|
1637
|
+
cap,
|
|
1638
|
+
cap
|
|
1639
|
+
];
|
|
1640
|
+
indices.forEach((ix, n) => {
|
|
1641
|
+
bounds[n] = indexArg(ix, cap);
|
|
1642
|
+
});
|
|
1643
|
+
const [i, j, k] = bounds;
|
|
1644
|
+
if (i > j) throw new Error(`invalid slice index: ${i} > ${j}`);
|
|
1645
|
+
if (j > k) throw new Error(`invalid slice index: ${j} > ${k}`);
|
|
1646
|
+
return collection.slice(i, j);
|
|
1647
|
+
}
|
|
1572
1648
|
function describeType(v) {
|
|
1573
1649
|
if (v === null) return "null";
|
|
1574
1650
|
if (v === void 0) return "undefined";
|
|
@@ -1802,6 +1878,43 @@ function declareVar(scope, name, value) {
|
|
|
1802
1878
|
* no instance mutation, so the same Engine handles concurrent evaluate
|
|
1803
1879
|
* calls (tested through the parse-once-eval-many invariant).
|
|
1804
1880
|
*/
|
|
1881
|
+
/**
|
|
1882
|
+
* Every kind a slot may declare.
|
|
1883
|
+
*
|
|
1884
|
+
* [LAW:one-source-of-truth] The kinds are a *list* first and a type
|
|
1885
|
+
* second. `validateArgSpecs` must reject a declaration naming a kind
|
|
1886
|
+
* that does not exist, and a runtime check needs a runtime list; writing
|
|
1887
|
+
* that list out beside a hand-maintained union would be the second
|
|
1888
|
+
* clock. So the array is authoritative and `ArgType` is derived from it
|
|
1889
|
+
* — one edit adds a kind to the type, to the construct-time check, and
|
|
1890
|
+
* to the two exhaustive switches that must then grow an arm.
|
|
1891
|
+
*
|
|
1892
|
+
* The per-kind semantics live on `ArgType` below, where a consumer
|
|
1893
|
+
* hovering the exported name finds them.
|
|
1894
|
+
*/
|
|
1895
|
+
const ARG_TYPES = [
|
|
1896
|
+
"string",
|
|
1897
|
+
"int",
|
|
1898
|
+
"truncating-int",
|
|
1899
|
+
"float",
|
|
1900
|
+
"bool",
|
|
1901
|
+
"T",
|
|
1902
|
+
"ordered",
|
|
1903
|
+
"list",
|
|
1904
|
+
"dict",
|
|
1905
|
+
"sized",
|
|
1906
|
+
"comparable",
|
|
1907
|
+
"stringifiable",
|
|
1908
|
+
"liftable",
|
|
1909
|
+
"callable",
|
|
1910
|
+
"collection",
|
|
1911
|
+
"index-key",
|
|
1912
|
+
"sliceable",
|
|
1913
|
+
"truthy",
|
|
1914
|
+
"reflective",
|
|
1915
|
+
"value",
|
|
1916
|
+
"serializable"
|
|
1917
|
+
];
|
|
1805
1918
|
const VALID_MISSING_KEYS = new Set([
|
|
1806
1919
|
"default",
|
|
1807
1920
|
"zero",
|
|
@@ -1832,6 +1945,24 @@ function validateDelims(value) {
|
|
|
1832
1945
|
right: value.right
|
|
1833
1946
|
};
|
|
1834
1947
|
}
|
|
1948
|
+
function readsSlotsFromArgTypes(arity) {
|
|
1949
|
+
switch (arity.kind) {
|
|
1950
|
+
case "exact": return false;
|
|
1951
|
+
case "variadic": return true;
|
|
1952
|
+
case "alternating": return true;
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
function validateArgSpecs(funcs) {
|
|
1956
|
+
const legal = new Set(ARG_TYPES);
|
|
1957
|
+
for (const [name, fn] of Object.entries(funcs)) {
|
|
1958
|
+
fn.argTypes.forEach((declared, slot) => {
|
|
1959
|
+
if (!legal.has(declared)) throw new Error(`EngineConfig.funcs.${name}: argTypes[${slot}] is ${JSON.stringify(declared)}, which is not an ArgType; declare one of ${ARG_TYPES.join(", ")}`);
|
|
1960
|
+
});
|
|
1961
|
+
if (readsSlotsFromArgTypes(fn.arity) && fn.argTypes.length === 0) throw new Error(`EngineConfig.funcs.${name}: arity ${JSON.stringify(fn.arity.kind)} needs at least one declared argType (it reads its repeating slot from the end of argTypes); declare the slots the Go signature has, or use { kind: "exact" }`);
|
|
1962
|
+
if (fn.arity.kind === "alternating" && (!Number.isSafeInteger(fn.arity.minimum) || fn.arity.minimum < 0)) throw new Error(`EngineConfig.funcs.${name}: arity "alternating" needs a non-negative integer minimum, got ${String(fn.arity.minimum)}; the gate rejects every count below it, so a negative or non-finite minimum would disable the lower bound`);
|
|
1963
|
+
}
|
|
1964
|
+
return funcs;
|
|
1965
|
+
}
|
|
1835
1966
|
const BREAK_SIGNAL = Object.freeze({ kind: "break" });
|
|
1836
1967
|
const CONTINUE_SIGNAL = Object.freeze({ kind: "continue" });
|
|
1837
1968
|
const NO_PIPE = { kind: "none" };
|
|
@@ -2002,10 +2133,10 @@ var Engine = class {
|
|
|
2002
2133
|
this.isT = config.isT ?? DEFAULT_IS_T;
|
|
2003
2134
|
this.missingKey = validateMissingKey(config.missingKey);
|
|
2004
2135
|
this.delims = validateDelims(config.delims);
|
|
2005
|
-
this.funcs = {
|
|
2136
|
+
this.funcs = validateArgSpecs({
|
|
2006
2137
|
...defaultBuiltins(this.toString, this.isT),
|
|
2007
2138
|
...config.funcs ?? {}
|
|
2008
|
-
};
|
|
2139
|
+
});
|
|
2009
2140
|
}
|
|
2010
2141
|
/**
|
|
2011
2142
|
* Parse a template source into a reusable Template handle.
|
|
@@ -2204,13 +2335,20 @@ var Engine = class {
|
|
|
2204
2335
|
const v = piped.value;
|
|
2205
2336
|
args.push(lazy ? () => v : v);
|
|
2206
2337
|
}
|
|
2207
|
-
|
|
2338
|
+
return this.invoke(head.ident, fn, args, cmd.pos, ctx);
|
|
2339
|
+
}
|
|
2340
|
+
invoke(name, fn, args, pos, ctx) {
|
|
2341
|
+
enforceArgTypes(name, fn, args, pos, ctx.source, this.toString, this.fromString, this.isT);
|
|
2208
2342
|
try {
|
|
2209
2343
|
return fn.fn(...args);
|
|
2210
2344
|
} catch (e) {
|
|
2211
|
-
if (e instanceof TypeMismatchError) throw new TypeMismatchError(e.funcName, e.argIndex, e.expected, e.receivedSummary,
|
|
2212
|
-
if (e instanceof FailError) throw new FailError(e.message,
|
|
2213
|
-
throw e;
|
|
2345
|
+
if (e instanceof TypeMismatchError) throw new TypeMismatchError(e.funcName, e.argIndex, e.expected, e.receivedSummary, pos, { source: ctx.source });
|
|
2346
|
+
if (e instanceof FailError) throw new FailError(e.message, pos, { source: ctx.source });
|
|
2347
|
+
if (e instanceof TemplateError) throw e;
|
|
2348
|
+
throw new EvalError(`error calling ${name}: ${errorText(e)}`, pos, {
|
|
2349
|
+
source: ctx.source,
|
|
2350
|
+
cause: e
|
|
2351
|
+
});
|
|
2214
2352
|
}
|
|
2215
2353
|
}
|
|
2216
2354
|
evalPrimary(node, scope, ctx) {
|
|
@@ -2228,8 +2366,7 @@ var Engine = class {
|
|
|
2228
2366
|
source: ctx.source,
|
|
2229
2367
|
available: Object.keys(this.funcs)
|
|
2230
2368
|
});
|
|
2231
|
-
|
|
2232
|
-
return fn.fn();
|
|
2369
|
+
return this.invoke(node.ident, fn, [], node.pos, ctx);
|
|
2233
2370
|
}
|
|
2234
2371
|
case "Chain": return this.resolveFieldChain(this.evalPrimary(node.node, scope, ctx), node.fields, node.pos, ctx);
|
|
2235
2372
|
case "Pipe": return this.evalPipe(node, scope, ctx);
|
|
@@ -2276,17 +2413,23 @@ const DEFAULT_IS_T = (v) => typeof v === "object" && v !== null && !Array.isArra
|
|
|
2276
2413
|
function createEngine(config) {
|
|
2277
2414
|
return new Engine(config);
|
|
2278
2415
|
}
|
|
2279
|
-
function enforceArgTypes(funcName,
|
|
2280
|
-
const
|
|
2416
|
+
function enforceArgTypes(funcName, spec, values, pos, src, toString = defaultToString, fromString = defaultFromString, isT = DEFAULT_IS_T) {
|
|
2417
|
+
const { argTypes, arity } = spec;
|
|
2418
|
+
const accepted = acceptedArgCount(argTypes, arity);
|
|
2419
|
+
if (values.length < accepted.minimum || values.length > accepted.maximum) throw new ArgCountError(funcName, accepted, values.length, pos, { source: src });
|
|
2420
|
+
const lookup = makeSlotLookup(argTypes, arity);
|
|
2281
2421
|
let firstOrdered = -1;
|
|
2282
2422
|
let firstComparable = -1;
|
|
2283
2423
|
for (let i = 0; i < values.length; i++) {
|
|
2284
2424
|
const declared = lookup(i);
|
|
2285
2425
|
const value = values[i];
|
|
2286
|
-
if (!matchesArgType(declared, value, toString, isT))
|
|
2426
|
+
if (!matchesArgType(declared, value, toString, isT)) {
|
|
2427
|
+
if ((declared === "int" || declared === "truncating-int") && (typeof value === "number" || typeof value === "bigint")) throw new NotIntegerError(funcName, i + 1, value, pos, { source: src });
|
|
2428
|
+
throw new TypeMismatchError(funcName, i + 1, humanArgType(declared), describeValue(value), pos, { source: src });
|
|
2429
|
+
}
|
|
2287
2430
|
if (declared === "liftable" && typeof value === "string") values[i] = fromString(value);
|
|
2288
|
-
if (declared === "int") values[i] = Math.trunc(Number(value));
|
|
2289
|
-
else if (declared === "float") values[i] = Number(value);
|
|
2431
|
+
if (declared === "truncating-int") values[i] = Math.trunc(Number(value));
|
|
2432
|
+
else if (declared === "int" || declared === "float") values[i] = Number(value);
|
|
2290
2433
|
if (declared === "ordered") {
|
|
2291
2434
|
if (firstOrdered === -1) firstOrdered = i;
|
|
2292
2435
|
else if (!sameOrderedKind(values[firstOrdered], value)) throw new TypeMismatchError(funcName, i + 1, `${humanArgType("ordered")} of the same kind as ${describeValue(values[firstOrdered])}`, describeValue(value), pos, { source: src });
|
|
@@ -2297,14 +2440,29 @@ function enforceArgTypes(funcName, argTypes, values, pos, src, toString = defaul
|
|
|
2297
2440
|
}
|
|
2298
2441
|
}
|
|
2299
2442
|
}
|
|
2300
|
-
function
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2443
|
+
function acceptedArgCount(argTypes, arity) {
|
|
2444
|
+
switch (arity.kind) {
|
|
2445
|
+
case "exact": return {
|
|
2446
|
+
minimum: argTypes.length,
|
|
2447
|
+
maximum: argTypes.length
|
|
2448
|
+
};
|
|
2449
|
+
case "variadic": return {
|
|
2450
|
+
minimum: argTypes.length - 1,
|
|
2451
|
+
maximum: Infinity
|
|
2452
|
+
};
|
|
2453
|
+
case "alternating": return {
|
|
2454
|
+
minimum: arity.minimum,
|
|
2455
|
+
maximum: Infinity
|
|
2456
|
+
};
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
function makeSlotLookup(argTypes, arity) {
|
|
2460
|
+
const len = argTypes.length;
|
|
2461
|
+
switch (arity.kind) {
|
|
2462
|
+
case "exact": return (i) => argTypes[i];
|
|
2463
|
+
case "variadic": return (i) => argTypes[Math.min(i, len - 1)];
|
|
2464
|
+
case "alternating": return (i) => argTypes[i % len];
|
|
2305
2465
|
}
|
|
2306
|
-
const trailing = argTypes[argTypes.length - 1];
|
|
2307
|
-
return (i) => i < argTypes.length ? argTypes[i] : trailing;
|
|
2308
2466
|
}
|
|
2309
2467
|
function matchesArgType(declared, value, toString, isT) {
|
|
2310
2468
|
switch (declared) {
|
|
@@ -2312,7 +2470,8 @@ function matchesArgType(declared, value, toString, isT) {
|
|
|
2312
2470
|
case "reflective":
|
|
2313
2471
|
case "value": return true;
|
|
2314
2472
|
case "string": return typeof value === "string";
|
|
2315
|
-
case "int": return typeof value === "number" && Number.
|
|
2473
|
+
case "int": return typeof value === "number" && Number.isSafeInteger(value) || typeof value === "bigint" && Number.isSafeInteger(Number(value));
|
|
2474
|
+
case "truncating-int": return typeof value === "number" && Number.isFinite(value) || typeof value === "bigint" && Number.isSafeInteger(Number(value));
|
|
2316
2475
|
case "float": return typeof value === "number" || typeof value === "bigint" && Number.isFinite(Number(value));
|
|
2317
2476
|
case "bool": return typeof value === "boolean";
|
|
2318
2477
|
case "ordered": return typeof value === "string" || typeof value === "number" || typeof value === "bigint" || typeof value === "boolean";
|
|
@@ -2382,7 +2541,8 @@ function comparableKind(v) {
|
|
|
2382
2541
|
}
|
|
2383
2542
|
function humanArgType(t) {
|
|
2384
2543
|
switch (t) {
|
|
2385
|
-
case "int": return "integer (
|
|
2544
|
+
case "int": return "integer (safe-integer number or bigint)";
|
|
2545
|
+
case "truncating-int": return "integer (finite number, truncated toward zero, or safe-integer bigint)";
|
|
2386
2546
|
case "float": return "float (number, including NaN/Infinity, or finite-convertible bigint)";
|
|
2387
2547
|
case "T": return "T (consumer-defined fragment)";
|
|
2388
2548
|
case "ordered": return "orderable primitive";
|
|
@@ -2405,6 +2565,9 @@ function humanArgType(t) {
|
|
|
2405
2565
|
default: throw new Error(`invalid ArgType: ${String(t)}`);
|
|
2406
2566
|
}
|
|
2407
2567
|
}
|
|
2568
|
+
function errorText(e) {
|
|
2569
|
+
return e instanceof Error ? e.message : String(e);
|
|
2570
|
+
}
|
|
2408
2571
|
function describeValue(value) {
|
|
2409
2572
|
if (value === null) return "null";
|
|
2410
2573
|
if (value === void 0) return "undefined";
|
|
@@ -2642,30 +2805,36 @@ function sprigConversions() {
|
|
|
2642
2805
|
atoi: {
|
|
2643
2806
|
fn: (s) => atoi(s),
|
|
2644
2807
|
argTypes: ["string"],
|
|
2808
|
+
arity: { kind: "exact" },
|
|
2645
2809
|
returnType: "int"
|
|
2646
2810
|
},
|
|
2647
2811
|
int: {
|
|
2648
2812
|
fn: (v) => int(v),
|
|
2649
2813
|
argTypes: ["value"],
|
|
2814
|
+
arity: { kind: "exact" },
|
|
2650
2815
|
returnType: "int"
|
|
2651
2816
|
},
|
|
2652
2817
|
int64: {
|
|
2653
2818
|
fn: (v) => int64(v),
|
|
2654
|
-
argTypes: ["value"]
|
|
2819
|
+
argTypes: ["value"],
|
|
2820
|
+
arity: { kind: "exact" }
|
|
2655
2821
|
},
|
|
2656
2822
|
float64: {
|
|
2657
2823
|
fn: (v) => float64(v),
|
|
2658
2824
|
argTypes: ["value"],
|
|
2825
|
+
arity: { kind: "exact" },
|
|
2659
2826
|
returnType: "float"
|
|
2660
2827
|
},
|
|
2661
2828
|
toDecimal: {
|
|
2662
2829
|
fn: (s) => toDecimal(s),
|
|
2663
2830
|
argTypes: ["string"],
|
|
2831
|
+
arity: { kind: "exact" },
|
|
2664
2832
|
returnType: "int"
|
|
2665
2833
|
},
|
|
2666
2834
|
toRawJson: {
|
|
2667
2835
|
fn: (v) => toRawJson(v),
|
|
2668
2836
|
argTypes: ["serializable"],
|
|
2837
|
+
arity: { kind: "exact" },
|
|
2669
2838
|
returnType: "string"
|
|
2670
2839
|
}
|
|
2671
2840
|
};
|
|
@@ -3557,11 +3726,13 @@ function sprigDatetime(clock = () => /* @__PURE__ */ new Date()) {
|
|
|
3557
3726
|
return {
|
|
3558
3727
|
now: {
|
|
3559
3728
|
fn: () => now(clock),
|
|
3560
|
-
argTypes: []
|
|
3729
|
+
argTypes: [],
|
|
3730
|
+
arity: { kind: "exact" }
|
|
3561
3731
|
},
|
|
3562
3732
|
date: {
|
|
3563
3733
|
fn: (format, t) => date(format, t),
|
|
3564
|
-
argTypes: ["string", "value"]
|
|
3734
|
+
argTypes: ["string", "value"],
|
|
3735
|
+
arity: { kind: "exact" }
|
|
3565
3736
|
},
|
|
3566
3737
|
dateInZone: {
|
|
3567
3738
|
fn: (format, t, zone) => dateInZone(format, t, zone),
|
|
@@ -3569,39 +3740,48 @@ function sprigDatetime(clock = () => /* @__PURE__ */ new Date()) {
|
|
|
3569
3740
|
"string",
|
|
3570
3741
|
"value",
|
|
3571
3742
|
"string"
|
|
3572
|
-
]
|
|
3743
|
+
],
|
|
3744
|
+
arity: { kind: "exact" }
|
|
3573
3745
|
},
|
|
3574
3746
|
dateModify: {
|
|
3575
3747
|
fn: (dur, t) => dateModify(dur, t),
|
|
3576
|
-
argTypes: ["string", "value"]
|
|
3748
|
+
argTypes: ["string", "value"],
|
|
3749
|
+
arity: { kind: "exact" }
|
|
3577
3750
|
},
|
|
3578
3751
|
htmlDate: {
|
|
3579
3752
|
fn: (t) => htmlDate(t),
|
|
3580
|
-
argTypes: ["value"]
|
|
3753
|
+
argTypes: ["value"],
|
|
3754
|
+
arity: { kind: "exact" }
|
|
3581
3755
|
},
|
|
3582
3756
|
htmlDateInZone: {
|
|
3583
3757
|
fn: (t, zone) => htmlDateInZone(t, zone),
|
|
3584
|
-
argTypes: ["value", "string"]
|
|
3758
|
+
argTypes: ["value", "string"],
|
|
3759
|
+
arity: { kind: "exact" }
|
|
3585
3760
|
},
|
|
3586
3761
|
duration: {
|
|
3587
3762
|
fn: (sec) => duration(sec),
|
|
3588
|
-
argTypes: ["value"]
|
|
3763
|
+
argTypes: ["value"],
|
|
3764
|
+
arity: { kind: "exact" }
|
|
3589
3765
|
},
|
|
3590
3766
|
durationRound: {
|
|
3591
3767
|
fn: (d) => durationRound(d),
|
|
3592
|
-
argTypes: ["value"]
|
|
3768
|
+
argTypes: ["value"],
|
|
3769
|
+
arity: { kind: "exact" }
|
|
3593
3770
|
},
|
|
3594
3771
|
toDate: {
|
|
3595
3772
|
fn: (format, s) => toDate(format, s),
|
|
3596
|
-
argTypes: ["string", "string"]
|
|
3773
|
+
argTypes: ["string", "string"],
|
|
3774
|
+
arity: { kind: "exact" }
|
|
3597
3775
|
},
|
|
3598
3776
|
ago: {
|
|
3599
3777
|
fn: (t) => ago(t, clock),
|
|
3600
|
-
argTypes: ["value"]
|
|
3778
|
+
argTypes: ["value"],
|
|
3779
|
+
arity: { kind: "exact" }
|
|
3601
3780
|
},
|
|
3602
3781
|
unixEpoch: {
|
|
3603
3782
|
fn: (t) => unixEpoch(t),
|
|
3604
|
-
argTypes: ["value"]
|
|
3783
|
+
argTypes: ["value"],
|
|
3784
|
+
arity: { kind: "exact" }
|
|
3605
3785
|
}
|
|
3606
3786
|
};
|
|
3607
3787
|
}
|
|
@@ -3700,15 +3880,18 @@ function sprigDefaults() {
|
|
|
3700
3880
|
return {
|
|
3701
3881
|
default: {
|
|
3702
3882
|
fn: (a, b) => defaultFn(a, b),
|
|
3703
|
-
argTypes: ["value", "truthy"]
|
|
3883
|
+
argTypes: ["value", "truthy"],
|
|
3884
|
+
arity: { kind: "variadic" }
|
|
3704
3885
|
},
|
|
3705
3886
|
empty: {
|
|
3706
3887
|
fn: (v) => empty(v),
|
|
3707
|
-
argTypes: ["truthy"]
|
|
3888
|
+
argTypes: ["truthy"],
|
|
3889
|
+
arity: { kind: "exact" }
|
|
3708
3890
|
},
|
|
3709
3891
|
coalesce: {
|
|
3710
3892
|
fn: (...vs) => coalesce(...vs),
|
|
3711
|
-
argTypes: ["truthy"]
|
|
3893
|
+
argTypes: ["truthy"],
|
|
3894
|
+
arity: { kind: "variadic" }
|
|
3712
3895
|
},
|
|
3713
3896
|
ternary: {
|
|
3714
3897
|
fn: (a, b, c) => ternary(a, b, c),
|
|
@@ -3716,20 +3899,24 @@ function sprigDefaults() {
|
|
|
3716
3899
|
"value",
|
|
3717
3900
|
"value",
|
|
3718
3901
|
"truthy"
|
|
3719
|
-
]
|
|
3902
|
+
],
|
|
3903
|
+
arity: { kind: "exact" }
|
|
3720
3904
|
},
|
|
3721
3905
|
fromJson: {
|
|
3722
3906
|
fn: (s) => fromJson(s),
|
|
3723
|
-
argTypes: ["string"]
|
|
3907
|
+
argTypes: ["string"],
|
|
3908
|
+
arity: { kind: "exact" }
|
|
3724
3909
|
},
|
|
3725
3910
|
toJson: {
|
|
3726
3911
|
fn: (v) => toJson(v),
|
|
3727
3912
|
argTypes: ["serializable"],
|
|
3913
|
+
arity: { kind: "exact" },
|
|
3728
3914
|
returnType: "string"
|
|
3729
3915
|
},
|
|
3730
3916
|
toPrettyJson: {
|
|
3731
3917
|
fn: (v) => toPrettyJson(v),
|
|
3732
3918
|
argTypes: ["serializable"],
|
|
3919
|
+
arity: { kind: "exact" },
|
|
3733
3920
|
returnType: "string"
|
|
3734
3921
|
}
|
|
3735
3922
|
};
|
|
@@ -3919,11 +4106,15 @@ function sprigDicts() {
|
|
|
3919
4106
|
dict: {
|
|
3920
4107
|
fn: (...kv) => dict(...kv),
|
|
3921
4108
|
argTypes: ["string", "value"],
|
|
3922
|
-
|
|
4109
|
+
arity: {
|
|
4110
|
+
kind: "alternating",
|
|
4111
|
+
minimum: 0
|
|
4112
|
+
}
|
|
3923
4113
|
},
|
|
3924
4114
|
get: {
|
|
3925
4115
|
fn: (d, k) => get(d, k),
|
|
3926
|
-
argTypes: ["dict", "string"]
|
|
4116
|
+
argTypes: ["dict", "string"],
|
|
4117
|
+
arity: { kind: "exact" }
|
|
3927
4118
|
},
|
|
3928
4119
|
set: {
|
|
3929
4120
|
fn: (d, k, v) => set(d, k, v),
|
|
@@ -3931,43 +4122,53 @@ function sprigDicts() {
|
|
|
3931
4122
|
"dict",
|
|
3932
4123
|
"string",
|
|
3933
4124
|
"value"
|
|
3934
|
-
]
|
|
4125
|
+
],
|
|
4126
|
+
arity: { kind: "exact" }
|
|
3935
4127
|
},
|
|
3936
4128
|
unset: {
|
|
3937
4129
|
fn: (d, k) => unset(d, k),
|
|
3938
|
-
argTypes: ["dict", "string"]
|
|
4130
|
+
argTypes: ["dict", "string"],
|
|
4131
|
+
arity: { kind: "exact" }
|
|
3939
4132
|
},
|
|
3940
4133
|
keys: {
|
|
3941
4134
|
fn: (d) => keys(d),
|
|
3942
|
-
argTypes: ["dict"]
|
|
4135
|
+
argTypes: ["dict"],
|
|
4136
|
+
arity: { kind: "variadic" }
|
|
3943
4137
|
},
|
|
3944
4138
|
values: {
|
|
3945
4139
|
fn: (d) => values(d),
|
|
3946
|
-
argTypes: ["dict"]
|
|
4140
|
+
argTypes: ["dict"],
|
|
4141
|
+
arity: { kind: "exact" }
|
|
3947
4142
|
},
|
|
3948
4143
|
pluck: {
|
|
3949
4144
|
fn: (k, ...d) => pluck(k, ...d),
|
|
3950
|
-
argTypes: ["string", "dict"]
|
|
4145
|
+
argTypes: ["string", "dict"],
|
|
4146
|
+
arity: { kind: "variadic" }
|
|
3951
4147
|
},
|
|
3952
4148
|
pick: {
|
|
3953
4149
|
fn: (d, ...k) => pick(d, ...k),
|
|
3954
|
-
argTypes: ["dict", "string"]
|
|
4150
|
+
argTypes: ["dict", "string"],
|
|
4151
|
+
arity: { kind: "variadic" }
|
|
3955
4152
|
},
|
|
3956
4153
|
omit: {
|
|
3957
4154
|
fn: (d, ...k) => omit(d, ...k),
|
|
3958
|
-
argTypes: ["dict", "string"]
|
|
4155
|
+
argTypes: ["dict", "string"],
|
|
4156
|
+
arity: { kind: "variadic" }
|
|
3959
4157
|
},
|
|
3960
4158
|
hasKey: {
|
|
3961
4159
|
fn: (d, k) => hasKey(d, k),
|
|
3962
|
-
argTypes: ["dict", "string"]
|
|
4160
|
+
argTypes: ["dict", "string"],
|
|
4161
|
+
arity: { kind: "exact" }
|
|
3963
4162
|
},
|
|
3964
4163
|
merge: {
|
|
3965
4164
|
fn: (d, ...s) => merge(d, ...s),
|
|
3966
|
-
argTypes: ["dict"]
|
|
4165
|
+
argTypes: ["dict", "dict"],
|
|
4166
|
+
arity: { kind: "variadic" }
|
|
3967
4167
|
},
|
|
3968
4168
|
mergeOverwrite: {
|
|
3969
4169
|
fn: (d, ...s) => mergeOverwrite(d, ...s),
|
|
3970
|
-
argTypes: ["dict"]
|
|
4170
|
+
argTypes: ["dict", "dict"],
|
|
4171
|
+
arity: { kind: "variadic" }
|
|
3971
4172
|
}
|
|
3972
4173
|
};
|
|
3973
4174
|
}
|
|
@@ -3992,7 +4193,8 @@ function fail(msg) {
|
|
|
3992
4193
|
function sprigFlow() {
|
|
3993
4194
|
return { fail: {
|
|
3994
4195
|
fn: (msg) => fail(msg),
|
|
3995
|
-
argTypes: ["string"]
|
|
4196
|
+
argTypes: ["string"],
|
|
4197
|
+
arity: { kind: "exact" }
|
|
3996
4198
|
} };
|
|
3997
4199
|
}
|
|
3998
4200
|
//#endregion
|
|
@@ -4124,39 +4326,48 @@ function sprigHash() {
|
|
|
4124
4326
|
return {
|
|
4125
4327
|
b64enc: {
|
|
4126
4328
|
fn: (s) => b64enc(s),
|
|
4127
|
-
argTypes: ["string"]
|
|
4329
|
+
argTypes: ["string"],
|
|
4330
|
+
arity: { kind: "exact" }
|
|
4128
4331
|
},
|
|
4129
4332
|
b64dec: {
|
|
4130
4333
|
fn: (s) => b64dec(s),
|
|
4131
|
-
argTypes: ["string"]
|
|
4334
|
+
argTypes: ["string"],
|
|
4335
|
+
arity: { kind: "exact" }
|
|
4132
4336
|
},
|
|
4133
4337
|
b32enc: {
|
|
4134
4338
|
fn: (s) => b32enc(s),
|
|
4135
|
-
argTypes: ["string"]
|
|
4339
|
+
argTypes: ["string"],
|
|
4340
|
+
arity: { kind: "exact" }
|
|
4136
4341
|
},
|
|
4137
4342
|
b32dec: {
|
|
4138
4343
|
fn: (s) => b32dec(s),
|
|
4139
|
-
argTypes: ["string"]
|
|
4344
|
+
argTypes: ["string"],
|
|
4345
|
+
arity: { kind: "exact" }
|
|
4140
4346
|
},
|
|
4141
4347
|
sha1sum: {
|
|
4142
4348
|
fn: (s) => sha1sum(s),
|
|
4143
|
-
argTypes: ["string"]
|
|
4349
|
+
argTypes: ["string"],
|
|
4350
|
+
arity: { kind: "exact" }
|
|
4144
4351
|
},
|
|
4145
4352
|
sha256sum: {
|
|
4146
4353
|
fn: (s) => sha256sum(s),
|
|
4147
|
-
argTypes: ["string"]
|
|
4354
|
+
argTypes: ["string"],
|
|
4355
|
+
arity: { kind: "exact" }
|
|
4148
4356
|
},
|
|
4149
4357
|
sha512sum: {
|
|
4150
4358
|
fn: (s) => sha512sum(s),
|
|
4151
|
-
argTypes: ["string"]
|
|
4359
|
+
argTypes: ["string"],
|
|
4360
|
+
arity: { kind: "exact" }
|
|
4152
4361
|
},
|
|
4153
4362
|
adler32sum: {
|
|
4154
4363
|
fn: (s) => adler32sum(s),
|
|
4155
|
-
argTypes: ["string"]
|
|
4364
|
+
argTypes: ["string"],
|
|
4365
|
+
arity: { kind: "exact" }
|
|
4156
4366
|
},
|
|
4157
4367
|
uuidv4: {
|
|
4158
4368
|
fn: () => uuidv4(),
|
|
4159
|
-
argTypes: []
|
|
4369
|
+
argTypes: [],
|
|
4370
|
+
arity: { kind: "exact" }
|
|
4160
4371
|
}
|
|
4161
4372
|
};
|
|
4162
4373
|
}
|
|
@@ -4404,97 +4615,115 @@ function sprigLists() {
|
|
|
4404
4615
|
return {
|
|
4405
4616
|
list: {
|
|
4406
4617
|
fn: (...a) => list(...a),
|
|
4407
|
-
argTypes: ["value"]
|
|
4618
|
+
argTypes: ["value"],
|
|
4619
|
+
arity: { kind: "variadic" }
|
|
4408
4620
|
},
|
|
4409
4621
|
first: {
|
|
4410
4622
|
fn: (l) => first(l),
|
|
4411
|
-
argTypes: ["list"]
|
|
4623
|
+
argTypes: ["list"],
|
|
4624
|
+
arity: { kind: "exact" }
|
|
4412
4625
|
},
|
|
4413
4626
|
last: {
|
|
4414
4627
|
fn: (l) => last(l),
|
|
4415
|
-
argTypes: ["list"]
|
|
4628
|
+
argTypes: ["list"],
|
|
4629
|
+
arity: { kind: "exact" }
|
|
4416
4630
|
},
|
|
4417
4631
|
rest: {
|
|
4418
4632
|
fn: (l) => rest(l),
|
|
4419
|
-
argTypes: ["list"]
|
|
4633
|
+
argTypes: ["list"],
|
|
4634
|
+
arity: { kind: "exact" }
|
|
4420
4635
|
},
|
|
4421
4636
|
initial: {
|
|
4422
4637
|
fn: (l) => initial(l),
|
|
4423
|
-
argTypes: ["list"]
|
|
4638
|
+
argTypes: ["list"],
|
|
4639
|
+
arity: { kind: "exact" }
|
|
4424
4640
|
},
|
|
4425
4641
|
len: {
|
|
4426
4642
|
fn: (l) => len(l),
|
|
4427
|
-
argTypes: ["sized"]
|
|
4643
|
+
argTypes: ["sized"],
|
|
4644
|
+
arity: { kind: "exact" }
|
|
4428
4645
|
},
|
|
4429
4646
|
reverse: {
|
|
4430
4647
|
fn: (l) => reverse(l),
|
|
4431
|
-
argTypes: ["list"]
|
|
4648
|
+
argTypes: ["list"],
|
|
4649
|
+
arity: { kind: "exact" }
|
|
4432
4650
|
},
|
|
4433
4651
|
uniq: {
|
|
4434
4652
|
fn: (l) => uniq(l),
|
|
4435
|
-
argTypes: ["list"]
|
|
4653
|
+
argTypes: ["list"],
|
|
4654
|
+
arity: { kind: "exact" }
|
|
4436
4655
|
},
|
|
4437
4656
|
without: {
|
|
4438
4657
|
fn: (l, ...e) => without(l, ...e),
|
|
4439
|
-
argTypes: ["list", "value"]
|
|
4658
|
+
argTypes: ["list", "value"],
|
|
4659
|
+
arity: { kind: "variadic" }
|
|
4440
4660
|
},
|
|
4441
4661
|
has: {
|
|
4442
4662
|
fn: (i, l) => has(i, l),
|
|
4443
|
-
argTypes: ["value", "list"]
|
|
4663
|
+
argTypes: ["value", "list"],
|
|
4664
|
+
arity: { kind: "exact" }
|
|
4444
4665
|
},
|
|
4445
4666
|
compact: {
|
|
4446
4667
|
fn: (l) => compact(l),
|
|
4447
|
-
argTypes: ["list"]
|
|
4668
|
+
argTypes: ["list"],
|
|
4669
|
+
arity: { kind: "exact" }
|
|
4448
4670
|
},
|
|
4449
4671
|
slice: {
|
|
4450
4672
|
fn: (l, i, j) => slice(l, i, j),
|
|
4451
|
-
argTypes: [
|
|
4452
|
-
|
|
4453
|
-
"int",
|
|
4454
|
-
"int"
|
|
4455
|
-
]
|
|
4673
|
+
argTypes: ["list", "truncating-int"],
|
|
4674
|
+
arity: { kind: "variadic" }
|
|
4456
4675
|
},
|
|
4457
4676
|
concat: {
|
|
4458
4677
|
fn: (...l) => concat(...l),
|
|
4459
|
-
argTypes: ["list"]
|
|
4678
|
+
argTypes: ["list"],
|
|
4679
|
+
arity: { kind: "variadic" }
|
|
4460
4680
|
},
|
|
4461
4681
|
chunk: {
|
|
4462
4682
|
fn: (s, l) => chunk(s, l),
|
|
4463
|
-
argTypes: ["int", "list"]
|
|
4683
|
+
argTypes: ["int", "list"],
|
|
4684
|
+
arity: { kind: "exact" }
|
|
4464
4685
|
},
|
|
4465
4686
|
prepend: {
|
|
4466
4687
|
fn: (l, i) => prepend(l, i),
|
|
4467
|
-
argTypes: ["list", "value"]
|
|
4688
|
+
argTypes: ["list", "value"],
|
|
4689
|
+
arity: { kind: "exact" }
|
|
4468
4690
|
},
|
|
4469
4691
|
append: {
|
|
4470
4692
|
fn: (l, i) => append(l, i),
|
|
4471
|
-
argTypes: ["list", "value"]
|
|
4693
|
+
argTypes: ["list", "value"],
|
|
4694
|
+
arity: { kind: "exact" }
|
|
4472
4695
|
},
|
|
4473
4696
|
sortAlpha: {
|
|
4474
4697
|
fn: (l) => sortAlpha(l),
|
|
4475
4698
|
argTypes: ["list"],
|
|
4699
|
+
arity: { kind: "exact" },
|
|
4476
4700
|
returnType: "list"
|
|
4477
4701
|
},
|
|
4478
4702
|
push: {
|
|
4479
4703
|
fn: (l, i) => append(l, i),
|
|
4480
|
-
argTypes: ["list", "value"]
|
|
4704
|
+
argTypes: ["list", "value"],
|
|
4705
|
+
arity: { kind: "exact" }
|
|
4481
4706
|
},
|
|
4482
4707
|
tuple: {
|
|
4483
4708
|
fn: (...a) => list(...a),
|
|
4484
|
-
argTypes: ["value"]
|
|
4709
|
+
argTypes: ["value"],
|
|
4710
|
+
arity: { kind: "variadic" }
|
|
4485
4711
|
},
|
|
4486
4712
|
dig: {
|
|
4487
4713
|
fn: (...a) => dig(...a),
|
|
4488
|
-
argTypes: ["value"]
|
|
4714
|
+
argTypes: ["value"],
|
|
4715
|
+
arity: { kind: "variadic" }
|
|
4489
4716
|
},
|
|
4490
4717
|
all: {
|
|
4491
4718
|
fn: (...a) => all(...a),
|
|
4492
4719
|
argTypes: ["truthy"],
|
|
4720
|
+
arity: { kind: "variadic" },
|
|
4493
4721
|
returnType: "bool"
|
|
4494
4722
|
},
|
|
4495
4723
|
any: {
|
|
4496
4724
|
fn: (...a) => any(...a),
|
|
4497
4725
|
argTypes: ["truthy"],
|
|
4726
|
+
arity: { kind: "variadic" },
|
|
4498
4727
|
returnType: "bool"
|
|
4499
4728
|
}
|
|
4500
4729
|
};
|
|
@@ -4535,8 +4764,8 @@ function div(a, b) {
|
|
|
4535
4764
|
}
|
|
4536
4765
|
//#endregion
|
|
4537
4766
|
//#region src/sprig/math/divf.ts
|
|
4538
|
-
function divf(a,
|
|
4539
|
-
return
|
|
4767
|
+
function divf(a, ...rest) {
|
|
4768
|
+
return rest.reduce((acc, v) => acc / v, a);
|
|
4540
4769
|
}
|
|
4541
4770
|
//#endregion
|
|
4542
4771
|
//#region src/sprig/math/floor.ts
|
|
@@ -4671,8 +4900,8 @@ function sub(a, b) {
|
|
|
4671
4900
|
}
|
|
4672
4901
|
//#endregion
|
|
4673
4902
|
//#region src/sprig/math/subf.ts
|
|
4674
|
-
function subf(a,
|
|
4675
|
-
return
|
|
4903
|
+
function subf(a, ...rest) {
|
|
4904
|
+
return rest.reduce((acc, v) => acc - v, a);
|
|
4676
4905
|
}
|
|
4677
4906
|
//#endregion
|
|
4678
4907
|
//#region src/sprig/math/until.ts
|
|
@@ -4691,88 +4920,113 @@ function sprigMath() {
|
|
|
4691
4920
|
return {
|
|
4692
4921
|
add: {
|
|
4693
4922
|
fn: (...a) => add(...a),
|
|
4694
|
-
argTypes: ["int"]
|
|
4923
|
+
argTypes: ["truncating-int"],
|
|
4924
|
+
arity: { kind: "variadic" }
|
|
4695
4925
|
},
|
|
4696
4926
|
sub: {
|
|
4697
4927
|
fn: (a, b) => sub(a, b),
|
|
4698
|
-
argTypes: ["int", "int"]
|
|
4928
|
+
argTypes: ["truncating-int", "truncating-int"],
|
|
4929
|
+
arity: { kind: "exact" }
|
|
4699
4930
|
},
|
|
4700
4931
|
mul: {
|
|
4701
4932
|
fn: (...a) => mul(...a),
|
|
4702
|
-
argTypes: ["int"]
|
|
4933
|
+
argTypes: ["truncating-int", "truncating-int"],
|
|
4934
|
+
arity: { kind: "variadic" }
|
|
4703
4935
|
},
|
|
4704
4936
|
div: {
|
|
4705
4937
|
fn: (a, b) => div(a, b),
|
|
4706
|
-
argTypes: ["int", "int"]
|
|
4938
|
+
argTypes: ["truncating-int", "truncating-int"],
|
|
4939
|
+
arity: { kind: "exact" }
|
|
4707
4940
|
},
|
|
4708
4941
|
mod: {
|
|
4709
4942
|
fn: (a, b) => mod(a, b),
|
|
4710
|
-
argTypes: ["int", "int"]
|
|
4943
|
+
argTypes: ["truncating-int", "truncating-int"],
|
|
4944
|
+
arity: { kind: "exact" }
|
|
4711
4945
|
},
|
|
4712
4946
|
min: {
|
|
4713
4947
|
fn: (...a) => min(...a),
|
|
4714
|
-
argTypes: ["int"]
|
|
4948
|
+
argTypes: ["truncating-int", "truncating-int"],
|
|
4949
|
+
arity: { kind: "variadic" }
|
|
4715
4950
|
},
|
|
4716
4951
|
max: {
|
|
4717
4952
|
fn: (...a) => max(...a),
|
|
4718
|
-
argTypes: ["int"]
|
|
4953
|
+
argTypes: ["truncating-int", "truncating-int"],
|
|
4954
|
+
arity: { kind: "variadic" }
|
|
4719
4955
|
},
|
|
4720
4956
|
floor: {
|
|
4721
4957
|
fn: (a) => floor(a),
|
|
4722
|
-
argTypes: ["float"]
|
|
4958
|
+
argTypes: ["float"],
|
|
4959
|
+
arity: { kind: "exact" }
|
|
4723
4960
|
},
|
|
4724
4961
|
ceil: {
|
|
4725
4962
|
fn: (a) => ceil(a),
|
|
4726
|
-
argTypes: ["float"]
|
|
4963
|
+
argTypes: ["float"],
|
|
4964
|
+
arity: { kind: "exact" }
|
|
4727
4965
|
},
|
|
4728
4966
|
round: {
|
|
4729
4967
|
fn: (a, p) => round(a, p),
|
|
4730
|
-
argTypes: [
|
|
4968
|
+
argTypes: [
|
|
4969
|
+
"float",
|
|
4970
|
+
"int",
|
|
4971
|
+
"float"
|
|
4972
|
+
],
|
|
4973
|
+
arity: { kind: "variadic" }
|
|
4731
4974
|
},
|
|
4732
4975
|
addf: {
|
|
4733
4976
|
fn: (...a) => addf(...a),
|
|
4734
|
-
argTypes: ["float"]
|
|
4977
|
+
argTypes: ["float"],
|
|
4978
|
+
arity: { kind: "variadic" }
|
|
4735
4979
|
},
|
|
4736
4980
|
subf: {
|
|
4737
|
-
fn: (a,
|
|
4738
|
-
argTypes: ["float", "float"]
|
|
4981
|
+
fn: (a, ...rest) => subf(a, ...rest),
|
|
4982
|
+
argTypes: ["float", "float"],
|
|
4983
|
+
arity: { kind: "variadic" }
|
|
4739
4984
|
},
|
|
4740
4985
|
mulf: {
|
|
4741
4986
|
fn: (...a) => mulf(...a),
|
|
4742
|
-
argTypes: ["float"]
|
|
4987
|
+
argTypes: ["float", "float"],
|
|
4988
|
+
arity: { kind: "variadic" }
|
|
4743
4989
|
},
|
|
4744
4990
|
divf: {
|
|
4745
|
-
fn: (a,
|
|
4746
|
-
argTypes: ["float", "float"]
|
|
4991
|
+
fn: (a, ...rest) => divf(a, ...rest),
|
|
4992
|
+
argTypes: ["float", "float"],
|
|
4993
|
+
arity: { kind: "variadic" }
|
|
4747
4994
|
},
|
|
4748
4995
|
add1: {
|
|
4749
4996
|
fn: (n) => add1(n),
|
|
4750
|
-
argTypes: ["int"]
|
|
4997
|
+
argTypes: ["truncating-int"],
|
|
4998
|
+
arity: { kind: "exact" }
|
|
4751
4999
|
},
|
|
4752
5000
|
add1f: {
|
|
4753
5001
|
fn: (n) => add1f(n),
|
|
4754
|
-
argTypes: ["float"]
|
|
5002
|
+
argTypes: ["float"],
|
|
5003
|
+
arity: { kind: "exact" }
|
|
4755
5004
|
},
|
|
4756
5005
|
maxf: {
|
|
4757
5006
|
fn: (...a) => maxf(...a),
|
|
4758
|
-
argTypes: ["float"]
|
|
5007
|
+
argTypes: ["float", "float"],
|
|
5008
|
+
arity: { kind: "variadic" }
|
|
4759
5009
|
},
|
|
4760
5010
|
minf: {
|
|
4761
5011
|
fn: (...a) => minf(...a),
|
|
4762
|
-
argTypes: ["float"]
|
|
5012
|
+
argTypes: ["float", "float"],
|
|
5013
|
+
arity: { kind: "variadic" }
|
|
4763
5014
|
},
|
|
4764
5015
|
biggest: {
|
|
4765
5016
|
fn: (...a) => max(...a),
|
|
4766
|
-
argTypes: ["int"]
|
|
5017
|
+
argTypes: ["truncating-int", "truncating-int"],
|
|
5018
|
+
arity: { kind: "variadic" }
|
|
4767
5019
|
},
|
|
4768
5020
|
seq: {
|
|
4769
5021
|
fn: (...a) => seq(...a),
|
|
4770
5022
|
argTypes: ["int"],
|
|
5023
|
+
arity: { kind: "variadic" },
|
|
4771
5024
|
returnType: "string"
|
|
4772
5025
|
},
|
|
4773
5026
|
until: {
|
|
4774
5027
|
fn: (n) => until(n),
|
|
4775
5028
|
argTypes: ["int"],
|
|
5029
|
+
arity: { kind: "exact" },
|
|
4776
5030
|
returnType: "list"
|
|
4777
5031
|
},
|
|
4778
5032
|
untilStep: {
|
|
@@ -4782,6 +5036,7 @@ function sprigMath() {
|
|
|
4782
5036
|
"int",
|
|
4783
5037
|
"int"
|
|
4784
5038
|
],
|
|
5039
|
+
arity: { kind: "exact" },
|
|
4785
5040
|
returnType: "list"
|
|
4786
5041
|
}
|
|
4787
5042
|
};
|
|
@@ -4856,6 +5111,51 @@ function randNumeric(n, random) {
|
|
|
4856
5111
|
return randString(n, NUMERIC, random);
|
|
4857
5112
|
}
|
|
4858
5113
|
//#endregion
|
|
5114
|
+
//#region src/sprig/strings/runes.ts
|
|
5115
|
+
/**
|
|
5116
|
+
* The rune-level string seam: the operations Go gets for free on its
|
|
5117
|
+
* strings and JS does not.
|
|
5118
|
+
*
|
|
5119
|
+
* [LAW:parse-dont-validate] Go walks a string as runes; JS strings are
|
|
5120
|
+
* UTF-16, so a character-position operation done on the raw string
|
|
5121
|
+
* (`s.slice(0, 1)`, `s[i]`, `s.length`, `s.split("")`) splits an astral
|
|
5122
|
+
* character in half and yields a lone surrogate — `trunc 1 "𐍈x"`
|
|
5123
|
+
* returned "\ud800", for which `isWellFormed()` is false. Decoding once,
|
|
5124
|
+
* up front, is the checkpoint: every element of the returned array is a
|
|
5125
|
+
* whole character, so an index into the middle of one is unrepresentable
|
|
5126
|
+
* and no slice of it can produce a lone surrogate. Callers re-encode
|
|
5127
|
+
* with `.join("")`.
|
|
5128
|
+
*
|
|
5129
|
+
* Code points deliberately — not UTF-16 units, and not grapheme
|
|
5130
|
+
* clusters. Grapheme clustering would hold `"é"` together, a third
|
|
5131
|
+
* behaviour matching neither Go nor this engine.
|
|
5132
|
+
*
|
|
5133
|
+
* For splitting this buys exact Go parity. For slicing it buys
|
|
5134
|
+
* well-formedness instead: Go slices `trunc`/`substr`/`abbrev` by BYTE,
|
|
5135
|
+
* so `trunc 1 "𐍈x"` is the single invalid byte `\xf0` there and the
|
|
5136
|
+
* whole `𐍈` here. That residual divergence is intended and tracked
|
|
5137
|
+
* separately; a rune is the closest well-formed unit to Go's byte.
|
|
5138
|
+
*/
|
|
5139
|
+
/**
|
|
5140
|
+
* Decode `s` to its code points. The array is freshly built per call,
|
|
5141
|
+
* so callers may permute it in place (`shuffle` does).
|
|
5142
|
+
*/
|
|
5143
|
+
function runes(s) {
|
|
5144
|
+
return Array.from(s);
|
|
5145
|
+
}
|
|
5146
|
+
/**
|
|
5147
|
+
* `strings.Split(s, sep)` — an empty separator splits between runes,
|
|
5148
|
+
* where JS's `s.split("")` splits between UTF-16 units and shears
|
|
5149
|
+
* astral characters into lone surrogates.
|
|
5150
|
+
*
|
|
5151
|
+
* [LAW:single-enforcer] `split`, `splitList`, `splitn`, and `replace`
|
|
5152
|
+
* all reach for Go's split; the empty-separator rule lives here so the
|
|
5153
|
+
* four cannot drift on it.
|
|
5154
|
+
*/
|
|
5155
|
+
function goSplit(sep, s) {
|
|
5156
|
+
return sep === "" ? runes(s) : s.split(sep);
|
|
5157
|
+
}
|
|
5158
|
+
//#endregion
|
|
4859
5159
|
//#region src/sprig/random/shuffle.ts
|
|
4860
5160
|
/**
|
|
4861
5161
|
* `shuffle s` — returns a randomly permuted copy of `s`.
|
|
@@ -4863,14 +5163,14 @@ function randNumeric(n, random) {
|
|
|
4863
5163
|
* Operates on Unicode code points (matching Go sprig's rune-level Fisher-Yates).
|
|
4864
5164
|
*/
|
|
4865
5165
|
function shuffle(s, random) {
|
|
4866
|
-
const
|
|
4867
|
-
for (let i =
|
|
5166
|
+
const cps = runes(s);
|
|
5167
|
+
for (let i = cps.length - 1; i > 0; i--) {
|
|
4868
5168
|
const j = Math.floor(clampRandom(random()) * (i + 1));
|
|
4869
|
-
const tmp =
|
|
4870
|
-
|
|
4871
|
-
|
|
5169
|
+
const tmp = cps[i];
|
|
5170
|
+
cps[i] = cps[j];
|
|
5171
|
+
cps[j] = tmp;
|
|
4872
5172
|
}
|
|
4873
|
-
return
|
|
5173
|
+
return cps.join("");
|
|
4874
5174
|
}
|
|
4875
5175
|
//#endregion
|
|
4876
5176
|
//#region src/sprig/random/index.ts
|
|
@@ -4884,27 +5184,33 @@ function sprigRandom(random = Math.random) {
|
|
|
4884
5184
|
return {
|
|
4885
5185
|
randInt: {
|
|
4886
5186
|
fn: (min, max) => randInt(min, max, random),
|
|
4887
|
-
argTypes: ["int", "int"]
|
|
5187
|
+
argTypes: ["int", "int"],
|
|
5188
|
+
arity: { kind: "exact" }
|
|
4888
5189
|
},
|
|
4889
5190
|
randAlpha: {
|
|
4890
5191
|
fn: (n) => randAlpha(n, random),
|
|
4891
|
-
argTypes: ["int"]
|
|
5192
|
+
argTypes: ["int"],
|
|
5193
|
+
arity: { kind: "exact" }
|
|
4892
5194
|
},
|
|
4893
5195
|
randAlphaNum: {
|
|
4894
5196
|
fn: (n) => randAlphaNum(n, random),
|
|
4895
|
-
argTypes: ["int"]
|
|
5197
|
+
argTypes: ["int"],
|
|
5198
|
+
arity: { kind: "exact" }
|
|
4896
5199
|
},
|
|
4897
5200
|
randNumeric: {
|
|
4898
5201
|
fn: (n) => randNumeric(n, random),
|
|
4899
|
-
argTypes: ["int"]
|
|
5202
|
+
argTypes: ["int"],
|
|
5203
|
+
arity: { kind: "exact" }
|
|
4900
5204
|
},
|
|
4901
5205
|
randAscii: {
|
|
4902
5206
|
fn: (n) => randAscii(n, random),
|
|
4903
|
-
argTypes: ["int"]
|
|
5207
|
+
argTypes: ["int"],
|
|
5208
|
+
arity: { kind: "exact" }
|
|
4904
5209
|
},
|
|
4905
5210
|
shuffle: {
|
|
4906
5211
|
fn: (s) => shuffle(s, random),
|
|
4907
|
-
argTypes: ["string"]
|
|
5212
|
+
argTypes: ["string"],
|
|
5213
|
+
arity: { kind: "exact" }
|
|
4908
5214
|
}
|
|
4909
5215
|
};
|
|
4910
5216
|
}
|
|
@@ -4970,11 +5276,13 @@ function sprigRegex() {
|
|
|
4970
5276
|
return {
|
|
4971
5277
|
regexMatch: {
|
|
4972
5278
|
fn: (p, s) => regexMatch(p, s),
|
|
4973
|
-
argTypes: ["string", "string"]
|
|
5279
|
+
argTypes: ["string", "string"],
|
|
5280
|
+
arity: { kind: "exact" }
|
|
4974
5281
|
},
|
|
4975
5282
|
regexFind: {
|
|
4976
5283
|
fn: (p, s) => regexFind(p, s),
|
|
4977
|
-
argTypes: ["string", "string"]
|
|
5284
|
+
argTypes: ["string", "string"],
|
|
5285
|
+
arity: { kind: "exact" }
|
|
4978
5286
|
},
|
|
4979
5287
|
regexFindAll: {
|
|
4980
5288
|
fn: (p, s, n) => regexFindAll(p, s, n),
|
|
@@ -4982,7 +5290,8 @@ function sprigRegex() {
|
|
|
4982
5290
|
"string",
|
|
4983
5291
|
"string",
|
|
4984
5292
|
"int"
|
|
4985
|
-
]
|
|
5293
|
+
],
|
|
5294
|
+
arity: { kind: "exact" }
|
|
4986
5295
|
},
|
|
4987
5296
|
regexReplaceAll: {
|
|
4988
5297
|
fn: (p, s, r) => regexReplaceAll(p, s, r),
|
|
@@ -4990,7 +5299,8 @@ function sprigRegex() {
|
|
|
4990
5299
|
"string",
|
|
4991
5300
|
"string",
|
|
4992
5301
|
"string"
|
|
4993
|
-
]
|
|
5302
|
+
],
|
|
5303
|
+
arity: { kind: "exact" }
|
|
4994
5304
|
},
|
|
4995
5305
|
regexReplaceAllLiteral: {
|
|
4996
5306
|
fn: (p, s, r) => regexReplaceAllLiteral(p, s, r),
|
|
@@ -4998,7 +5308,8 @@ function sprigRegex() {
|
|
|
4998
5308
|
"string",
|
|
4999
5309
|
"string",
|
|
5000
5310
|
"string"
|
|
5001
|
-
]
|
|
5311
|
+
],
|
|
5312
|
+
arity: { kind: "exact" }
|
|
5002
5313
|
},
|
|
5003
5314
|
regexSplit: {
|
|
5004
5315
|
fn: (p, s, n) => regexSplit(p, s, n),
|
|
@@ -5006,7 +5317,8 @@ function sprigRegex() {
|
|
|
5006
5317
|
"string",
|
|
5007
5318
|
"string",
|
|
5008
5319
|
"int"
|
|
5009
|
-
]
|
|
5320
|
+
],
|
|
5321
|
+
arity: { kind: "exact" }
|
|
5010
5322
|
}
|
|
5011
5323
|
};
|
|
5012
5324
|
}
|
|
@@ -5194,11 +5506,13 @@ function sprigSemver() {
|
|
|
5194
5506
|
return {
|
|
5195
5507
|
semver: {
|
|
5196
5508
|
fn: (s) => semver(s),
|
|
5197
|
-
argTypes: ["string"]
|
|
5509
|
+
argTypes: ["string"],
|
|
5510
|
+
arity: { kind: "exact" }
|
|
5198
5511
|
},
|
|
5199
5512
|
semverCompare: {
|
|
5200
5513
|
fn: (constraint, version) => semverCompare(constraint, version),
|
|
5201
5514
|
argTypes: ["string", "string"],
|
|
5515
|
+
arity: { kind: "exact" },
|
|
5202
5516
|
returnType: "bool"
|
|
5203
5517
|
}
|
|
5204
5518
|
};
|
|
@@ -5210,11 +5524,15 @@ function sprigSemver() {
|
|
|
5210
5524
|
* with `...` when truncation occurs. Width must be at least 4 to fit
|
|
5211
5525
|
* the ellipsis; smaller widths return `s` unchanged (Go sprig
|
|
5212
5526
|
* behavior).
|
|
5527
|
+
*
|
|
5528
|
+
* `width` counts code points, so the cut never splits an astral
|
|
5529
|
+
* character — see `runes.js` for why that differs from Go's bytes.
|
|
5213
5530
|
*/
|
|
5214
5531
|
function abbrev(width, s) {
|
|
5215
|
-
|
|
5532
|
+
const cps = runes(s);
|
|
5533
|
+
if (cps.length <= width) return s;
|
|
5216
5534
|
if (width < 4) return s;
|
|
5217
|
-
return `${
|
|
5535
|
+
return `${cps.slice(0, width - 3).join("")}...`;
|
|
5218
5536
|
}
|
|
5219
5537
|
//#endregion
|
|
5220
5538
|
//#region src/sprig/strings/abbrevboth.ts
|
|
@@ -5223,11 +5541,15 @@ function abbrev(width, s) {
|
|
|
5223
5541
|
* around the visible window. Mirrors Go sprig's abbrevboth semantics:
|
|
5224
5542
|
* left/right specify offsets (0-indexed); the result has `...` around
|
|
5225
5543
|
* a slice taken between them.
|
|
5544
|
+
*
|
|
5545
|
+
* Offsets count code points, so the window never splits an astral
|
|
5546
|
+
* character — see `runes.js` for why that differs from Go's bytes.
|
|
5226
5547
|
*/
|
|
5227
5548
|
function abbrevboth(left, right, s) {
|
|
5228
|
-
|
|
5229
|
-
if (
|
|
5230
|
-
|
|
5549
|
+
const cps = runes(s);
|
|
5550
|
+
if (right < 7 || cps.length < right) return s;
|
|
5551
|
+
if (left < 0 || left > cps.length - right + 1) return s;
|
|
5552
|
+
return `...${cps.slice(left, left + right - 6).join("")}...`;
|
|
5231
5553
|
}
|
|
5232
5554
|
//#endregion
|
|
5233
5555
|
//#region src/sprig/strings/caseUtils.ts
|
|
@@ -5243,14 +5565,13 @@ function abbrevboth(left, right, s) {
|
|
|
5243
5565
|
*
|
|
5244
5566
|
* ## Port notes
|
|
5245
5567
|
*
|
|
5246
|
-
* Go iterates UTF-8 bytes via `utf8.DecodeRuneInString`.
|
|
5247
|
-
*
|
|
5248
|
-
*
|
|
5249
|
-
*
|
|
5250
|
-
*
|
|
5251
|
-
*
|
|
5252
|
-
*
|
|
5253
|
-
* actually exercise.
|
|
5568
|
+
* Go iterates UTF-8 bytes via `utf8.DecodeRuneInString`. The `runes`
|
|
5569
|
+
* seam yields code points the same way Go yields runes, so the
|
|
5570
|
+
* rune-level logic carries over. We intentionally do NOT attempt to
|
|
5571
|
+
* mirror xstrings' `isAlphabet` CJK-exclusion table — for ASCII/Latin
|
|
5572
|
+
* templates, which are what real users feed sprig, the simpler
|
|
5573
|
+
* `isLetter` test matches Go's output. The fixture suite pins the
|
|
5574
|
+
* cases consumers actually exercise.
|
|
5254
5575
|
*
|
|
5255
5576
|
* `unicode.ToTitle` from Go has no JS equivalent for ASCII letters
|
|
5256
5577
|
* (Title and Upper coincide for code points without a separate Title
|
|
@@ -5420,7 +5741,7 @@ function pushLowered(buf, word, connector) {
|
|
|
5420
5741
|
*/
|
|
5421
5742
|
function camelCaseToLowerCase(s, connector) {
|
|
5422
5743
|
if (s.length === 0) return "";
|
|
5423
|
-
const cps =
|
|
5744
|
+
const cps = runes(s);
|
|
5424
5745
|
const buf = [];
|
|
5425
5746
|
let { word, next: i } = nextWord(cps, 0);
|
|
5426
5747
|
while (i < cps.length) {
|
|
@@ -5474,7 +5795,7 @@ function camelCaseToLowerCase(s, connector) {
|
|
|
5474
5795
|
*/
|
|
5475
5796
|
function camelCase(s) {
|
|
5476
5797
|
if (s.length === 0) return "";
|
|
5477
|
-
const cps =
|
|
5798
|
+
const cps = runes(s);
|
|
5478
5799
|
const buf = [];
|
|
5479
5800
|
let i = 0;
|
|
5480
5801
|
let r0 = "";
|
|
@@ -5663,9 +5984,16 @@ function repeat(n, s) {
|
|
|
5663
5984
|
}
|
|
5664
5985
|
//#endregion
|
|
5665
5986
|
//#region src/sprig/strings/replace.ts
|
|
5666
|
-
/**
|
|
5987
|
+
/**
|
|
5988
|
+
* Replaces ALL occurrences of `old` with `nw` in `s` (Go's strings.Replace n=-1).
|
|
5989
|
+
*
|
|
5990
|
+
* An empty `old` splits between runes rather than UTF-16 units, so the
|
|
5991
|
+
* replacement is never inserted inside an astral character. Where Go
|
|
5992
|
+
* additionally inserts `nw` at both ends (`-a-b-c-` to this port's
|
|
5993
|
+
* `a-b-c`) it still differs — a separate, non-Unicode divergence.
|
|
5994
|
+
*/
|
|
5667
5995
|
function replace(old, nw, s) {
|
|
5668
|
-
return
|
|
5996
|
+
return goSplit(old, s).join(nw);
|
|
5669
5997
|
}
|
|
5670
5998
|
//#endregion
|
|
5671
5999
|
//#region src/sprig/strings/snakecase.ts
|
|
@@ -5687,7 +6015,7 @@ function snakecase(s) {
|
|
|
5687
6015
|
* split "/" "a/b/c" → { _0: "a", _1: "b", _2: "c" }
|
|
5688
6016
|
*/
|
|
5689
6017
|
function split(sep, s) {
|
|
5690
|
-
const parts =
|
|
6018
|
+
const parts = goSplit(sep, s);
|
|
5691
6019
|
const out = {};
|
|
5692
6020
|
for (let i = 0; i < parts.length; i++) out[`_${i}`] = parts[i];
|
|
5693
6021
|
return out;
|
|
@@ -5695,7 +6023,7 @@ function split(sep, s) {
|
|
|
5695
6023
|
//#endregion
|
|
5696
6024
|
//#region src/sprig/strings/splitList.ts
|
|
5697
6025
|
function splitList(sep, s) {
|
|
5698
|
-
return
|
|
6026
|
+
return goSplit(sep, s);
|
|
5699
6027
|
}
|
|
5700
6028
|
//#endregion
|
|
5701
6029
|
//#region src/sprig/strings/splitn.ts
|
|
@@ -5726,7 +6054,7 @@ function splitn(sep, n, s) {
|
|
|
5726
6054
|
}
|
|
5727
6055
|
function goSplitN(s, sep, n) {
|
|
5728
6056
|
if (n === 0) return [];
|
|
5729
|
-
const all = sep
|
|
6057
|
+
const all = goSplit(sep, s);
|
|
5730
6058
|
if (n < 0 || all.length <= n) return all;
|
|
5731
6059
|
const head = all.slice(0, n - 1);
|
|
5732
6060
|
const tail = all.slice(n - 1).join(sep);
|
|
@@ -5743,13 +6071,17 @@ function squote(...args) {
|
|
|
5743
6071
|
/**
|
|
5744
6072
|
* `substr i j s` — substring [i, j) with out-of-range clamping.
|
|
5745
6073
|
* Matches Go sprig's behavior of clamping rather than throwing:
|
|
5746
|
-
* negative `end` (and any `end
|
|
5747
|
-
* `start` clamps to `[0, end]`.
|
|
6074
|
+
* negative `end` (and any `end` past the last char) clamps to the
|
|
6075
|
+
* string's length; `start` clamps to `[0, end]`.
|
|
6076
|
+
*
|
|
6077
|
+
* Offsets count code points, so a window never splits an astral
|
|
6078
|
+
* character — see `runes.js` for why that differs from Go's bytes.
|
|
5748
6079
|
*/
|
|
5749
6080
|
function substr(start, end, s) {
|
|
5750
|
-
const
|
|
6081
|
+
const cps = runes(s);
|
|
6082
|
+
const j = end < 0 || end > cps.length ? cps.length : end;
|
|
5751
6083
|
const i = Math.min(Math.max(0, start), j);
|
|
5752
|
-
return
|
|
6084
|
+
return cps.slice(i, j).join("");
|
|
5753
6085
|
}
|
|
5754
6086
|
//#endregion
|
|
5755
6087
|
//#region src/sprig/strings/swapcase.ts
|
|
@@ -5792,15 +6124,23 @@ function trim(s) {
|
|
|
5792
6124
|
}
|
|
5793
6125
|
//#endregion
|
|
5794
6126
|
//#region src/sprig/strings/trimAll.ts
|
|
5795
|
-
/**
|
|
6127
|
+
/**
|
|
6128
|
+
* `trimAll cutset s` — strip leading + trailing chars in `cutset`.
|
|
6129
|
+
*
|
|
6130
|
+
* Both sides are compared as code points, matching Go's `strings.Trim`,
|
|
6131
|
+
* which decodes the cutset as runes. Scanning `s` by UTF-16 unit
|
|
6132
|
+
* compared half an astral character against whole ones, so an astral
|
|
6133
|
+
* cutset char never matched and the string came back untrimmed.
|
|
6134
|
+
*/
|
|
5796
6135
|
function trimAll(cutset, s) {
|
|
5797
6136
|
if (cutset.length === 0) return s;
|
|
5798
|
-
const set = new Set(
|
|
6137
|
+
const set = new Set(runes(cutset));
|
|
6138
|
+
const cps = runes(s);
|
|
5799
6139
|
let start = 0;
|
|
5800
|
-
while (start <
|
|
5801
|
-
let end =
|
|
5802
|
-
while (end > start && set.has(
|
|
5803
|
-
return
|
|
6140
|
+
while (start < cps.length && set.has(cps[start])) start += 1;
|
|
6141
|
+
let end = cps.length;
|
|
6142
|
+
while (end > start && set.has(cps[end - 1])) end -= 1;
|
|
6143
|
+
return cps.slice(start, end).join("");
|
|
5804
6144
|
}
|
|
5805
6145
|
//#endregion
|
|
5806
6146
|
//#region src/sprig/strings/trimPrefix.ts
|
|
@@ -5817,13 +6157,17 @@ function trimSuffix(suffix, s) {
|
|
|
5817
6157
|
/**
|
|
5818
6158
|
* `trunc n s` — first `n` chars when n>=0; last |n| chars when n<0.
|
|
5819
6159
|
* Strings shorter than |n| are returned unchanged. Matches Go sprig.
|
|
6160
|
+
*
|
|
6161
|
+
* `n` counts code points, so truncating never splits an astral
|
|
6162
|
+
* character — see `runes.js` for why that differs from Go's bytes.
|
|
5820
6163
|
*/
|
|
5821
6164
|
function trunc(n, s) {
|
|
6165
|
+
const cps = runes(s);
|
|
5822
6166
|
if (n < 0) {
|
|
5823
6167
|
const k = -n;
|
|
5824
|
-
return k >=
|
|
6168
|
+
return k >= cps.length ? s : cps.slice(cps.length - k).join("");
|
|
5825
6169
|
}
|
|
5826
|
-
return n >=
|
|
6170
|
+
return n >= cps.length ? s : cps.slice(0, n).join("");
|
|
5827
6171
|
}
|
|
5828
6172
|
//#endregion
|
|
5829
6173
|
//#region src/sprig/strings/untitle.ts
|
|
@@ -5875,7 +6219,8 @@ function sprigStrings() {
|
|
|
5875
6219
|
return {
|
|
5876
6220
|
abbrev: {
|
|
5877
6221
|
fn: (w, s) => abbrev(w, s),
|
|
5878
|
-
argTypes: ["int", "string"]
|
|
6222
|
+
argTypes: ["int", "string"],
|
|
6223
|
+
arity: { kind: "exact" }
|
|
5879
6224
|
},
|
|
5880
6225
|
abbrevboth: {
|
|
5881
6226
|
fn: (l, r, s) => abbrevboth(l, r, s),
|
|
@@ -5883,57 +6228,70 @@ function sprigStrings() {
|
|
|
5883
6228
|
"int",
|
|
5884
6229
|
"int",
|
|
5885
6230
|
"string"
|
|
5886
|
-
]
|
|
6231
|
+
],
|
|
6232
|
+
arity: { kind: "exact" }
|
|
5887
6233
|
},
|
|
5888
6234
|
camelcase: {
|
|
5889
6235
|
fn: (s) => camelcase(s),
|
|
5890
6236
|
argTypes: ["string"],
|
|
6237
|
+
arity: { kind: "exact" },
|
|
5891
6238
|
returnType: "string"
|
|
5892
6239
|
},
|
|
5893
6240
|
cat: {
|
|
5894
6241
|
fn: (...a) => cat(...a),
|
|
5895
|
-
argTypes: ["string"]
|
|
6242
|
+
argTypes: ["string"],
|
|
6243
|
+
arity: { kind: "variadic" }
|
|
5896
6244
|
},
|
|
5897
6245
|
contains: {
|
|
5898
6246
|
fn: (sub, s) => contains(sub, s),
|
|
5899
|
-
argTypes: ["string", "string"]
|
|
6247
|
+
argTypes: ["string", "string"],
|
|
6248
|
+
arity: { kind: "exact" }
|
|
5900
6249
|
},
|
|
5901
6250
|
hasPrefix: {
|
|
5902
6251
|
fn: (p, s) => hasPrefix(p, s),
|
|
5903
|
-
argTypes: ["string", "string"]
|
|
6252
|
+
argTypes: ["string", "string"],
|
|
6253
|
+
arity: { kind: "exact" }
|
|
5904
6254
|
},
|
|
5905
6255
|
hasSuffix: {
|
|
5906
6256
|
fn: (sf, s) => hasSuffix(sf, s),
|
|
5907
|
-
argTypes: ["string", "string"]
|
|
6257
|
+
argTypes: ["string", "string"],
|
|
6258
|
+
arity: { kind: "exact" }
|
|
5908
6259
|
},
|
|
5909
6260
|
indent: {
|
|
5910
6261
|
fn: (n, s) => indent(n, s),
|
|
5911
|
-
argTypes: ["int", "string"]
|
|
6262
|
+
argTypes: ["int", "string"],
|
|
6263
|
+
arity: { kind: "exact" }
|
|
5912
6264
|
},
|
|
5913
6265
|
initials: {
|
|
5914
6266
|
fn: (s) => initials(s),
|
|
5915
|
-
argTypes: ["string"]
|
|
6267
|
+
argTypes: ["string"],
|
|
6268
|
+
arity: { kind: "exact" }
|
|
5916
6269
|
},
|
|
5917
6270
|
join: {
|
|
5918
6271
|
fn: (sep, list) => join(sep, list),
|
|
5919
|
-
argTypes: ["string", "list"]
|
|
6272
|
+
argTypes: ["string", "list"],
|
|
6273
|
+
arity: { kind: "exact" }
|
|
5920
6274
|
},
|
|
5921
6275
|
kebabcase: {
|
|
5922
6276
|
fn: (s) => kebabcase(s),
|
|
5923
6277
|
argTypes: ["string"],
|
|
6278
|
+
arity: { kind: "exact" },
|
|
5924
6279
|
returnType: "string"
|
|
5925
6280
|
},
|
|
5926
6281
|
lower: {
|
|
5927
6282
|
fn: (s) => lower(s),
|
|
5928
|
-
argTypes: ["string"]
|
|
6283
|
+
argTypes: ["string"],
|
|
6284
|
+
arity: { kind: "exact" }
|
|
5929
6285
|
},
|
|
5930
6286
|
nindent: {
|
|
5931
6287
|
fn: (n, s) => nindent(n, s),
|
|
5932
|
-
argTypes: ["int", "string"]
|
|
6288
|
+
argTypes: ["int", "string"],
|
|
6289
|
+
arity: { kind: "exact" }
|
|
5933
6290
|
},
|
|
5934
6291
|
nospace: {
|
|
5935
6292
|
fn: (s) => nospace(s),
|
|
5936
6293
|
argTypes: ["string"],
|
|
6294
|
+
arity: { kind: "exact" },
|
|
5937
6295
|
returnType: "string"
|
|
5938
6296
|
},
|
|
5939
6297
|
plural: {
|
|
@@ -5943,20 +6301,24 @@ function sprigStrings() {
|
|
|
5943
6301
|
"string",
|
|
5944
6302
|
"int"
|
|
5945
6303
|
],
|
|
6304
|
+
arity: { kind: "exact" },
|
|
5946
6305
|
returnType: "string"
|
|
5947
6306
|
},
|
|
5948
6307
|
quote: {
|
|
5949
6308
|
fn: (...a) => quote(...a),
|
|
5950
|
-
argTypes: ["string"]
|
|
6309
|
+
argTypes: ["string"],
|
|
6310
|
+
arity: { kind: "variadic" }
|
|
5951
6311
|
},
|
|
5952
6312
|
regexQuoteMeta: {
|
|
5953
6313
|
fn: (s) => regexQuoteMeta(s),
|
|
5954
6314
|
argTypes: ["string"],
|
|
6315
|
+
arity: { kind: "exact" },
|
|
5955
6316
|
returnType: "string"
|
|
5956
6317
|
},
|
|
5957
6318
|
repeat: {
|
|
5958
6319
|
fn: (n, s) => repeat(n, s),
|
|
5959
|
-
argTypes: ["int", "string"]
|
|
6320
|
+
argTypes: ["int", "string"],
|
|
6321
|
+
arity: { kind: "exact" }
|
|
5960
6322
|
},
|
|
5961
6323
|
replace: {
|
|
5962
6324
|
fn: (o, n, s) => replace(o, n, s),
|
|
@@ -5964,20 +6326,24 @@ function sprigStrings() {
|
|
|
5964
6326
|
"string",
|
|
5965
6327
|
"string",
|
|
5966
6328
|
"string"
|
|
5967
|
-
]
|
|
6329
|
+
],
|
|
6330
|
+
arity: { kind: "exact" }
|
|
5968
6331
|
},
|
|
5969
6332
|
snakecase: {
|
|
5970
6333
|
fn: (s) => snakecase(s),
|
|
5971
6334
|
argTypes: ["string"],
|
|
6335
|
+
arity: { kind: "exact" },
|
|
5972
6336
|
returnType: "string"
|
|
5973
6337
|
},
|
|
5974
6338
|
split: {
|
|
5975
6339
|
fn: (sep, s) => split(sep, s),
|
|
5976
|
-
argTypes: ["string", "string"]
|
|
6340
|
+
argTypes: ["string", "string"],
|
|
6341
|
+
arity: { kind: "exact" }
|
|
5977
6342
|
},
|
|
5978
6343
|
splitList: {
|
|
5979
6344
|
fn: (sep, s) => splitList(sep, s),
|
|
5980
|
-
argTypes: ["string", "string"]
|
|
6345
|
+
argTypes: ["string", "string"],
|
|
6346
|
+
arity: { kind: "exact" }
|
|
5981
6347
|
},
|
|
5982
6348
|
splitn: {
|
|
5983
6349
|
fn: (sep, n, s) => splitn(sep, n, s),
|
|
@@ -5986,11 +6352,13 @@ function sprigStrings() {
|
|
|
5986
6352
|
"int",
|
|
5987
6353
|
"string"
|
|
5988
6354
|
],
|
|
6355
|
+
arity: { kind: "exact" },
|
|
5989
6356
|
returnType: "dict"
|
|
5990
6357
|
},
|
|
5991
6358
|
squote: {
|
|
5992
6359
|
fn: (...a) => squote(...a),
|
|
5993
|
-
argTypes: ["string"]
|
|
6360
|
+
argTypes: ["string"],
|
|
6361
|
+
arity: { kind: "variadic" }
|
|
5994
6362
|
},
|
|
5995
6363
|
substr: {
|
|
5996
6364
|
fn: (i, j, s) => substr(i, j, s),
|
|
@@ -5998,48 +6366,59 @@ function sprigStrings() {
|
|
|
5998
6366
|
"int",
|
|
5999
6367
|
"int",
|
|
6000
6368
|
"string"
|
|
6001
|
-
]
|
|
6369
|
+
],
|
|
6370
|
+
arity: { kind: "exact" }
|
|
6002
6371
|
},
|
|
6003
6372
|
swapcase: {
|
|
6004
6373
|
fn: (s) => swapcase(s),
|
|
6005
6374
|
argTypes: ["string"],
|
|
6375
|
+
arity: { kind: "exact" },
|
|
6006
6376
|
returnType: "string"
|
|
6007
6377
|
},
|
|
6008
6378
|
title: {
|
|
6009
6379
|
fn: (s) => title(s),
|
|
6010
|
-
argTypes: ["string"]
|
|
6380
|
+
argTypes: ["string"],
|
|
6381
|
+
arity: { kind: "exact" }
|
|
6011
6382
|
},
|
|
6012
6383
|
trim: {
|
|
6013
6384
|
fn: (s) => trim(s),
|
|
6014
|
-
argTypes: ["string"]
|
|
6385
|
+
argTypes: ["string"],
|
|
6386
|
+
arity: { kind: "exact" }
|
|
6015
6387
|
},
|
|
6016
6388
|
trimAll: {
|
|
6017
6389
|
fn: (cs, s) => trimAll(cs, s),
|
|
6018
|
-
argTypes: ["string", "string"]
|
|
6390
|
+
argTypes: ["string", "string"],
|
|
6391
|
+
arity: { kind: "exact" }
|
|
6019
6392
|
},
|
|
6020
6393
|
trimPrefix: {
|
|
6021
6394
|
fn: (p, s) => trimPrefix(p, s),
|
|
6022
|
-
argTypes: ["string", "string"]
|
|
6395
|
+
argTypes: ["string", "string"],
|
|
6396
|
+
arity: { kind: "exact" }
|
|
6023
6397
|
},
|
|
6024
6398
|
trimSuffix: {
|
|
6025
6399
|
fn: (sf, s) => trimSuffix(sf, s),
|
|
6026
|
-
argTypes: ["string", "string"]
|
|
6400
|
+
argTypes: ["string", "string"],
|
|
6401
|
+
arity: { kind: "exact" }
|
|
6027
6402
|
},
|
|
6028
6403
|
trunc: {
|
|
6029
6404
|
fn: (n, s) => trunc(n, s),
|
|
6030
|
-
argTypes: ["int", "string"]
|
|
6405
|
+
argTypes: ["int", "string"],
|
|
6406
|
+
arity: { kind: "exact" }
|
|
6031
6407
|
},
|
|
6032
6408
|
untitle: {
|
|
6033
6409
|
fn: (s) => untitle(s),
|
|
6034
|
-
argTypes: ["string"]
|
|
6410
|
+
argTypes: ["string"],
|
|
6411
|
+
arity: { kind: "exact" }
|
|
6035
6412
|
},
|
|
6036
6413
|
upper: {
|
|
6037
6414
|
fn: (s) => upper(s),
|
|
6038
|
-
argTypes: ["string"]
|
|
6415
|
+
argTypes: ["string"],
|
|
6416
|
+
arity: { kind: "exact" }
|
|
6039
6417
|
},
|
|
6040
6418
|
wrap: {
|
|
6041
6419
|
fn: (w, s) => wrap(w, s),
|
|
6042
|
-
argTypes: ["int", "string"]
|
|
6420
|
+
argTypes: ["int", "string"],
|
|
6421
|
+
arity: { kind: "exact" }
|
|
6043
6422
|
},
|
|
6044
6423
|
wrapWith: {
|
|
6045
6424
|
fn: (w, sep, s) => wrapWith(w, sep, s),
|
|
@@ -6047,7 +6426,8 @@ function sprigStrings() {
|
|
|
6047
6426
|
"int",
|
|
6048
6427
|
"string",
|
|
6049
6428
|
"string"
|
|
6050
|
-
]
|
|
6429
|
+
],
|
|
6430
|
+
arity: { kind: "exact" }
|
|
6051
6431
|
}
|
|
6052
6432
|
};
|
|
6053
6433
|
}
|
|
@@ -6119,35 +6499,42 @@ function sprigTypes() {
|
|
|
6119
6499
|
return {
|
|
6120
6500
|
kindOf: {
|
|
6121
6501
|
fn: (v) => kindOf(v),
|
|
6122
|
-
argTypes: ["reflective"]
|
|
6502
|
+
argTypes: ["reflective"],
|
|
6503
|
+
arity: { kind: "exact" }
|
|
6123
6504
|
},
|
|
6124
6505
|
kindIs: {
|
|
6125
6506
|
fn: (k, v) => kindIs(k, v),
|
|
6126
|
-
argTypes: ["string", "reflective"]
|
|
6507
|
+
argTypes: ["string", "reflective"],
|
|
6508
|
+
arity: { kind: "exact" }
|
|
6127
6509
|
},
|
|
6128
6510
|
typeOf: {
|
|
6129
6511
|
fn: (v) => typeOf(v),
|
|
6130
|
-
argTypes: ["reflective"]
|
|
6512
|
+
argTypes: ["reflective"],
|
|
6513
|
+
arity: { kind: "exact" }
|
|
6131
6514
|
},
|
|
6132
6515
|
typeIs: {
|
|
6133
6516
|
fn: (t, v) => typeIs(t, v),
|
|
6134
|
-
argTypes: ["string", "reflective"]
|
|
6517
|
+
argTypes: ["string", "reflective"],
|
|
6518
|
+
arity: { kind: "exact" }
|
|
6135
6519
|
},
|
|
6136
6520
|
typeIsLike: {
|
|
6137
6521
|
fn: (t, v) => typeIsLike(t, v),
|
|
6138
|
-
argTypes: ["string", "reflective"]
|
|
6522
|
+
argTypes: ["string", "reflective"],
|
|
6523
|
+
arity: { kind: "exact" }
|
|
6139
6524
|
},
|
|
6140
6525
|
deepEqual: {
|
|
6141
6526
|
fn: (a, b) => deepEqual(a, b),
|
|
6142
|
-
argTypes: ["value", "value"]
|
|
6527
|
+
argTypes: ["value", "value"],
|
|
6528
|
+
arity: { kind: "exact" }
|
|
6143
6529
|
},
|
|
6144
6530
|
deepCopy: {
|
|
6145
6531
|
fn: (v) => deepCopy(v),
|
|
6146
|
-
argTypes: ["value"]
|
|
6532
|
+
argTypes: ["value"],
|
|
6533
|
+
arity: { kind: "exact" }
|
|
6147
6534
|
}
|
|
6148
6535
|
};
|
|
6149
6536
|
}
|
|
6150
6537
|
//#endregion
|
|
6151
|
-
export { Defines, Engine, EvalError, FailError, FuncNotFoundError, MissingFieldError, ParseError, Template, TemplateError, TypeMismatchError, createEngine, sprigConversions, sprigDatetime, sprigDefaults, sprigDicts, sprigFlow, sprigHash, sprigLists, sprigMath, sprigRandom, sprigRegex, sprigSemver, sprigStrings, sprigTypes, staticDictEntries };
|
|
6538
|
+
export { ArgCountError, Defines, Engine, EvalError, FailError, FuncNotFoundError, MissingFieldError, NotIntegerError, ParseError, Template, TemplateError, TypeMismatchError, createEngine, sprigConversions, sprigDatetime, sprigDefaults, sprigDicts, sprigFlow, sprigHash, sprigLists, sprigMath, sprigRandom, sprigRegex, sprigSemver, sprigStrings, sprigTypes, staticDictEntries };
|
|
6152
6539
|
|
|
6153
6540
|
//# sourceMappingURL=index.js.map
|