trilean 1.7.12 → 1.9.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 +36 -14
- package/dist/builtin-functions.cjs +146 -0
- package/dist/builtin-functions.d.cts +13 -0
- package/dist/builtin-functions.d.ts +13 -0
- package/dist/builtin-functions.js +145 -0
- package/dist/complex-division.cjs +48 -0
- package/dist/complex-division.d.cts +25 -0
- package/dist/complex-division.d.ts +25 -0
- package/dist/complex-division.js +47 -0
- package/dist/complex.cjs +4 -2
- package/dist/complex.d.cts +4 -2
- package/dist/complex.d.ts +4 -2
- package/dist/complex.js +4 -2
- package/dist/duration-order.cjs +84 -0
- package/dist/duration-order.d.cts +22 -0
- package/dist/duration-order.d.ts +22 -0
- package/dist/duration-order.js +82 -0
- package/dist/evaluate-document.cjs +93 -0
- package/dist/evaluate-document.d.cts +44 -0
- package/dist/evaluate-document.d.ts +44 -0
- package/dist/evaluate-document.js +92 -0
- package/dist/evaluator-collection.d.cts +1 -1
- package/dist/evaluator-collection.d.ts +1 -1
- package/dist/evaluator-factory.d.cts +1 -1
- package/dist/evaluator-factory.d.ts +1 -1
- package/dist/evaluator-indeterminacy-helpers.d.cts +1 -1
- package/dist/evaluator-indeterminacy-helpers.d.ts +1 -1
- package/dist/evaluator-operations.cjs +75 -24
- package/dist/evaluator-operations.d.cts +3 -3
- package/dist/evaluator-operations.d.ts +3 -3
- package/dist/evaluator-operations.js +74 -23
- package/dist/evaluator.d.cts +1 -1
- package/dist/evaluator.d.ts +1 -1
- package/dist/functions.d.cts +8 -4
- package/dist/functions.d.ts +8 -4
- package/dist/index.cjs +8 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/input-resolvers.cjs +110 -0
- package/dist/input-resolvers.d.cts +24 -0
- package/dist/input-resolvers.d.ts +24 -0
- package/dist/input-resolvers.js +108 -0
- package/dist/integer-power.cjs +20 -0
- package/dist/integer-power.d.cts +13 -0
- package/dist/integer-power.d.ts +13 -0
- package/dist/integer-power.js +19 -0
- package/dist/plain-record.cjs +8 -0
- package/dist/plain-record.d.cts +4 -0
- package/dist/plain-record.d.ts +4 -0
- package/dist/plain-record.js +7 -0
- package/dist-cli/trilean.mjs +1848 -0
- package/package.json +5 -1
- package/schemas/trilean.schema.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as ComputedValue } from "./computed-value-CbRF0Izc.js";
|
|
2
|
+
import { FunctionRegistry } from "./functions.js";
|
|
2
3
|
import { t as JsonValue } from "./json-value-B1Hjjjri.js";
|
|
3
4
|
import { PredicateNode } from "./tree.js";
|
|
4
5
|
import { Evaluation, IndeterminateReason } from "./evaluation.js";
|
|
5
6
|
import { EvaluationBudget } from "./evaluator-budget.js";
|
|
6
|
-
import { FunctionRegistry } from "./functions.js";
|
|
7
7
|
import { Task } from "./evaluator-effect.js";
|
|
8
8
|
import { EvaluationContext, EvaluatorResolvers } from "./resolvers.js";
|
|
9
9
|
//#region src/evaluator-collection.d.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as ComputedValue } from "./computed-value-CbRF0Izc.cjs";
|
|
2
|
+
import { FunctionRegistry } from "./functions.cjs";
|
|
2
3
|
import { ExpressionNode, PredicateNode } from "./tree.cjs";
|
|
3
4
|
import { Evaluation } from "./evaluation.cjs";
|
|
4
|
-
import { FunctionRegistry } from "./functions.cjs";
|
|
5
5
|
import { EvaluationContext, Resolvers, SyncResolvers } from "./resolvers.cjs";
|
|
6
6
|
//#region src/evaluator-factory.d.ts
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as ComputedValue } from "./computed-value-CbRF0Izc.js";
|
|
2
|
+
import { FunctionRegistry } from "./functions.js";
|
|
2
3
|
import { ExpressionNode, PredicateNode } from "./tree.js";
|
|
3
4
|
import { Evaluation } from "./evaluation.js";
|
|
4
|
-
import { FunctionRegistry } from "./functions.js";
|
|
5
5
|
import { EvaluationContext, Resolvers, SyncResolvers } from "./resolvers.js";
|
|
6
6
|
//#region src/evaluator-factory.d.ts
|
|
7
7
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { FunctionRegistry } from "./functions.cjs";
|
|
1
2
|
import { ExpressionNode, PredicateNode } from "./tree.cjs";
|
|
2
3
|
import { IndeterminateReason } from "./evaluation.cjs";
|
|
3
|
-
import { FunctionRegistry } from "./functions.cjs";
|
|
4
4
|
import { EvaluationContext, Resolvers } from "./resolvers.cjs";
|
|
5
5
|
//#region src/evaluator-indeterminacy-helpers.d.ts
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { FunctionRegistry } from "./functions.js";
|
|
1
2
|
import { ExpressionNode, PredicateNode } from "./tree.js";
|
|
2
3
|
import { IndeterminateReason } from "./evaluation.js";
|
|
3
|
-
import { FunctionRegistry } from "./functions.js";
|
|
4
4
|
import { EvaluationContext, Resolvers } from "./resolvers.js";
|
|
5
5
|
//#region src/evaluator-indeterminacy-helpers.d.ts
|
|
6
6
|
/**
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_computed_value = require("./computed-value.cjs");
|
|
3
|
+
const require_complex_division = require("./complex-division.cjs");
|
|
4
|
+
const require_duration_order = require("./duration-order.cjs");
|
|
3
5
|
const require_evaluation = require("./evaluation.cjs");
|
|
6
|
+
const require_integer_power = require("./integer-power.cjs");
|
|
4
7
|
let trilean_regex = require("trilean-regex");
|
|
5
8
|
//#region src/evaluator-operations.ts
|
|
6
9
|
/** The three-valued AND table: `false` is absorbing regardless of the other operand's indeterminacy; otherwise both-definite folds to a boolean AND; otherwise indeterminate, with the tie-break rule (declared operand order, left before right) applied via `firstIndeterminate`. */
|
|
@@ -36,16 +39,9 @@ function applyComparisonOperator(op, left, right) {
|
|
|
36
39
|
default: throw new Error("unreachable comparison operator");
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
ms: 1,
|
|
41
|
-
s: 1e3,
|
|
42
|
-
min: 6e4,
|
|
43
|
-
h: 36e5,
|
|
44
|
-
d: 864e5
|
|
45
|
-
};
|
|
46
|
-
/** Normalises a `duration`'s magnitude to milliseconds, the common base unit for combining or comparing two `duration`s (or an `instant` and a `duration`) of potentially different `DurationUnit`s -- shared by `compareValues`'s own `duration` branch below and by the temporal arithmetic further down. */
|
|
42
|
+
/** Converts a `duration`'s magnitude to milliseconds by multiplying, the base unit the temporal arithmetic below combines durations of different `DurationUnit`s in and shifts an `instant` by. Comparing two durations does not use it: `compareDurations` does that without converting, because this multiplication overflows for very large spans. */
|
|
47
43
|
function toMilliseconds(value, unit) {
|
|
48
|
-
return value * millisecondsPerDurationUnit[unit];
|
|
44
|
+
return value * require_duration_order.millisecondsPerDurationUnit[unit];
|
|
49
45
|
}
|
|
50
46
|
/** `Date.parse` reports an unparseable timestamp as `NaN`, and every downstream use of that `NaN` then fails silently rather than loudly: every comparison against it is `false` (so `neq` between two unparseable instants would come back definitely `true`), a subtraction yields a `NaN`-magnitude duration, and `new Date(NaN).toISOString()` throws a `RangeError` outright -- a thrown exception for a data-quality problem, which this design never does (see `Evaluation<T>`'s own doc comment in evaluation.ts). An `instant` whose string will not parse is a value the operation cannot use, so every caller below reports it as `wrong-type`, exactly like any other unusable operand. */
|
|
51
47
|
function toEpochMilliseconds(value) {
|
|
@@ -64,7 +60,7 @@ function instantFromEpochMilliseconds(epochMilliseconds) {
|
|
|
64
60
|
value: shifted.toISOString()
|
|
65
61
|
});
|
|
66
62
|
}
|
|
67
|
-
/** `compare`'s two operands: valid kinds are `number` (matching units required), `instant` (ordered by parsed epoch millisecond), or `duration` (ordered by
|
|
63
|
+
/** `compare`'s two operands: valid kinds are `number` (matching units required), `instant` (ordered by parsed epoch millisecond), or `duration` (ordered by `compareDurations`, in whatever unit each carries, with a NaN unordered) -- `text` is never valid here (see `textCompare`), and a kind mismatch between the two operands is `wrong-type`. Narrowing `right` against a literal `left.kind` case (rather than asserting it) is what lets both sides stay properly typed with no `as`. */
|
|
68
64
|
function compareValues(op, left, right) {
|
|
69
65
|
switch (left.kind) {
|
|
70
66
|
case "number":
|
|
@@ -84,9 +80,11 @@ function compareValues(op, left, right) {
|
|
|
84
80
|
if (rightEpoch === void 0) return unparseableInstant(right.value);
|
|
85
81
|
return require_evaluation.definite(applyComparisonOperator(op, leftEpoch, rightEpoch));
|
|
86
82
|
}
|
|
87
|
-
case "duration":
|
|
83
|
+
case "duration": {
|
|
88
84
|
if (right.kind !== "duration") return require_evaluation.indeterminate("wrong-type", `cannot compare a 'duration' value with a '${right.kind}' value`);
|
|
89
|
-
|
|
85
|
+
const order = require_duration_order.compareDurations(left, right);
|
|
86
|
+
return require_evaluation.definite(applyComparisonOperator(op, order ?? NaN, 0));
|
|
87
|
+
}
|
|
90
88
|
case "complex":
|
|
91
89
|
if (op !== "eq" && op !== "neq") return require_evaluation.indeterminate("wrong-type", `ordering operator '${op}' is not defined for complex values; the complex plane has no total order`);
|
|
92
90
|
if (right.kind !== "complex") return require_evaluation.indeterminate("wrong-type", `cannot compare a 'complex' value with a '${right.kind}' value`);
|
|
@@ -151,7 +149,7 @@ function computeMembershipMatch(operand, candidate) {
|
|
|
151
149
|
}
|
|
152
150
|
case "duration":
|
|
153
151
|
if (candidate.kind !== "duration") return require_evaluation.indeterminate("wrong-type", `cannot compare a 'duration' value with a '${candidate.kind}' value for membership`);
|
|
154
|
-
return require_evaluation.definite(
|
|
152
|
+
return require_evaluation.definite(require_duration_order.compareDurations(operand, candidate) === 0);
|
|
155
153
|
case "complex":
|
|
156
154
|
if (candidate.kind !== "complex") return require_evaluation.indeterminate("wrong-type", `cannot compare a 'complex' value with a '${candidate.kind}' value for membership`);
|
|
157
155
|
if (!require_computed_value.unitsEqual(operand.unit, candidate.unit)) return require_evaluation.indeterminate("wrong-type", "cannot compare complex values with incompatible units for membership");
|
|
@@ -264,7 +262,7 @@ function toComplexValue(value) {
|
|
|
264
262
|
unit: value.unit
|
|
265
263
|
};
|
|
266
264
|
}
|
|
267
|
-
/** The complex product, as its own component-level helper rather than only a branch of the operator switch below, because `power`'s
|
|
265
|
+
/** The complex product, as its own component-level helper rather than only a branch of the operator switch below, because `power`'s exponentiation by squaring needs exactly this and must not re-derive it. */
|
|
268
266
|
function multiplyComplexValues(left, right) {
|
|
269
267
|
return {
|
|
270
268
|
kind: "complex",
|
|
@@ -294,12 +292,12 @@ function applyArithmeticOnComplex(op, left, right) {
|
|
|
294
292
|
});
|
|
295
293
|
case "multiply": return require_evaluation.definite(multiplyComplexValues(left, right));
|
|
296
294
|
case "divide": {
|
|
297
|
-
|
|
298
|
-
|
|
295
|
+
if (right.re === 0 && right.im === 0) return require_evaluation.indeterminate("domain-error", "division by zero");
|
|
296
|
+
const quotient = require_complex_division.divideComplexComponents(left, right);
|
|
299
297
|
return require_evaluation.definite({
|
|
300
298
|
kind: "complex",
|
|
301
|
-
re:
|
|
302
|
-
im:
|
|
299
|
+
re: quotient.re,
|
|
300
|
+
im: quotient.im,
|
|
303
301
|
unit: require_computed_value.combineUnitsForDivide(left.unit, right.unit)
|
|
304
302
|
});
|
|
305
303
|
}
|
|
@@ -307,7 +305,23 @@ function applyArithmeticOnComplex(op, left, right) {
|
|
|
307
305
|
default: throw new Error("unreachable arithmetic operator");
|
|
308
306
|
}
|
|
309
307
|
}
|
|
310
|
-
/** `
|
|
308
|
+
/** `1 / value` for a non-zero complex value, carrying the inverse unit. */
|
|
309
|
+
function reciprocalOf(value) {
|
|
310
|
+
return {
|
|
311
|
+
kind: "complex",
|
|
312
|
+
...require_complex_division.divideComplexComponents({
|
|
313
|
+
re: 1,
|
|
314
|
+
im: 0
|
|
315
|
+
}, value),
|
|
316
|
+
unit: require_computed_value.combineUnitsForDivide({}, value.unit)
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
/** Whether a complex value is finite and not zero, which is what dividing by it needs. A positive power that has overflowed or underflowed to zero is neither, and cannot be inverted. */
|
|
320
|
+
function isFiniteAndNonZero(value) {
|
|
321
|
+
const larger = Math.max(Math.abs(value.re), Math.abs(value.im));
|
|
322
|
+
return Number.isFinite(larger) && larger > 0;
|
|
323
|
+
}
|
|
324
|
+
/** `power` with a complex operand on either side, defined for exactly one case: a real integer exponent, evaluated as the repeated multiplication that integer exponentiation *is*, grouped by squaring so the work grows with the logarithm of the exponent rather than the exponent itself. The price is accuracy: the error of squaring grows in proportion to the exponent, so for large exponents the result is many times less accurate than a plain multiplication loop's (the "Complex values" section of README.md has the measurement, and explains why an arbitrary complex exponent stays out of scope). */
|
|
311
325
|
function applyComplexPower(base, exponent) {
|
|
312
326
|
if (exponent.kind !== "number" || !Number.isInteger(exponent.value)) return require_evaluation.indeterminate("wrong-type", "'power' with a complex operand requires a real integer exponent");
|
|
313
327
|
if (!isDimensionless(base.unit) || !isDimensionless(exponent.unit)) return require_evaluation.indeterminate("wrong-type", "'power' requires dimensionless operands");
|
|
@@ -318,15 +332,31 @@ function applyComplexPower(base, exponent) {
|
|
|
318
332
|
unit: {}
|
|
319
333
|
};
|
|
320
334
|
const complexBase = toComplexValue(base);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
335
|
+
if (exponent.value >= 0) return require_evaluation.definite(require_integer_power.powerByRepeatedSquaring({
|
|
336
|
+
base: complexBase,
|
|
337
|
+
exponent: exponent.value,
|
|
338
|
+
identity: complexUnit,
|
|
339
|
+
multiply: multiplyComplexValues
|
|
340
|
+
}));
|
|
341
|
+
if (complexBase.re === 0 && complexBase.im === 0) return require_evaluation.indeterminate("domain-error", "division by zero");
|
|
342
|
+
const positivePower = require_integer_power.powerByRepeatedSquaring({
|
|
343
|
+
base: complexBase,
|
|
344
|
+
exponent: -exponent.value,
|
|
345
|
+
identity: complexUnit,
|
|
346
|
+
multiply: multiplyComplexValues
|
|
347
|
+
});
|
|
348
|
+
if (isFiniteAndNonZero(positivePower)) return require_evaluation.definite(reciprocalOf(positivePower));
|
|
349
|
+
return require_evaluation.definite(require_integer_power.powerByRepeatedSquaring({
|
|
350
|
+
base: reciprocalOf(complexBase),
|
|
351
|
+
exponent: -exponent.value,
|
|
352
|
+
identity: complexUnit,
|
|
353
|
+
multiply: multiplyComplexValues
|
|
354
|
+
}));
|
|
325
355
|
}
|
|
326
356
|
/**
|
|
327
357
|
* Dispatches `arithmetic` by operand kind. The three cross-kind temporal combinations this design defines (`instant - instant`, `instant + duration`, `duration + instant`) are checked explicitly first, in that order, against the exact operator each requires; any other combination touching an `instant` is `wrong-type` (see "Temporal values" in README.md -- e.g. adding two instants, or subtracting a `duration` from an `instant`, are deliberately *not* defined). Same-kind `duration`/`duration` combinations are delegated to `applyArithmeticOnDurations`; a `duration` paired with anything other than an `instant` or another `duration` is `wrong-type`. Everything remaining requires two `number` operands.
|
|
328
358
|
*/
|
|
329
|
-
function
|
|
359
|
+
function applyArithmeticByKind(op, left, right) {
|
|
330
360
|
if (left.kind === "instant" && right.kind === "instant" && op === "subtract") {
|
|
331
361
|
const leftEpoch = toEpochMilliseconds(left.value);
|
|
332
362
|
if (leftEpoch === void 0) return unparseableInstant(left.value);
|
|
@@ -359,6 +389,26 @@ function applyArithmetic(op, left, right) {
|
|
|
359
389
|
}
|
|
360
390
|
return applyArithmeticOnNumbers(op, left, right);
|
|
361
391
|
}
|
|
392
|
+
/** Whether a computed value's numeric components are all finite. Only the kinds an arithmetic operator can produce carry one; any other kind has nothing to overflow. */
|
|
393
|
+
function hasFiniteMagnitude(value) {
|
|
394
|
+
switch (value.kind) {
|
|
395
|
+
case "number":
|
|
396
|
+
case "duration": return Number.isFinite(value.value);
|
|
397
|
+
case "complex": return Number.isFinite(value.re) && Number.isFinite(value.im);
|
|
398
|
+
case "text":
|
|
399
|
+
case "boolean":
|
|
400
|
+
case "instant": return true;
|
|
401
|
+
default: throw new Error("unreachable computed-value kind");
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* `arithmetic`'s entry point: the result of `applyArithmeticByKind`, except that a definite result whose magnitude overflowed to `Infinity` (or became `NaN`) is a `domain-error` instead. A value of that kind is outside what `ComputedValue` can serialise (JSON writes it as `null`), and an operation pushed outside its valid domain is exactly the category division by zero already uses. Checking once here, after every operator and operand kind has produced its result, is what keeps each of them honest without repeating the check per operator.
|
|
406
|
+
*/
|
|
407
|
+
function applyArithmetic(op, left, right) {
|
|
408
|
+
const result = applyArithmeticByKind(op, left, right);
|
|
409
|
+
if (result.status === "definite" && !hasFiniteMagnitude(result.value)) return require_evaluation.indeterminate("domain-error", "result is not a finite number");
|
|
410
|
+
return result;
|
|
411
|
+
}
|
|
362
412
|
/** `reference`'s optional expected-unit check: when `expectedUnit` is declared (from `node.unit`), the resolved value must be numeric (`number` or `complex`) and its own unit must match. Returns the `wrong-type` `Evaluation` to return immediately if the check fails, or `undefined` if the reference may resolve as-is. */
|
|
363
413
|
function checkReferenceUnit(expectedUnit, resolvedValue) {
|
|
364
414
|
if (expectedUnit === void 0) return void 0;
|
|
@@ -371,6 +421,7 @@ function invokeRegisteredFunction(functions, fnName, args) {
|
|
|
371
421
|
if (fn === void 0) return require_evaluation.indeterminate("wrong-type", `no function registered under the name '${fnName}'`);
|
|
372
422
|
const outcome = fn(args);
|
|
373
423
|
if ("domainError" in outcome) return require_evaluation.indeterminate("domain-error", outcome.domainError);
|
|
424
|
+
if ("wrongType" in outcome) return require_evaluation.indeterminate("wrong-type", outcome.wrongType);
|
|
374
425
|
return require_evaluation.definite(outcome);
|
|
375
426
|
}
|
|
376
427
|
//#endregion
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { a as Unit, t as ComputedValue } from "./computed-value-CbRF0Izc.cjs";
|
|
2
|
+
import { FunctionRegistry } from "./functions.cjs";
|
|
2
3
|
import { ArithmeticOperator, ComparisonOperator, TextComparisonOperator } from "./tree.cjs";
|
|
3
4
|
import { Evaluation } from "./evaluation.cjs";
|
|
4
|
-
import { FunctionRegistry } from "./functions.cjs";
|
|
5
5
|
//#region src/evaluator-operations.d.ts
|
|
6
6
|
/** The three-valued AND table: `false` is absorbing regardless of the other operand's indeterminacy; otherwise both-definite folds to a boolean AND; otherwise indeterminate, with the tie-break rule (declared operand order, left before right) applied via `firstIndeterminate`. */
|
|
7
7
|
export declare function combineAnd(left: Evaluation<boolean>, right: Evaluation<boolean>): Evaluation<boolean>;
|
|
8
8
|
/** The three-valued OR table: mirror image of `combineAnd`, with `true` absorbing. */
|
|
9
9
|
export declare function combineOr(left: Evaluation<boolean>, right: Evaluation<boolean>): Evaluation<boolean>;
|
|
10
|
-
/** `compare`'s two operands: valid kinds are `number` (matching units required), `instant` (ordered by parsed epoch millisecond), or `duration` (ordered by
|
|
10
|
+
/** `compare`'s two operands: valid kinds are `number` (matching units required), `instant` (ordered by parsed epoch millisecond), or `duration` (ordered by `compareDurations`, in whatever unit each carries, with a NaN unordered) -- `text` is never valid here (see `textCompare`), and a kind mismatch between the two operands is `wrong-type`. Narrowing `right` against a literal `left.kind` case (rather than asserting it) is what lets both sides stay properly typed with no `as`. */
|
|
11
11
|
export declare function compareValues(op: ComparisonOperator, left: ComputedValue, right: ComputedValue): Evaluation<boolean>;
|
|
12
12
|
/** `textCompare`'s two operands must both resolve to the `text` computed-value kind -- any other kind, on either operand, is `wrong-type` (see the `textCompare` section of README.md). `equals`/`notEquals` are exact string equality; `matches`/`notMatches` interpret `right`'s text as an ECMAScript regular expression tested against `left`'s text; `portableMatches`/`portableNotMatches` interpret it as a pattern in `trilean-regex`'s own restricted grammar instead, matched by that package's finite-automaton reference matcher rather than the host's native `RegExp` engine -- see the `textCompare` section of README.md for when to reach for the portable pair instead of the plain one. An invalid pattern is `wrong-type` rather than a thrown exception either way -- every data-quality problem stays inside the `Evaluation` result, per `Evaluation<T>`'s own doc comment in evaluation.ts. */
|
|
13
13
|
export declare function compareText(op: TextComparisonOperator, left: ComputedValue, right: ComputedValue): Evaluation<boolean>;
|
|
@@ -16,7 +16,7 @@ export declare function computeMembershipMatch(operand: ComputedValue, candidate
|
|
|
16
16
|
/** `negate` is never sugar for "zero minus the value" (see the `arithmetic`/`negate` section of README.md) -- a `duration`'s magnitude is negated directly, in its own original unit, with no subtraction or millisecond normalisation involved. */
|
|
17
17
|
export declare function applyNegate(operand: ComputedValue): Evaluation<ComputedValue>;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* `arithmetic`'s entry point: the result of `applyArithmeticByKind`, except that a definite result whose magnitude overflowed to `Infinity` (or became `NaN`) is a `domain-error` instead. A value of that kind is outside what `ComputedValue` can serialise (JSON writes it as `null`), and an operation pushed outside its valid domain is exactly the category division by zero already uses. Checking once here, after every operator and operand kind has produced its result, is what keeps each of them honest without repeating the check per operator.
|
|
20
20
|
*/
|
|
21
21
|
export declare function applyArithmetic(op: ArithmeticOperator, left: ComputedValue, right: ComputedValue): Evaluation<ComputedValue>;
|
|
22
22
|
/** `reference`'s optional expected-unit check: when `expectedUnit` is declared (from `node.unit`), the resolved value must be numeric (`number` or `complex`) and its own unit must match. Returns the `wrong-type` `Evaluation` to return immediately if the check fails, or `undefined` if the reference may resolve as-is. */
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { a as Unit, t as ComputedValue } from "./computed-value-CbRF0Izc.js";
|
|
2
|
+
import { FunctionRegistry } from "./functions.js";
|
|
2
3
|
import { ArithmeticOperator, ComparisonOperator, TextComparisonOperator } from "./tree.js";
|
|
3
4
|
import { Evaluation } from "./evaluation.js";
|
|
4
|
-
import { FunctionRegistry } from "./functions.js";
|
|
5
5
|
//#region src/evaluator-operations.d.ts
|
|
6
6
|
/** The three-valued AND table: `false` is absorbing regardless of the other operand's indeterminacy; otherwise both-definite folds to a boolean AND; otherwise indeterminate, with the tie-break rule (declared operand order, left before right) applied via `firstIndeterminate`. */
|
|
7
7
|
export declare function combineAnd(left: Evaluation<boolean>, right: Evaluation<boolean>): Evaluation<boolean>;
|
|
8
8
|
/** The three-valued OR table: mirror image of `combineAnd`, with `true` absorbing. */
|
|
9
9
|
export declare function combineOr(left: Evaluation<boolean>, right: Evaluation<boolean>): Evaluation<boolean>;
|
|
10
|
-
/** `compare`'s two operands: valid kinds are `number` (matching units required), `instant` (ordered by parsed epoch millisecond), or `duration` (ordered by
|
|
10
|
+
/** `compare`'s two operands: valid kinds are `number` (matching units required), `instant` (ordered by parsed epoch millisecond), or `duration` (ordered by `compareDurations`, in whatever unit each carries, with a NaN unordered) -- `text` is never valid here (see `textCompare`), and a kind mismatch between the two operands is `wrong-type`. Narrowing `right` against a literal `left.kind` case (rather than asserting it) is what lets both sides stay properly typed with no `as`. */
|
|
11
11
|
export declare function compareValues(op: ComparisonOperator, left: ComputedValue, right: ComputedValue): Evaluation<boolean>;
|
|
12
12
|
/** `textCompare`'s two operands must both resolve to the `text` computed-value kind -- any other kind, on either operand, is `wrong-type` (see the `textCompare` section of README.md). `equals`/`notEquals` are exact string equality; `matches`/`notMatches` interpret `right`'s text as an ECMAScript regular expression tested against `left`'s text; `portableMatches`/`portableNotMatches` interpret it as a pattern in `trilean-regex`'s own restricted grammar instead, matched by that package's finite-automaton reference matcher rather than the host's native `RegExp` engine -- see the `textCompare` section of README.md for when to reach for the portable pair instead of the plain one. An invalid pattern is `wrong-type` rather than a thrown exception either way -- every data-quality problem stays inside the `Evaluation` result, per `Evaluation<T>`'s own doc comment in evaluation.ts. */
|
|
13
13
|
export declare function compareText(op: TextComparisonOperator, left: ComputedValue, right: ComputedValue): Evaluation<boolean>;
|
|
@@ -16,7 +16,7 @@ export declare function computeMembershipMatch(operand: ComputedValue, candidate
|
|
|
16
16
|
/** `negate` is never sugar for "zero minus the value" (see the `arithmetic`/`negate` section of README.md) -- a `duration`'s magnitude is negated directly, in its own original unit, with no subtraction or millisecond normalisation involved. */
|
|
17
17
|
export declare function applyNegate(operand: ComputedValue): Evaluation<ComputedValue>;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* `arithmetic`'s entry point: the result of `applyArithmeticByKind`, except that a definite result whose magnitude overflowed to `Infinity` (or became `NaN`) is a `domain-error` instead. A value of that kind is outside what `ComputedValue` can serialise (JSON writes it as `null`), and an operation pushed outside its valid domain is exactly the category division by zero already uses. Checking once here, after every operator and operand kind has produced its result, is what keeps each of them honest without repeating the check per operator.
|
|
20
20
|
*/
|
|
21
21
|
export declare function applyArithmetic(op: ArithmeticOperator, left: ComputedValue, right: ComputedValue): Evaluation<ComputedValue>;
|
|
22
22
|
/** `reference`'s optional expected-unit check: when `expectedUnit` is declared (from `node.unit`), the resolved value must be numeric (`number` or `complex`) and its own unit must match. Returns the `wrong-type` `Evaluation` to return immediately if the check fails, or `undefined` if the reference may resolve as-is. */
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { combineUnitsForDivide, combineUnitsForMultiply, unitsEqual } from "./computed-value.js";
|
|
2
|
+
import { divideComplexComponents } from "./complex-division.js";
|
|
3
|
+
import { compareDurations, millisecondsPerDurationUnit } from "./duration-order.js";
|
|
2
4
|
import { definite, firstIndeterminate, indeterminate } from "./evaluation.js";
|
|
5
|
+
import { powerByRepeatedSquaring } from "./integer-power.js";
|
|
3
6
|
import { RegexParseError, compilePattern } from "trilean-regex";
|
|
4
7
|
//#region src/evaluator-operations.ts
|
|
5
8
|
/** The three-valued AND table: `false` is absorbing regardless of the other operand's indeterminacy; otherwise both-definite folds to a boolean AND; otherwise indeterminate, with the tie-break rule (declared operand order, left before right) applied via `firstIndeterminate`. */
|
|
@@ -35,14 +38,7 @@ function applyComparisonOperator(op, left, right) {
|
|
|
35
38
|
default: throw new Error("unreachable comparison operator");
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
ms: 1,
|
|
40
|
-
s: 1e3,
|
|
41
|
-
min: 6e4,
|
|
42
|
-
h: 36e5,
|
|
43
|
-
d: 864e5
|
|
44
|
-
};
|
|
45
|
-
/** Normalises a `duration`'s magnitude to milliseconds, the common base unit for combining or comparing two `duration`s (or an `instant` and a `duration`) of potentially different `DurationUnit`s -- shared by `compareValues`'s own `duration` branch below and by the temporal arithmetic further down. */
|
|
41
|
+
/** Converts a `duration`'s magnitude to milliseconds by multiplying, the base unit the temporal arithmetic below combines durations of different `DurationUnit`s in and shifts an `instant` by. Comparing two durations does not use it: `compareDurations` does that without converting, because this multiplication overflows for very large spans. */
|
|
46
42
|
function toMilliseconds(value, unit) {
|
|
47
43
|
return value * millisecondsPerDurationUnit[unit];
|
|
48
44
|
}
|
|
@@ -63,7 +59,7 @@ function instantFromEpochMilliseconds(epochMilliseconds) {
|
|
|
63
59
|
value: shifted.toISOString()
|
|
64
60
|
});
|
|
65
61
|
}
|
|
66
|
-
/** `compare`'s two operands: valid kinds are `number` (matching units required), `instant` (ordered by parsed epoch millisecond), or `duration` (ordered by
|
|
62
|
+
/** `compare`'s two operands: valid kinds are `number` (matching units required), `instant` (ordered by parsed epoch millisecond), or `duration` (ordered by `compareDurations`, in whatever unit each carries, with a NaN unordered) -- `text` is never valid here (see `textCompare`), and a kind mismatch between the two operands is `wrong-type`. Narrowing `right` against a literal `left.kind` case (rather than asserting it) is what lets both sides stay properly typed with no `as`. */
|
|
67
63
|
function compareValues(op, left, right) {
|
|
68
64
|
switch (left.kind) {
|
|
69
65
|
case "number":
|
|
@@ -83,9 +79,11 @@ function compareValues(op, left, right) {
|
|
|
83
79
|
if (rightEpoch === void 0) return unparseableInstant(right.value);
|
|
84
80
|
return definite(applyComparisonOperator(op, leftEpoch, rightEpoch));
|
|
85
81
|
}
|
|
86
|
-
case "duration":
|
|
82
|
+
case "duration": {
|
|
87
83
|
if (right.kind !== "duration") return indeterminate("wrong-type", `cannot compare a 'duration' value with a '${right.kind}' value`);
|
|
88
|
-
|
|
84
|
+
const order = compareDurations(left, right);
|
|
85
|
+
return definite(applyComparisonOperator(op, order ?? NaN, 0));
|
|
86
|
+
}
|
|
89
87
|
case "complex":
|
|
90
88
|
if (op !== "eq" && op !== "neq") return indeterminate("wrong-type", `ordering operator '${op}' is not defined for complex values; the complex plane has no total order`);
|
|
91
89
|
if (right.kind !== "complex") return indeterminate("wrong-type", `cannot compare a 'complex' value with a '${right.kind}' value`);
|
|
@@ -150,7 +148,7 @@ function computeMembershipMatch(operand, candidate) {
|
|
|
150
148
|
}
|
|
151
149
|
case "duration":
|
|
152
150
|
if (candidate.kind !== "duration") return indeterminate("wrong-type", `cannot compare a 'duration' value with a '${candidate.kind}' value for membership`);
|
|
153
|
-
return definite(
|
|
151
|
+
return definite(compareDurations(operand, candidate) === 0);
|
|
154
152
|
case "complex":
|
|
155
153
|
if (candidate.kind !== "complex") return indeterminate("wrong-type", `cannot compare a 'complex' value with a '${candidate.kind}' value for membership`);
|
|
156
154
|
if (!unitsEqual(operand.unit, candidate.unit)) return indeterminate("wrong-type", "cannot compare complex values with incompatible units for membership");
|
|
@@ -263,7 +261,7 @@ function toComplexValue(value) {
|
|
|
263
261
|
unit: value.unit
|
|
264
262
|
};
|
|
265
263
|
}
|
|
266
|
-
/** The complex product, as its own component-level helper rather than only a branch of the operator switch below, because `power`'s
|
|
264
|
+
/** The complex product, as its own component-level helper rather than only a branch of the operator switch below, because `power`'s exponentiation by squaring needs exactly this and must not re-derive it. */
|
|
267
265
|
function multiplyComplexValues(left, right) {
|
|
268
266
|
return {
|
|
269
267
|
kind: "complex",
|
|
@@ -293,12 +291,12 @@ function applyArithmeticOnComplex(op, left, right) {
|
|
|
293
291
|
});
|
|
294
292
|
case "multiply": return definite(multiplyComplexValues(left, right));
|
|
295
293
|
case "divide": {
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
if (right.re === 0 && right.im === 0) return indeterminate("domain-error", "division by zero");
|
|
295
|
+
const quotient = divideComplexComponents(left, right);
|
|
298
296
|
return definite({
|
|
299
297
|
kind: "complex",
|
|
300
|
-
re:
|
|
301
|
-
im:
|
|
298
|
+
re: quotient.re,
|
|
299
|
+
im: quotient.im,
|
|
302
300
|
unit: combineUnitsForDivide(left.unit, right.unit)
|
|
303
301
|
});
|
|
304
302
|
}
|
|
@@ -306,7 +304,23 @@ function applyArithmeticOnComplex(op, left, right) {
|
|
|
306
304
|
default: throw new Error("unreachable arithmetic operator");
|
|
307
305
|
}
|
|
308
306
|
}
|
|
309
|
-
/** `
|
|
307
|
+
/** `1 / value` for a non-zero complex value, carrying the inverse unit. */
|
|
308
|
+
function reciprocalOf(value) {
|
|
309
|
+
return {
|
|
310
|
+
kind: "complex",
|
|
311
|
+
...divideComplexComponents({
|
|
312
|
+
re: 1,
|
|
313
|
+
im: 0
|
|
314
|
+
}, value),
|
|
315
|
+
unit: combineUnitsForDivide({}, value.unit)
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
/** Whether a complex value is finite and not zero, which is what dividing by it needs. A positive power that has overflowed or underflowed to zero is neither, and cannot be inverted. */
|
|
319
|
+
function isFiniteAndNonZero(value) {
|
|
320
|
+
const larger = Math.max(Math.abs(value.re), Math.abs(value.im));
|
|
321
|
+
return Number.isFinite(larger) && larger > 0;
|
|
322
|
+
}
|
|
323
|
+
/** `power` with a complex operand on either side, defined for exactly one case: a real integer exponent, evaluated as the repeated multiplication that integer exponentiation *is*, grouped by squaring so the work grows with the logarithm of the exponent rather than the exponent itself. The price is accuracy: the error of squaring grows in proportion to the exponent, so for large exponents the result is many times less accurate than a plain multiplication loop's (the "Complex values" section of README.md has the measurement, and explains why an arbitrary complex exponent stays out of scope). */
|
|
310
324
|
function applyComplexPower(base, exponent) {
|
|
311
325
|
if (exponent.kind !== "number" || !Number.isInteger(exponent.value)) return indeterminate("wrong-type", "'power' with a complex operand requires a real integer exponent");
|
|
312
326
|
if (!isDimensionless(base.unit) || !isDimensionless(exponent.unit)) return indeterminate("wrong-type", "'power' requires dimensionless operands");
|
|
@@ -317,15 +331,31 @@ function applyComplexPower(base, exponent) {
|
|
|
317
331
|
unit: {}
|
|
318
332
|
};
|
|
319
333
|
const complexBase = toComplexValue(base);
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
334
|
+
if (exponent.value >= 0) return definite(powerByRepeatedSquaring({
|
|
335
|
+
base: complexBase,
|
|
336
|
+
exponent: exponent.value,
|
|
337
|
+
identity: complexUnit,
|
|
338
|
+
multiply: multiplyComplexValues
|
|
339
|
+
}));
|
|
340
|
+
if (complexBase.re === 0 && complexBase.im === 0) return indeterminate("domain-error", "division by zero");
|
|
341
|
+
const positivePower = powerByRepeatedSquaring({
|
|
342
|
+
base: complexBase,
|
|
343
|
+
exponent: -exponent.value,
|
|
344
|
+
identity: complexUnit,
|
|
345
|
+
multiply: multiplyComplexValues
|
|
346
|
+
});
|
|
347
|
+
if (isFiniteAndNonZero(positivePower)) return definite(reciprocalOf(positivePower));
|
|
348
|
+
return definite(powerByRepeatedSquaring({
|
|
349
|
+
base: reciprocalOf(complexBase),
|
|
350
|
+
exponent: -exponent.value,
|
|
351
|
+
identity: complexUnit,
|
|
352
|
+
multiply: multiplyComplexValues
|
|
353
|
+
}));
|
|
324
354
|
}
|
|
325
355
|
/**
|
|
326
356
|
* Dispatches `arithmetic` by operand kind. The three cross-kind temporal combinations this design defines (`instant - instant`, `instant + duration`, `duration + instant`) are checked explicitly first, in that order, against the exact operator each requires; any other combination touching an `instant` is `wrong-type` (see "Temporal values" in README.md -- e.g. adding two instants, or subtracting a `duration` from an `instant`, are deliberately *not* defined). Same-kind `duration`/`duration` combinations are delegated to `applyArithmeticOnDurations`; a `duration` paired with anything other than an `instant` or another `duration` is `wrong-type`. Everything remaining requires two `number` operands.
|
|
327
357
|
*/
|
|
328
|
-
function
|
|
358
|
+
function applyArithmeticByKind(op, left, right) {
|
|
329
359
|
if (left.kind === "instant" && right.kind === "instant" && op === "subtract") {
|
|
330
360
|
const leftEpoch = toEpochMilliseconds(left.value);
|
|
331
361
|
if (leftEpoch === void 0) return unparseableInstant(left.value);
|
|
@@ -358,6 +388,26 @@ function applyArithmetic(op, left, right) {
|
|
|
358
388
|
}
|
|
359
389
|
return applyArithmeticOnNumbers(op, left, right);
|
|
360
390
|
}
|
|
391
|
+
/** Whether a computed value's numeric components are all finite. Only the kinds an arithmetic operator can produce carry one; any other kind has nothing to overflow. */
|
|
392
|
+
function hasFiniteMagnitude(value) {
|
|
393
|
+
switch (value.kind) {
|
|
394
|
+
case "number":
|
|
395
|
+
case "duration": return Number.isFinite(value.value);
|
|
396
|
+
case "complex": return Number.isFinite(value.re) && Number.isFinite(value.im);
|
|
397
|
+
case "text":
|
|
398
|
+
case "boolean":
|
|
399
|
+
case "instant": return true;
|
|
400
|
+
default: throw new Error("unreachable computed-value kind");
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* `arithmetic`'s entry point: the result of `applyArithmeticByKind`, except that a definite result whose magnitude overflowed to `Infinity` (or became `NaN`) is a `domain-error` instead. A value of that kind is outside what `ComputedValue` can serialise (JSON writes it as `null`), and an operation pushed outside its valid domain is exactly the category division by zero already uses. Checking once here, after every operator and operand kind has produced its result, is what keeps each of them honest without repeating the check per operator.
|
|
405
|
+
*/
|
|
406
|
+
function applyArithmetic(op, left, right) {
|
|
407
|
+
const result = applyArithmeticByKind(op, left, right);
|
|
408
|
+
if (result.status === "definite" && !hasFiniteMagnitude(result.value)) return indeterminate("domain-error", "result is not a finite number");
|
|
409
|
+
return result;
|
|
410
|
+
}
|
|
361
411
|
/** `reference`'s optional expected-unit check: when `expectedUnit` is declared (from `node.unit`), the resolved value must be numeric (`number` or `complex`) and its own unit must match. Returns the `wrong-type` `Evaluation` to return immediately if the check fails, or `undefined` if the reference may resolve as-is. */
|
|
362
412
|
function checkReferenceUnit(expectedUnit, resolvedValue) {
|
|
363
413
|
if (expectedUnit === void 0) return void 0;
|
|
@@ -370,6 +420,7 @@ function invokeRegisteredFunction(functions, fnName, args) {
|
|
|
370
420
|
if (fn === void 0) return indeterminate("wrong-type", `no function registered under the name '${fnName}'`);
|
|
371
421
|
const outcome = fn(args);
|
|
372
422
|
if ("domainError" in outcome) return indeterminate("domain-error", outcome.domainError);
|
|
423
|
+
if ("wrongType" in outcome) return indeterminate("wrong-type", outcome.wrongType);
|
|
373
424
|
return definite(outcome);
|
|
374
425
|
}
|
|
375
426
|
//#endregion
|
package/dist/evaluator.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as ComputedValue } from "./computed-value-CbRF0Izc.cjs";
|
|
2
|
+
import { FunctionRegistry } from "./functions.cjs";
|
|
2
3
|
import { ExpressionNode, PredicateNode } from "./tree.cjs";
|
|
3
4
|
import { Evaluation } from "./evaluation.cjs";
|
|
4
5
|
import { EvaluationBudget } from "./evaluator-budget.cjs";
|
|
5
|
-
import { FunctionRegistry } from "./functions.cjs";
|
|
6
6
|
import { Task } from "./evaluator-effect.cjs";
|
|
7
7
|
import { EvaluationContext, EvaluatorResolvers } from "./resolvers.cjs";
|
|
8
8
|
//#region src/evaluator.d.ts
|
package/dist/evaluator.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as ComputedValue } from "./computed-value-CbRF0Izc.js";
|
|
2
|
+
import { FunctionRegistry } from "./functions.js";
|
|
2
3
|
import { ExpressionNode, PredicateNode } from "./tree.js";
|
|
3
4
|
import { Evaluation } from "./evaluation.js";
|
|
4
5
|
import { EvaluationBudget } from "./evaluator-budget.js";
|
|
5
|
-
import { FunctionRegistry } from "./functions.js";
|
|
6
6
|
import { Task } from "./evaluator-effect.js";
|
|
7
7
|
import { EvaluationContext, EvaluatorResolvers } from "./resolvers.js";
|
|
8
8
|
//#region src/evaluator.d.ts
|
package/dist/functions.d.cts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { t as ComputedValue } from "./computed-value-CbRF0Izc.cjs";
|
|
2
2
|
//#region src/functions.d.ts
|
|
3
|
+
/** What a registered function returns instead of a value when it cannot produce one: a `domainError` for an argument of the right kind outside the function's domain (`squareRoot` of a negative number), or a `wrongType` for an argument the function cannot accept at all (the wrong kind, or units that do not match). They surface as `domain-error` and `wrong-type` respectively, the same split every other node kind draws. */
|
|
4
|
+
export type FunctionFailure = {
|
|
5
|
+
domainError: string;
|
|
6
|
+
} | {
|
|
7
|
+
wrongType: string;
|
|
8
|
+
};
|
|
3
9
|
/**
|
|
4
|
-
* Named functions available to a `call` expression node, supplied once at evaluator construction time (see `createEvaluator` in evaluator-factory.ts) rather than per evaluation call. A function reports a
|
|
10
|
+
* Named functions available to a `call` expression node, supplied once at evaluator construction time (see `createEvaluator` in evaluator-factory.ts) rather than per evaluation call. A function reports a failure by returning a `FunctionFailure` rather than throwing, which keeps `call` inside the same three-outcome model as every other node kind.
|
|
5
11
|
*/
|
|
6
|
-
export type FunctionRegistry = Record<string, (args: readonly ComputedValue[]) => ComputedValue |
|
|
7
|
-
domainError: string;
|
|
8
|
-
}>;
|
|
12
|
+
export type FunctionRegistry = Record<string, (args: readonly ComputedValue[]) => ComputedValue | FunctionFailure>;
|
|
9
13
|
export declare const emptyFunctionRegistry: FunctionRegistry;
|
|
10
14
|
//#endregion
|
package/dist/functions.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { t as ComputedValue } from "./computed-value-CbRF0Izc.js";
|
|
2
2
|
//#region src/functions.d.ts
|
|
3
|
+
/** What a registered function returns instead of a value when it cannot produce one: a `domainError` for an argument of the right kind outside the function's domain (`squareRoot` of a negative number), or a `wrongType` for an argument the function cannot accept at all (the wrong kind, or units that do not match). They surface as `domain-error` and `wrong-type` respectively, the same split every other node kind draws. */
|
|
4
|
+
export type FunctionFailure = {
|
|
5
|
+
domainError: string;
|
|
6
|
+
} | {
|
|
7
|
+
wrongType: string;
|
|
8
|
+
};
|
|
3
9
|
/**
|
|
4
|
-
* Named functions available to a `call` expression node, supplied once at evaluator construction time (see `createEvaluator` in evaluator-factory.ts) rather than per evaluation call. A function reports a
|
|
10
|
+
* Named functions available to a `call` expression node, supplied once at evaluator construction time (see `createEvaluator` in evaluator-factory.ts) rather than per evaluation call. A function reports a failure by returning a `FunctionFailure` rather than throwing, which keeps `call` inside the same three-outcome model as every other node kind.
|
|
5
11
|
*/
|
|
6
|
-
export type FunctionRegistry = Record<string, (args: readonly ComputedValue[]) => ComputedValue |
|
|
7
|
-
domainError: string;
|
|
8
|
-
}>;
|
|
12
|
+
export type FunctionRegistry = Record<string, (args: readonly ComputedValue[]) => ComputedValue | FunctionFailure>;
|
|
9
13
|
export declare const emptyFunctionRegistry: FunctionRegistry;
|
|
10
14
|
//#endregion
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_complex = require("./complex.cjs");
|
|
3
2
|
const require_computed_value = require("./computed-value.cjs");
|
|
3
|
+
const require_complex = require("./complex.cjs");
|
|
4
|
+
const require_builtin_functions = require("./builtin-functions.cjs");
|
|
4
5
|
const require_derived_aggregates = require("./derived-aggregates.cjs");
|
|
5
6
|
const require_derived_connectives = require("./derived-connectives.cjs");
|
|
6
7
|
const require_derived_patterns = require("./derived-patterns.cjs");
|
|
@@ -10,6 +11,8 @@ const require_json_value = require("./json-value.cjs");
|
|
|
10
11
|
const require_tree = require("./tree.cjs");
|
|
11
12
|
const require_functions = require("./functions.cjs");
|
|
12
13
|
const require_evaluator_factory = require("./evaluator-factory.cjs");
|
|
14
|
+
const require_input_resolvers = require("./input-resolvers.cjs");
|
|
15
|
+
const require_evaluate_document = require("./evaluate-document.cjs");
|
|
13
16
|
exports.AccumulatorNodeSchema = require_tree.AccumulatorNodeSchema;
|
|
14
17
|
exports.AllOfNodeSchema = require_tree.AllOfNodeSchema;
|
|
15
18
|
exports.AndNodeSchema = require_tree.AndNodeSchema;
|
|
@@ -55,6 +58,7 @@ exports.TreeReferenceNodeSchema = require_tree.TreeReferenceNodeSchema;
|
|
|
55
58
|
exports.UnitSchema = require_computed_value.UnitSchema;
|
|
56
59
|
exports.and = require_derived_connectives.and;
|
|
57
60
|
exports.average = require_derived_aggregates.average;
|
|
61
|
+
exports.builtinFunctions = require_builtin_functions.builtinFunctions;
|
|
58
62
|
exports.coalesce = require_derived_values.coalesce;
|
|
59
63
|
exports.combineUnitsForDivide = require_computed_value.combineUnitsForDivide;
|
|
60
64
|
exports.combineUnitsForMultiply = require_computed_value.combineUnitsForMultiply;
|
|
@@ -64,9 +68,11 @@ exports.complexMagnitude = require_complex.complexMagnitude;
|
|
|
64
68
|
exports.complexPhase = require_complex.complexPhase;
|
|
65
69
|
exports.count = require_derived_aggregates.count;
|
|
66
70
|
exports.createEvaluator = require_evaluator_factory.createEvaluator;
|
|
71
|
+
exports.createInputResolvers = require_input_resolvers.createInputResolvers;
|
|
67
72
|
exports.createSyncEvaluator = require_evaluator_factory.createSyncEvaluator;
|
|
68
73
|
exports.definite = require_evaluation.definite;
|
|
69
74
|
exports.emptyFunctionRegistry = require_functions.emptyFunctionRegistry;
|
|
75
|
+
exports.evaluateDocument = require_evaluate_document.evaluateDocument;
|
|
70
76
|
exports.evaluatePredicate = require_evaluator_factory.evaluatePredicate;
|
|
71
77
|
exports.evaluateValue = require_evaluator_factory.evaluateValue;
|
|
72
78
|
exports.firstIndeterminate = require_evaluation.firstIndeterminate;
|
|
@@ -79,6 +85,7 @@ exports.none = require_derived_connectives.none;
|
|
|
79
85
|
exports.nor = require_derived_connectives.nor;
|
|
80
86
|
exports.not = require_derived_connectives.not;
|
|
81
87
|
exports.or = require_derived_connectives.or;
|
|
88
|
+
exports.parseInputs = require_input_resolvers.parseInputs;
|
|
82
89
|
exports.prefixPattern = require_derived_patterns.prefixPattern;
|
|
83
90
|
exports.presenceOf = require_derived_aggregates.presenceOf;
|
|
84
91
|
exports.sum = require_derived_aggregates.sum;
|