trilean 1.6.2 → 1.7.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 +13 -0
- package/dist/complex.d.cts +5 -6
- package/dist/complex.d.ts +5 -6
- package/dist/derived-aggregates.d.cts +5 -6
- package/dist/derived-aggregates.d.ts +5 -6
- package/dist/derived-connectives.d.cts +10 -11
- package/dist/derived-connectives.d.ts +10 -11
- package/dist/derived-patterns.d.cts +4 -5
- package/dist/derived-patterns.d.ts +4 -5
- package/dist/derived-values.d.cts +2 -3
- package/dist/derived-values.d.ts +2 -3
- package/dist/evaluation.d.cts +7 -8
- package/dist/evaluation.d.ts +7 -8
- package/dist/evaluator-budget.d.cts +6 -7
- package/dist/evaluator-budget.d.ts +6 -7
- package/dist/evaluator-collection.cjs +5 -4
- package/dist/evaluator-collection.d.cts +7 -7
- package/dist/evaluator-collection.d.ts +7 -7
- package/dist/evaluator-collection.js +5 -4
- package/dist/evaluator-effect.cjs +54 -0
- package/dist/evaluator-effect.d.cts +37 -0
- package/dist/evaluator-effect.d.ts +37 -0
- package/dist/evaluator-effect.js +50 -0
- package/dist/evaluator-factory.cjs +13 -2
- package/dist/evaluator-factory.d.cts +17 -6
- package/dist/evaluator-factory.d.ts +17 -6
- package/dist/evaluator-factory.js +13 -3
- package/dist/evaluator-indeterminacy-helpers.d.cts +26 -27
- package/dist/evaluator-indeterminacy-helpers.d.ts +26 -27
- package/dist/evaluator-operations.d.cts +10 -11
- package/dist/evaluator-operations.d.ts +10 -11
- package/dist/evaluator-test-helpers.d.cts +6 -7
- package/dist/evaluator-test-helpers.d.ts +6 -7
- package/dist/evaluator.cjs +43 -40
- package/dist/evaluator.d.cts +5 -5
- package/dist/evaluator.d.ts +5 -5
- package/dist/evaluator.js +43 -40
- package/dist/functions.d.cts +3 -4
- package/dist/functions.d.ts +3 -4
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/resolvers.d.cts +22 -6
- package/dist/resolvers.d.ts +22 -6
- package/dist/tree.d.cts +77 -78
- package/dist/tree.d.ts +77 -78
- package/package.json +3 -3
- package/schemas/trilean.schema.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/evaluator-effect.ts
|
|
2
|
+
/**
|
|
3
|
+
* Suspends until `value` is available. The driver resumes the task with exactly that value (awaited, in the async driver), and the generator's own "next" type is `T`, so the result is typed without an assertion.
|
|
4
|
+
*/
|
|
5
|
+
function* wait(value) {
|
|
6
|
+
return yield {
|
|
7
|
+
kind: "wait",
|
|
8
|
+
value
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Suspends until every task has finished and returns their results in order. The tasks are independent of one another by construction, so a driver may interleave them (async) or run them in sequence (sync).
|
|
13
|
+
*/
|
|
14
|
+
function* all(tasks) {
|
|
15
|
+
return yield {
|
|
16
|
+
kind: "all",
|
|
17
|
+
tasks
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function isThenable(value) {
|
|
21
|
+
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
22
|
+
}
|
|
23
|
+
/** Runs a task to completion, awaiting each suspension and running an `all` group's tasks concurrently. */
|
|
24
|
+
async function runAsync(task) {
|
|
25
|
+
let step = task.next();
|
|
26
|
+
while (step.done !== true) {
|
|
27
|
+
const suspension = step.value;
|
|
28
|
+
const result = suspension.kind === "wait" ? await suspension.value : await Promise.all(suspension.tasks.map(runAsync));
|
|
29
|
+
step = task.next(result);
|
|
30
|
+
}
|
|
31
|
+
return step.value;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runs a task to completion without awaiting anything: an `all` group's tasks run one after another, and a `wait` on a promise throws, since a synchronous evaluator has nothing to do with one.
|
|
35
|
+
*/
|
|
36
|
+
function runSync(task) {
|
|
37
|
+
let step = task.next();
|
|
38
|
+
while (step.done !== true) {
|
|
39
|
+
const suspension = step.value;
|
|
40
|
+
let result;
|
|
41
|
+
if (suspension.kind === "wait") {
|
|
42
|
+
if (isThenable(suspension.value)) throw new TypeError("a resolver supplied to a synchronous evaluator returned a promise; use the asynchronous evaluator for asynchronous resolvers");
|
|
43
|
+
result = suspension.value;
|
|
44
|
+
} else result = suspension.tasks.map(runSync);
|
|
45
|
+
step = task.next(result);
|
|
46
|
+
}
|
|
47
|
+
return step.value;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { all, runAsync, runSync, wait };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_evaluator_budget = require("./evaluator-budget.cjs");
|
|
3
|
+
const require_evaluator_effect = require("./evaluator-effect.cjs");
|
|
3
4
|
const require_evaluator = require("./evaluator.cjs");
|
|
4
5
|
const require_functions = require("./functions.cjs");
|
|
5
6
|
//#region src/evaluator-factory.ts
|
|
@@ -8,12 +9,22 @@ const require_functions = require("./functions.cjs");
|
|
|
8
9
|
*/
|
|
9
10
|
function createEvaluator({ functions = require_functions.emptyFunctionRegistry, maxNodes = require_evaluator_budget.DEFAULT_MAX_EVALUATION_NODES, maxNestingDepth = 500 }) {
|
|
10
11
|
return {
|
|
11
|
-
evaluatePredicate: async (node, context, resolvers) => require_evaluator.evaluatePredicateInternal(node, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, require_evaluator_budget.createEvaluationBudget(maxNodes, maxNestingDepth), 0),
|
|
12
|
-
evaluateValue: async (node, context, resolvers) => require_evaluator.evaluateValueInternal(node, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, require_evaluator_budget.createEvaluationBudget(maxNodes, maxNestingDepth), 0)
|
|
12
|
+
evaluatePredicate: async (node, context, resolvers) => require_evaluator_effect.runAsync(require_evaluator.evaluatePredicateInternal(node, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, require_evaluator_budget.createEvaluationBudget(maxNodes, maxNestingDepth), 0)),
|
|
13
|
+
evaluateValue: async (node, context, resolvers) => require_evaluator_effect.runAsync(require_evaluator.evaluateValueInternal(node, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, require_evaluator_budget.createEvaluationBudget(maxNodes, maxNestingDepth), 0))
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The synchronous counterpart of `createEvaluator`: the same node rules, options and `Evaluation` results, over `SyncResolvers`, returning the result directly instead of a promise. It runs the same implementation as the asynchronous evaluator, so the two cannot disagree about a node. One difference follows from having nothing to wait on: independent operands (both sides of an `and`, the candidates of a `memberOf`, the items of a collection) are evaluated one after another rather than concurrently, so when a `maxNodes` or `maxNestingDepth` budget is exhausted partway through a tree, which operand meets the limit first can differ from the asynchronous evaluator.
|
|
18
|
+
*/
|
|
19
|
+
function createSyncEvaluator({ functions = require_functions.emptyFunctionRegistry, maxNodes = require_evaluator_budget.DEFAULT_MAX_EVALUATION_NODES, maxNestingDepth = 500 }) {
|
|
20
|
+
return {
|
|
21
|
+
evaluatePredicate: (node, context, resolvers) => require_evaluator_effect.runSync(require_evaluator.evaluatePredicateInternal(node, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, require_evaluator_budget.createEvaluationBudget(maxNodes, maxNestingDepth), 0)),
|
|
22
|
+
evaluateValue: (node, context, resolvers) => require_evaluator_effect.runSync(require_evaluator.evaluateValueInternal(node, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, require_evaluator_budget.createEvaluationBudget(maxNodes, maxNestingDepth), 0))
|
|
13
23
|
};
|
|
14
24
|
}
|
|
15
25
|
const { evaluatePredicate, evaluateValue } = createEvaluator({});
|
|
16
26
|
//#endregion
|
|
17
27
|
exports.createEvaluator = createEvaluator;
|
|
28
|
+
exports.createSyncEvaluator = createSyncEvaluator;
|
|
18
29
|
exports.evaluatePredicate = evaluatePredicate;
|
|
19
30
|
exports.evaluateValue = evaluateValue;
|
|
@@ -2,21 +2,32 @@ import { t as ComputedValue } from "./computed-value-CbRF0Izc.cjs";
|
|
|
2
2
|
import { ExpressionNode, PredicateNode } from "./tree.cjs";
|
|
3
3
|
import { Evaluation } from "./evaluation.cjs";
|
|
4
4
|
import { FunctionRegistry } from "./functions.cjs";
|
|
5
|
-
import { EvaluationContext, Resolvers } from "./resolvers.cjs";
|
|
5
|
+
import { EvaluationContext, Resolvers, SyncResolvers } from "./resolvers.cjs";
|
|
6
6
|
//#region src/evaluator-factory.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* Builds a bound `{ evaluatePredicate, evaluateValue }` pair over a caller-supplied function registry for `call` nodes -- the registry is bound once, at construction time, unlike `resolvers`, which are supplied fresh to every call. `maxNodes` and `maxNestingDepth` configure that same pair's own `EvaluationBudget` (see its doc comment in evaluator-budget.ts), created fresh for every top-level `evaluatePredicate`/`evaluateValue` invocation so budgets never leak between unrelated calls. The bare module-level `evaluatePredicate`/`evaluateValue` exports below are `createEvaluator({})`'s output, so both caps default to `DEFAULT_MAX_EVALUATION_NODES`/`DEFAULT_MAX_NESTING_DEPTH` for every caller that does not explicitly configure them.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
/** Options shared by `createEvaluator` and `createSyncEvaluator`. */
|
|
11
|
+
export interface EvaluatorOptions {
|
|
11
12
|
functions?: FunctionRegistry;
|
|
12
13
|
/** Caps the total number of predicate/expression nodes a single `evaluatePredicate`/`evaluateValue` call may visit -- see `createEvaluationBudget`. Defaults to `DEFAULT_MAX_EVALUATION_NODES`. */
|
|
13
14
|
maxNodes?: number;
|
|
14
15
|
/** Caps ordinary recursive-descent nesting depth, independent of `MAX_TREE_REFERENCE_DEPTH`'s own `treeReference` chain-depth cap -- see `createEvaluationBudget`. Defaults to `DEFAULT_MAX_NESTING_DEPTH`. */
|
|
15
16
|
maxNestingDepth?: number;
|
|
16
|
-
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Builds a bound `{ evaluatePredicate, evaluateValue }` pair over a caller-supplied function registry for `call` nodes -- the registry is bound once, at construction time, unlike `resolvers`, which are supplied fresh to every call. `maxNodes` and `maxNestingDepth` configure that same pair's own `EvaluationBudget` (see its doc comment in evaluator-budget.ts), created fresh for every top-level `evaluatePredicate`/`evaluateValue` invocation so budgets never leak between unrelated calls. The bare module-level `evaluatePredicate`/`evaluateValue` exports below are `createEvaluator({})`'s output, so both caps default to `DEFAULT_MAX_EVALUATION_NODES`/`DEFAULT_MAX_NESTING_DEPTH` for every caller that does not explicitly configure them.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createEvaluator({ functions, maxNodes, maxNestingDepth }: EvaluatorOptions): {
|
|
17
22
|
evaluatePredicate: (node: PredicateNode, context: EvaluationContext, resolvers: Readonly<Resolvers>) => Promise<Evaluation<boolean>>;
|
|
18
23
|
evaluateValue: (node: ExpressionNode, context: EvaluationContext, resolvers: Readonly<Resolvers>) => Promise<Evaluation<ComputedValue>>;
|
|
19
24
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The synchronous counterpart of `createEvaluator`: the same node rules, options and `Evaluation` results, over `SyncResolvers`, returning the result directly instead of a promise. It runs the same implementation as the asynchronous evaluator, so the two cannot disagree about a node. One difference follows from having nothing to wait on: independent operands (both sides of an `and`, the candidates of a `memberOf`, the items of a collection) are evaluated one after another rather than concurrently, so when a `maxNodes` or `maxNestingDepth` budget is exhausted partway through a tree, which operand meets the limit first can differ from the asynchronous evaluator.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createSyncEvaluator({ functions, maxNodes, maxNestingDepth }: EvaluatorOptions): {
|
|
29
|
+
evaluatePredicate: (node: PredicateNode, context: EvaluationContext, resolvers: Readonly<SyncResolvers>) => Evaluation<boolean>;
|
|
30
|
+
evaluateValue: (node: ExpressionNode, context: EvaluationContext, resolvers: Readonly<SyncResolvers>) => Evaluation<ComputedValue>;
|
|
31
|
+
};
|
|
32
|
+
export declare const evaluatePredicate: (node: PredicateNode, context: EvaluationContext, resolvers: Readonly<Resolvers>) => Promise<Evaluation<boolean>>, evaluateValue: (node: ExpressionNode, context: EvaluationContext, resolvers: Readonly<Resolvers>) => Promise<Evaluation<ComputedValue>>;
|
|
33
|
+
//#endregion
|
|
@@ -2,21 +2,32 @@ import { t as ComputedValue } from "./computed-value-CbRF0Izc.js";
|
|
|
2
2
|
import { ExpressionNode, PredicateNode } from "./tree.js";
|
|
3
3
|
import { Evaluation } from "./evaluation.js";
|
|
4
4
|
import { FunctionRegistry } from "./functions.js";
|
|
5
|
-
import { EvaluationContext, Resolvers } from "./resolvers.js";
|
|
5
|
+
import { EvaluationContext, Resolvers, SyncResolvers } from "./resolvers.js";
|
|
6
6
|
//#region src/evaluator-factory.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* Builds a bound `{ evaluatePredicate, evaluateValue }` pair over a caller-supplied function registry for `call` nodes -- the registry is bound once, at construction time, unlike `resolvers`, which are supplied fresh to every call. `maxNodes` and `maxNestingDepth` configure that same pair's own `EvaluationBudget` (see its doc comment in evaluator-budget.ts), created fresh for every top-level `evaluatePredicate`/`evaluateValue` invocation so budgets never leak between unrelated calls. The bare module-level `evaluatePredicate`/`evaluateValue` exports below are `createEvaluator({})`'s output, so both caps default to `DEFAULT_MAX_EVALUATION_NODES`/`DEFAULT_MAX_NESTING_DEPTH` for every caller that does not explicitly configure them.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
/** Options shared by `createEvaluator` and `createSyncEvaluator`. */
|
|
11
|
+
export interface EvaluatorOptions {
|
|
11
12
|
functions?: FunctionRegistry;
|
|
12
13
|
/** Caps the total number of predicate/expression nodes a single `evaluatePredicate`/`evaluateValue` call may visit -- see `createEvaluationBudget`. Defaults to `DEFAULT_MAX_EVALUATION_NODES`. */
|
|
13
14
|
maxNodes?: number;
|
|
14
15
|
/** Caps ordinary recursive-descent nesting depth, independent of `MAX_TREE_REFERENCE_DEPTH`'s own `treeReference` chain-depth cap -- see `createEvaluationBudget`. Defaults to `DEFAULT_MAX_NESTING_DEPTH`. */
|
|
15
16
|
maxNestingDepth?: number;
|
|
16
|
-
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Builds a bound `{ evaluatePredicate, evaluateValue }` pair over a caller-supplied function registry for `call` nodes -- the registry is bound once, at construction time, unlike `resolvers`, which are supplied fresh to every call. `maxNodes` and `maxNestingDepth` configure that same pair's own `EvaluationBudget` (see its doc comment in evaluator-budget.ts), created fresh for every top-level `evaluatePredicate`/`evaluateValue` invocation so budgets never leak between unrelated calls. The bare module-level `evaluatePredicate`/`evaluateValue` exports below are `createEvaluator({})`'s output, so both caps default to `DEFAULT_MAX_EVALUATION_NODES`/`DEFAULT_MAX_NESTING_DEPTH` for every caller that does not explicitly configure them.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createEvaluator({ functions, maxNodes, maxNestingDepth }: EvaluatorOptions): {
|
|
17
22
|
evaluatePredicate: (node: PredicateNode, context: EvaluationContext, resolvers: Readonly<Resolvers>) => Promise<Evaluation<boolean>>;
|
|
18
23
|
evaluateValue: (node: ExpressionNode, context: EvaluationContext, resolvers: Readonly<Resolvers>) => Promise<Evaluation<ComputedValue>>;
|
|
19
24
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The synchronous counterpart of `createEvaluator`: the same node rules, options and `Evaluation` results, over `SyncResolvers`, returning the result directly instead of a promise. It runs the same implementation as the asynchronous evaluator, so the two cannot disagree about a node. One difference follows from having nothing to wait on: independent operands (both sides of an `and`, the candidates of a `memberOf`, the items of a collection) are evaluated one after another rather than concurrently, so when a `maxNodes` or `maxNestingDepth` budget is exhausted partway through a tree, which operand meets the limit first can differ from the asynchronous evaluator.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createSyncEvaluator({ functions, maxNodes, maxNestingDepth }: EvaluatorOptions): {
|
|
29
|
+
evaluatePredicate: (node: PredicateNode, context: EvaluationContext, resolvers: Readonly<SyncResolvers>) => Evaluation<boolean>;
|
|
30
|
+
evaluateValue: (node: ExpressionNode, context: EvaluationContext, resolvers: Readonly<SyncResolvers>) => Evaluation<ComputedValue>;
|
|
31
|
+
};
|
|
32
|
+
export declare const evaluatePredicate: (node: PredicateNode, context: EvaluationContext, resolvers: Readonly<Resolvers>) => Promise<Evaluation<boolean>>, evaluateValue: (node: ExpressionNode, context: EvaluationContext, resolvers: Readonly<Resolvers>) => Promise<Evaluation<ComputedValue>>;
|
|
33
|
+
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_MAX_EVALUATION_NODES, createEvaluationBudget } from "./evaluator-budget.js";
|
|
2
|
+
import { runAsync, runSync } from "./evaluator-effect.js";
|
|
2
3
|
import { evaluatePredicateInternal, evaluateValueInternal } from "./evaluator.js";
|
|
3
4
|
import { emptyFunctionRegistry } from "./functions.js";
|
|
4
5
|
//#region src/evaluator-factory.ts
|
|
@@ -7,10 +8,19 @@ import { emptyFunctionRegistry } from "./functions.js";
|
|
|
7
8
|
*/
|
|
8
9
|
function createEvaluator({ functions = emptyFunctionRegistry, maxNodes = DEFAULT_MAX_EVALUATION_NODES, maxNestingDepth = 500 }) {
|
|
9
10
|
return {
|
|
10
|
-
evaluatePredicate: async (node, context, resolvers) => evaluatePredicateInternal(node, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, createEvaluationBudget(maxNodes, maxNestingDepth), 0),
|
|
11
|
-
evaluateValue: async (node, context, resolvers) => evaluateValueInternal(node, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, createEvaluationBudget(maxNodes, maxNestingDepth), 0)
|
|
11
|
+
evaluatePredicate: async (node, context, resolvers) => runAsync(evaluatePredicateInternal(node, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, createEvaluationBudget(maxNodes, maxNestingDepth), 0)),
|
|
12
|
+
evaluateValue: async (node, context, resolvers) => runAsync(evaluateValueInternal(node, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, createEvaluationBudget(maxNodes, maxNestingDepth), 0))
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The synchronous counterpart of `createEvaluator`: the same node rules, options and `Evaluation` results, over `SyncResolvers`, returning the result directly instead of a promise. It runs the same implementation as the asynchronous evaluator, so the two cannot disagree about a node. One difference follows from having nothing to wait on: independent operands (both sides of an `and`, the candidates of a `memberOf`, the items of a collection) are evaluated one after another rather than concurrently, so when a `maxNodes` or `maxNestingDepth` budget is exhausted partway through a tree, which operand meets the limit first can differ from the asynchronous evaluator.
|
|
17
|
+
*/
|
|
18
|
+
function createSyncEvaluator({ functions = emptyFunctionRegistry, maxNodes = DEFAULT_MAX_EVALUATION_NODES, maxNestingDepth = 500 }) {
|
|
19
|
+
return {
|
|
20
|
+
evaluatePredicate: (node, context, resolvers) => runSync(evaluatePredicateInternal(node, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, createEvaluationBudget(maxNodes, maxNestingDepth), 0)),
|
|
21
|
+
evaluateValue: (node, context, resolvers) => runSync(evaluateValueInternal(node, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, createEvaluationBudget(maxNodes, maxNestingDepth), 0))
|
|
12
22
|
};
|
|
13
23
|
}
|
|
14
24
|
const { evaluatePredicate, evaluateValue } = createEvaluator({});
|
|
15
25
|
//#endregion
|
|
16
|
-
export { createEvaluator, evaluatePredicate, evaluateValue };
|
|
26
|
+
export { createEvaluator, createSyncEvaluator, evaluatePredicate, evaluateValue };
|
|
@@ -6,33 +6,33 @@ import { EvaluationContext, Resolvers } from "./resolvers.cjs";
|
|
|
6
6
|
/**
|
|
7
7
|
* Shared fixture machinery for the two split indeterminacy test files (evaluator.indeterminacy-table.test.ts, evaluator.indeterminacy-cases.test.ts): systematic, table-driven coverage of README.md's "Indeterminacy reference" section, one fixture per node-kind x reason-code combination that section documents, for every `PredicateNode`/`ExpressionNode` kind implemented. This complements, rather than replaces, the ad hoc behavioural tests already spread across the evaluator.*.test.ts files and truth-tables.test.ts.
|
|
8
8
|
*/
|
|
9
|
-
declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
|
|
10
|
-
declare function isUnknownArray(value: unknown): value is unknown[];
|
|
9
|
+
export declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
|
|
10
|
+
export declare function isUnknownArray(value: unknown): value is unknown[];
|
|
11
11
|
/** A single resolver pool shared by every fixture below, covering every named key/table/collection any fixture needs. Fixtures that need genuinely different resolver behaviour (the delegate/call rows) supply their own. */
|
|
12
|
-
declare const baseResolvers: Resolvers;
|
|
13
|
-
declare const numberLiteral: (value: number) => ExpressionNode;
|
|
14
|
-
declare const missingRef: ExpressionNode;
|
|
15
|
-
declare const divideByZero: ExpressionNode;
|
|
16
|
-
declare const wrongTypeArithmetic: ExpressionNode;
|
|
17
|
-
declare const trueGuard: PredicateNode;
|
|
18
|
-
declare const falseGuard: PredicateNode;
|
|
19
|
-
declare const missingGuard: PredicateNode;
|
|
12
|
+
export declare const baseResolvers: Resolvers;
|
|
13
|
+
export declare const numberLiteral: (value: number) => ExpressionNode;
|
|
14
|
+
export declare const missingRef: ExpressionNode;
|
|
15
|
+
export declare const divideByZero: ExpressionNode;
|
|
16
|
+
export declare const wrongTypeArithmetic: ExpressionNode;
|
|
17
|
+
export declare const trueGuard: PredicateNode;
|
|
18
|
+
export declare const falseGuard: PredicateNode;
|
|
19
|
+
export declare const missingGuard: PredicateNode;
|
|
20
20
|
/** Arbitrary non-`{-1,0,1,2}` magnitudes used below, named individually so each numeric literal only appears once (`@typescript-eslint/no-magic-numbers` only exempts -1/0/1/2 and object-literal property values, not values passed as plain call arguments). */
|
|
21
|
-
declare const memberOfProbeValue = 5;
|
|
22
|
-
declare const reduceInitialSeed = 5;
|
|
23
|
-
declare const laterConditionalCaseValue = 3;
|
|
24
|
-
declare const untouchedReduceInitial = 42;
|
|
25
|
-
declare const uniqueHitPolicyThirdCaseValue = 3;
|
|
26
|
-
type Expected = {
|
|
21
|
+
export declare const memberOfProbeValue = 5;
|
|
22
|
+
export declare const reduceInitialSeed = 5;
|
|
23
|
+
export declare const laterConditionalCaseValue = 3;
|
|
24
|
+
export declare const untouchedReduceInitial = 42;
|
|
25
|
+
export declare const uniqueHitPolicyThirdCaseValue = 3;
|
|
26
|
+
export type Expected = {
|
|
27
27
|
readonly status: "definite";
|
|
28
28
|
} | {
|
|
29
29
|
readonly status: "indeterminate";
|
|
30
30
|
readonly code: IndeterminateReason["code"];
|
|
31
31
|
};
|
|
32
|
-
declare const isDefinite: Expected;
|
|
33
|
-
declare const isNotFound: Expected;
|
|
34
|
-
declare const isWrongType: Expected;
|
|
35
|
-
declare const isDomainError: Expected;
|
|
32
|
+
export declare const isDefinite: Expected;
|
|
33
|
+
export declare const isNotFound: Expected;
|
|
34
|
+
export declare const isWrongType: Expected;
|
|
35
|
+
export declare const isDomainError: Expected;
|
|
36
36
|
/** The minimal shape `runFixture` needs from either `evaluatePredicate`'s or `evaluateValue`'s result -- both `Evaluation<boolean>` and `Evaluation<ComputedValue>` are structurally assignable here since only the indeterminate branch's `reason` is ever inspected, never the definite branch's `value`. Typing `Fixture.run`'s result as this proper discriminated union, rather than the looser `{ status: string }` it replaces, is what lets `runFixture` below narrow `result.reason` directly instead of needing a type assertion. */
|
|
37
37
|
type FixtureRunResult = {
|
|
38
38
|
readonly status: "definite";
|
|
@@ -40,18 +40,17 @@ type FixtureRunResult = {
|
|
|
40
40
|
readonly status: "indeterminate";
|
|
41
41
|
readonly reason: IndeterminateReason;
|
|
42
42
|
};
|
|
43
|
-
interface Fixture {
|
|
43
|
+
export interface Fixture {
|
|
44
44
|
readonly description: string;
|
|
45
45
|
readonly expected: Expected;
|
|
46
46
|
readonly run: () => Promise<FixtureRunResult>;
|
|
47
47
|
}
|
|
48
|
-
interface FixtureOverrides {
|
|
48
|
+
export interface FixtureOverrides {
|
|
49
49
|
readonly context?: EvaluationContext;
|
|
50
50
|
readonly resolvers?: Resolvers;
|
|
51
51
|
readonly functions?: FunctionRegistry;
|
|
52
52
|
}
|
|
53
|
-
declare function pred(description: string, node: PredicateNode, expected: Expected, overrides?: FixtureOverrides): Fixture;
|
|
54
|
-
declare function expr(description: string, node: ExpressionNode, expected: Expected, overrides?: FixtureOverrides): Fixture;
|
|
55
|
-
declare function runFixture({ run, expected }: Fixture): Promise<void>;
|
|
56
|
-
//#endregion
|
|
57
|
-
export { Expected, Fixture, FixtureOverrides, baseResolvers, divideByZero, expr, falseGuard, isDefinite, isDomainError, isNotFound, isPlainRecord, isUnknownArray, isWrongType, laterConditionalCaseValue, memberOfProbeValue, missingGuard, missingRef, numberLiteral, pred, reduceInitialSeed, runFixture, trueGuard, uniqueHitPolicyThirdCaseValue, untouchedReduceInitial, wrongTypeArithmetic };
|
|
53
|
+
export declare function pred(description: string, node: PredicateNode, expected: Expected, overrides?: FixtureOverrides): Fixture;
|
|
54
|
+
export declare function expr(description: string, node: ExpressionNode, expected: Expected, overrides?: FixtureOverrides): Fixture;
|
|
55
|
+
export declare function runFixture({ run, expected }: Fixture): Promise<void>;
|
|
56
|
+
//#endregion
|
|
@@ -6,33 +6,33 @@ import { EvaluationContext, Resolvers } from "./resolvers.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* Shared fixture machinery for the two split indeterminacy test files (evaluator.indeterminacy-table.test.ts, evaluator.indeterminacy-cases.test.ts): systematic, table-driven coverage of README.md's "Indeterminacy reference" section, one fixture per node-kind x reason-code combination that section documents, for every `PredicateNode`/`ExpressionNode` kind implemented. This complements, rather than replaces, the ad hoc behavioural tests already spread across the evaluator.*.test.ts files and truth-tables.test.ts.
|
|
8
8
|
*/
|
|
9
|
-
declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
|
|
10
|
-
declare function isUnknownArray(value: unknown): value is unknown[];
|
|
9
|
+
export declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
|
|
10
|
+
export declare function isUnknownArray(value: unknown): value is unknown[];
|
|
11
11
|
/** A single resolver pool shared by every fixture below, covering every named key/table/collection any fixture needs. Fixtures that need genuinely different resolver behaviour (the delegate/call rows) supply their own. */
|
|
12
|
-
declare const baseResolvers: Resolvers;
|
|
13
|
-
declare const numberLiteral: (value: number) => ExpressionNode;
|
|
14
|
-
declare const missingRef: ExpressionNode;
|
|
15
|
-
declare const divideByZero: ExpressionNode;
|
|
16
|
-
declare const wrongTypeArithmetic: ExpressionNode;
|
|
17
|
-
declare const trueGuard: PredicateNode;
|
|
18
|
-
declare const falseGuard: PredicateNode;
|
|
19
|
-
declare const missingGuard: PredicateNode;
|
|
12
|
+
export declare const baseResolvers: Resolvers;
|
|
13
|
+
export declare const numberLiteral: (value: number) => ExpressionNode;
|
|
14
|
+
export declare const missingRef: ExpressionNode;
|
|
15
|
+
export declare const divideByZero: ExpressionNode;
|
|
16
|
+
export declare const wrongTypeArithmetic: ExpressionNode;
|
|
17
|
+
export declare const trueGuard: PredicateNode;
|
|
18
|
+
export declare const falseGuard: PredicateNode;
|
|
19
|
+
export declare const missingGuard: PredicateNode;
|
|
20
20
|
/** Arbitrary non-`{-1,0,1,2}` magnitudes used below, named individually so each numeric literal only appears once (`@typescript-eslint/no-magic-numbers` only exempts -1/0/1/2 and object-literal property values, not values passed as plain call arguments). */
|
|
21
|
-
declare const memberOfProbeValue = 5;
|
|
22
|
-
declare const reduceInitialSeed = 5;
|
|
23
|
-
declare const laterConditionalCaseValue = 3;
|
|
24
|
-
declare const untouchedReduceInitial = 42;
|
|
25
|
-
declare const uniqueHitPolicyThirdCaseValue = 3;
|
|
26
|
-
type Expected = {
|
|
21
|
+
export declare const memberOfProbeValue = 5;
|
|
22
|
+
export declare const reduceInitialSeed = 5;
|
|
23
|
+
export declare const laterConditionalCaseValue = 3;
|
|
24
|
+
export declare const untouchedReduceInitial = 42;
|
|
25
|
+
export declare const uniqueHitPolicyThirdCaseValue = 3;
|
|
26
|
+
export type Expected = {
|
|
27
27
|
readonly status: "definite";
|
|
28
28
|
} | {
|
|
29
29
|
readonly status: "indeterminate";
|
|
30
30
|
readonly code: IndeterminateReason["code"];
|
|
31
31
|
};
|
|
32
|
-
declare const isDefinite: Expected;
|
|
33
|
-
declare const isNotFound: Expected;
|
|
34
|
-
declare const isWrongType: Expected;
|
|
35
|
-
declare const isDomainError: Expected;
|
|
32
|
+
export declare const isDefinite: Expected;
|
|
33
|
+
export declare const isNotFound: Expected;
|
|
34
|
+
export declare const isWrongType: Expected;
|
|
35
|
+
export declare const isDomainError: Expected;
|
|
36
36
|
/** The minimal shape `runFixture` needs from either `evaluatePredicate`'s or `evaluateValue`'s result -- both `Evaluation<boolean>` and `Evaluation<ComputedValue>` are structurally assignable here since only the indeterminate branch's `reason` is ever inspected, never the definite branch's `value`. Typing `Fixture.run`'s result as this proper discriminated union, rather than the looser `{ status: string }` it replaces, is what lets `runFixture` below narrow `result.reason` directly instead of needing a type assertion. */
|
|
37
37
|
type FixtureRunResult = {
|
|
38
38
|
readonly status: "definite";
|
|
@@ -40,18 +40,17 @@ type FixtureRunResult = {
|
|
|
40
40
|
readonly status: "indeterminate";
|
|
41
41
|
readonly reason: IndeterminateReason;
|
|
42
42
|
};
|
|
43
|
-
interface Fixture {
|
|
43
|
+
export interface Fixture {
|
|
44
44
|
readonly description: string;
|
|
45
45
|
readonly expected: Expected;
|
|
46
46
|
readonly run: () => Promise<FixtureRunResult>;
|
|
47
47
|
}
|
|
48
|
-
interface FixtureOverrides {
|
|
48
|
+
export interface FixtureOverrides {
|
|
49
49
|
readonly context?: EvaluationContext;
|
|
50
50
|
readonly resolvers?: Resolvers;
|
|
51
51
|
readonly functions?: FunctionRegistry;
|
|
52
52
|
}
|
|
53
|
-
declare function pred(description: string, node: PredicateNode, expected: Expected, overrides?: FixtureOverrides): Fixture;
|
|
54
|
-
declare function expr(description: string, node: ExpressionNode, expected: Expected, overrides?: FixtureOverrides): Fixture;
|
|
55
|
-
declare function runFixture({ run, expected }: Fixture): Promise<void>;
|
|
56
|
-
//#endregion
|
|
57
|
-
export { Expected, Fixture, FixtureOverrides, baseResolvers, divideByZero, expr, falseGuard, isDefinite, isDomainError, isNotFound, isPlainRecord, isUnknownArray, isWrongType, laterConditionalCaseValue, memberOfProbeValue, missingGuard, missingRef, numberLiteral, pred, reduceInitialSeed, runFixture, trueGuard, uniqueHitPolicyThirdCaseValue, untouchedReduceInitial, wrongTypeArithmetic };
|
|
53
|
+
export declare function pred(description: string, node: PredicateNode, expected: Expected, overrides?: FixtureOverrides): Fixture;
|
|
54
|
+
export declare function expr(description: string, node: ExpressionNode, expected: Expected, overrides?: FixtureOverrides): Fixture;
|
|
55
|
+
export declare function runFixture({ run, expected }: Fixture): Promise<void>;
|
|
56
|
+
//#endregion
|
|
@@ -4,24 +4,23 @@ import { Evaluation } from "./evaluation.cjs";
|
|
|
4
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
|
-
declare function combineAnd(left: Evaluation<boolean>, right: Evaluation<boolean>): Evaluation<boolean>;
|
|
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
|
-
declare function combineOr(left: Evaluation<boolean>, right: Evaluation<boolean>): Evaluation<boolean>;
|
|
9
|
+
export declare function combineOr(left: Evaluation<boolean>, right: Evaluation<boolean>): Evaluation<boolean>;
|
|
10
10
|
/** `compare`'s two operands: valid kinds are `number` (matching units required), `instant` (ordered by parsed epoch millisecond), or `duration` (ordered by magnitude normalised to milliseconds) -- `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
|
-
declare function compareValues(op: ComparisonOperator, left: ComputedValue, right: ComputedValue): Evaluation<boolean>;
|
|
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
|
-
declare function compareText(op: TextComparisonOperator, left: ComputedValue, right: ComputedValue): Evaluation<boolean>;
|
|
13
|
+
export declare function compareText(op: TextComparisonOperator, left: ComputedValue, right: ComputedValue): Evaluation<boolean>;
|
|
14
14
|
/** `memberOf`'s own value-equality test between two computed values -- kind-agnostic across `number`/`text`/`instant`/`duration` (see the `memberOf` section of README.md, and its "Derived aggregates" note that this equality is kind-agnostic across every computed-value kind), unlike `compare`'s own `eq`, which rejects a `text` operand outright and directs callers to `textCompare` instead. A kind mismatch, or a `number` pair with an incompatible unit, is `wrong-type` -- never simply "not equal". Narrowing `candidate` against a literal `operand.kind` case (rather than asserting it) is the same technique `compareValues` uses above. */
|
|
15
|
-
declare function computeMembershipMatch(operand: ComputedValue, candidate: ComputedValue): Evaluation<boolean>;
|
|
15
|
+
export declare function computeMembershipMatch(operand: ComputedValue, candidate: ComputedValue): Evaluation<boolean>;
|
|
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
|
-
declare function applyNegate(operand: ComputedValue): Evaluation<ComputedValue>;
|
|
17
|
+
export declare function applyNegate(operand: ComputedValue): Evaluation<ComputedValue>;
|
|
18
18
|
/**
|
|
19
19
|
* 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.
|
|
20
20
|
*/
|
|
21
|
-
declare function applyArithmetic(op: ArithmeticOperator, left: ComputedValue, right: ComputedValue): Evaluation<ComputedValue>;
|
|
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. */
|
|
23
|
-
declare function checkReferenceUnit(expectedUnit: Unit | undefined, resolvedValue: ComputedValue): Evaluation<never> | undefined;
|
|
23
|
+
export declare function checkReferenceUnit(expectedUnit: Unit | undefined, resolvedValue: ComputedValue): Evaluation<never> | undefined;
|
|
24
24
|
/** `call`'s own function-registry dispatch, given the `fn` name off the tree and its already-evaluated `args`. `node.fn` comes off the serialised tree, which this design treats as data that may have been authored anywhere (see README.md's opening section), while `FunctionRegistry` is an ordinary object with `Object.prototype` on its chain. A bare index lookup would therefore resolve `toString`, `valueOf`, `constructor` and friends as though a consumer had registered them; only the registry's own keys count as registered function names. */
|
|
25
|
-
declare function invokeRegisteredFunction(functions: Readonly<FunctionRegistry>, fnName: string, args: readonly ComputedValue[]): Evaluation<ComputedValue>;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { applyArithmetic, applyNegate, checkReferenceUnit, combineAnd, combineOr, compareText, compareValues, computeMembershipMatch, invokeRegisteredFunction };
|
|
25
|
+
export declare function invokeRegisteredFunction(functions: Readonly<FunctionRegistry>, fnName: string, args: readonly ComputedValue[]): Evaluation<ComputedValue>;
|
|
26
|
+
//#endregion
|
|
@@ -4,24 +4,23 @@ import { Evaluation } from "./evaluation.js";
|
|
|
4
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
|
-
declare function combineAnd(left: Evaluation<boolean>, right: Evaluation<boolean>): Evaluation<boolean>;
|
|
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
|
-
declare function combineOr(left: Evaluation<boolean>, right: Evaluation<boolean>): Evaluation<boolean>;
|
|
9
|
+
export declare function combineOr(left: Evaluation<boolean>, right: Evaluation<boolean>): Evaluation<boolean>;
|
|
10
10
|
/** `compare`'s two operands: valid kinds are `number` (matching units required), `instant` (ordered by parsed epoch millisecond), or `duration` (ordered by magnitude normalised to milliseconds) -- `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
|
-
declare function compareValues(op: ComparisonOperator, left: ComputedValue, right: ComputedValue): Evaluation<boolean>;
|
|
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
|
-
declare function compareText(op: TextComparisonOperator, left: ComputedValue, right: ComputedValue): Evaluation<boolean>;
|
|
13
|
+
export declare function compareText(op: TextComparisonOperator, left: ComputedValue, right: ComputedValue): Evaluation<boolean>;
|
|
14
14
|
/** `memberOf`'s own value-equality test between two computed values -- kind-agnostic across `number`/`text`/`instant`/`duration` (see the `memberOf` section of README.md, and its "Derived aggregates" note that this equality is kind-agnostic across every computed-value kind), unlike `compare`'s own `eq`, which rejects a `text` operand outright and directs callers to `textCompare` instead. A kind mismatch, or a `number` pair with an incompatible unit, is `wrong-type` -- never simply "not equal". Narrowing `candidate` against a literal `operand.kind` case (rather than asserting it) is the same technique `compareValues` uses above. */
|
|
15
|
-
declare function computeMembershipMatch(operand: ComputedValue, candidate: ComputedValue): Evaluation<boolean>;
|
|
15
|
+
export declare function computeMembershipMatch(operand: ComputedValue, candidate: ComputedValue): Evaluation<boolean>;
|
|
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
|
-
declare function applyNegate(operand: ComputedValue): Evaluation<ComputedValue>;
|
|
17
|
+
export declare function applyNegate(operand: ComputedValue): Evaluation<ComputedValue>;
|
|
18
18
|
/**
|
|
19
19
|
* 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.
|
|
20
20
|
*/
|
|
21
|
-
declare function applyArithmetic(op: ArithmeticOperator, left: ComputedValue, right: ComputedValue): Evaluation<ComputedValue>;
|
|
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. */
|
|
23
|
-
declare function checkReferenceUnit(expectedUnit: Unit | undefined, resolvedValue: ComputedValue): Evaluation<never> | undefined;
|
|
23
|
+
export declare function checkReferenceUnit(expectedUnit: Unit | undefined, resolvedValue: ComputedValue): Evaluation<never> | undefined;
|
|
24
24
|
/** `call`'s own function-registry dispatch, given the `fn` name off the tree and its already-evaluated `args`. `node.fn` comes off the serialised tree, which this design treats as data that may have been authored anywhere (see README.md's opening section), while `FunctionRegistry` is an ordinary object with `Object.prototype` on its chain. A bare index lookup would therefore resolve `toString`, `valueOf`, `constructor` and friends as though a consumer had registered them; only the registry's own keys count as registered function names. */
|
|
25
|
-
declare function invokeRegisteredFunction(functions: Readonly<FunctionRegistry>, fnName: string, args: readonly ComputedValue[]): Evaluation<ComputedValue>;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { applyArithmetic, applyNegate, checkReferenceUnit, combineAnd, combineOr, compareText, compareValues, computeMembershipMatch, invokeRegisteredFunction };
|
|
25
|
+
export declare function invokeRegisteredFunction(functions: Readonly<FunctionRegistry>, fnName: string, args: readonly ComputedValue[]): Evaluation<ComputedValue>;
|
|
26
|
+
//#endregion
|
|
@@ -2,12 +2,11 @@ import { Evaluation } from "./evaluation.cjs";
|
|
|
2
2
|
import { Resolvers } from "./resolvers.cjs";
|
|
3
3
|
//#region src/evaluator-test-helpers.d.ts
|
|
4
4
|
/** A resolver reporting a fixed `{ kind: "number", value: 10, unit: { m: 1 } }` for key `"present"`, and not-found for anything else -- `resolveLookup`/`resolveCollection` are never exercised by expression-level nodes and are stubbed only to satisfy `Resolvers`. Shared across the split `evaluator.*.test.ts` files below; a test needing genuinely different resolver behaviour spreads over it (`{ ...resolvers, resolveValue: ... }`) locally rather than mutating this shared instance. */
|
|
5
|
-
declare const resolvers: Resolvers;
|
|
6
|
-
declare function expectDefinite<T>(evaluation: Evaluation<T>, expected: T): void;
|
|
7
|
-
declare function expectIndeterminate<T>(evaluation: Evaluation<T>, code: "not-found" | "wrong-type" | "domain-error"): void;
|
|
5
|
+
export declare const resolvers: Resolvers;
|
|
6
|
+
export declare function expectDefinite<T>(evaluation: Evaluation<T>, expected: T): void;
|
|
7
|
+
export declare function expectIndeterminate<T>(evaluation: Evaluation<T>, code: "not-found" | "wrong-type" | "domain-error"): void;
|
|
8
8
|
/** A narrowing type guard for a resolver context treated as a plain record, following this repo's `object -> Record<string, unknown>` narrowing convention rather than an `as Record<string, unknown>` assertion. */
|
|
9
|
-
declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
|
|
9
|
+
export declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
|
|
10
10
|
/** `Array.isArray`'s own lib.es5.d.ts type predicate narrows to `any[]`, not `unknown[]` -- this re-typed wrapper is what lets a `resolveCollection` stub return a properly `unknown[]`-typed result instead of an implicit `any[]`. */
|
|
11
|
-
declare function isUnknownArray(value: unknown): value is unknown[];
|
|
12
|
-
//#endregion
|
|
13
|
-
export { expectDefinite, expectIndeterminate, isPlainRecord, isUnknownArray, resolvers };
|
|
11
|
+
export declare function isUnknownArray(value: unknown): value is unknown[];
|
|
12
|
+
//#endregion
|
|
@@ -2,12 +2,11 @@ import { Evaluation } from "./evaluation.js";
|
|
|
2
2
|
import { Resolvers } from "./resolvers.js";
|
|
3
3
|
//#region src/evaluator-test-helpers.d.ts
|
|
4
4
|
/** A resolver reporting a fixed `{ kind: "number", value: 10, unit: { m: 1 } }` for key `"present"`, and not-found for anything else -- `resolveLookup`/`resolveCollection` are never exercised by expression-level nodes and are stubbed only to satisfy `Resolvers`. Shared across the split `evaluator.*.test.ts` files below; a test needing genuinely different resolver behaviour spreads over it (`{ ...resolvers, resolveValue: ... }`) locally rather than mutating this shared instance. */
|
|
5
|
-
declare const resolvers: Resolvers;
|
|
6
|
-
declare function expectDefinite<T>(evaluation: Evaluation<T>, expected: T): void;
|
|
7
|
-
declare function expectIndeterminate<T>(evaluation: Evaluation<T>, code: "not-found" | "wrong-type" | "domain-error"): void;
|
|
5
|
+
export declare const resolvers: Resolvers;
|
|
6
|
+
export declare function expectDefinite<T>(evaluation: Evaluation<T>, expected: T): void;
|
|
7
|
+
export declare function expectIndeterminate<T>(evaluation: Evaluation<T>, code: "not-found" | "wrong-type" | "domain-error"): void;
|
|
8
8
|
/** A narrowing type guard for a resolver context treated as a plain record, following this repo's `object -> Record<string, unknown>` narrowing convention rather than an `as Record<string, unknown>` assertion. */
|
|
9
|
-
declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
|
|
9
|
+
export declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
|
|
10
10
|
/** `Array.isArray`'s own lib.es5.d.ts type predicate narrows to `any[]`, not `unknown[]` -- this re-typed wrapper is what lets a `resolveCollection` stub return a properly `unknown[]`-typed result instead of an implicit `any[]`. */
|
|
11
|
-
declare function isUnknownArray(value: unknown): value is unknown[];
|
|
12
|
-
//#endregion
|
|
13
|
-
export { expectDefinite, expectIndeterminate, isPlainRecord, isUnknownArray, resolvers };
|
|
11
|
+
export declare function isUnknownArray(value: unknown): value is unknown[];
|
|
12
|
+
//#endregion
|