functionalscript 0.18.0 → 0.20.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/fs/asn.1/module.f.js +7 -8
- package/fs/asn.1/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/asn.1/{test.f.js → proof.f.js} +12 -13
- package/fs/base128/proof.f.d.ts +1 -0
- package/fs/base128/{test.f.js → proof.f.js} +1 -1
- package/fs/bnf/data/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/bnf/data/{test.f.js → proof.f.js} +1 -1
- package/fs/bnf/proof.f.d.ts +3 -0
- package/fs/bnf/{test.f.js → proof.f.js} +1 -1
- package/fs/cas/module.f.js +2 -12
- package/fs/cas/proof.f.d.ts +1 -0
- package/fs/cas/proof.f.js +1 -0
- package/fs/cbase32/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/cbase32/{test.f.js → proof.f.js} +1 -1
- package/fs/ci/config/module.f.d.ts +4 -4
- package/fs/ci/config/module.f.js +4 -4
- package/fs/ci/node/module.f.js +12 -7
- package/fs/ci/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/ci/{test.f.js → proof.f.js} +1 -1
- package/fs/crypto/hmac/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/crypto/hmac/{test.f.js → proof.f.js} +1 -1
- package/fs/crypto/secp/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/crypto/secp/{test.f.js → proof.f.js} +1 -1
- package/fs/crypto/sha2/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/crypto/sha2/{test.f.js → proof.f.js} +1 -1
- package/fs/crypto/sign/module.f.js +3 -3
- package/fs/crypto/sign/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/crypto/sign/{test.f.js → proof.f.js} +1 -1
- package/fs/dev/module.f.d.ts +28 -2
- package/fs/dev/module.f.js +38 -22
- package/fs/dev/{test.f.d.ts → proof.f.d.ts} +5 -2
- package/fs/dev/{test.f.js → proof.f.js} +25 -2
- package/fs/dev/tf/module.d.ts +1 -2
- package/fs/dev/tf/module.f.d.ts +70 -7
- package/fs/dev/tf/module.f.js +115 -27
- package/fs/dev/tf/module.js +4 -103
- package/fs/dev/tf/{test.f.d.ts → proof.f.d.ts} +26 -0
- package/fs/dev/tf/{test.f.js → proof.f.js} +85 -38
- package/fs/dev/tf/scenarios/all.d.ts +1 -0
- package/fs/dev/tf/scenarios/all.js +3 -0
- package/fs/dev/tf/scenarios/async-subtests.fail.d.ts +4 -0
- package/fs/dev/tf/scenarios/async-subtests.fail.js +7 -0
- package/fs/dev/tf/scenarios/async-subtests.pass.d.ts +4 -0
- package/fs/dev/tf/scenarios/async-subtests.pass.js +7 -0
- package/fs/dev/tf/scenarios/async.fail.d.ts +1 -0
- package/fs/dev/tf/scenarios/async.fail.js +4 -0
- package/fs/dev/tf/scenarios/async.pass.d.ts +1 -0
- package/fs/dev/tf/scenarios/async.pass.js +3 -0
- package/fs/dev/tf/scenarios/fail.fail.f.d.ts +1 -0
- package/fs/dev/tf/scenarios/fail.fail.f.js +1 -0
- package/fs/dev/tf/scenarios/return-value.pass.f.d.ts +1 -0
- package/fs/dev/tf/scenarios/return-value.pass.f.js +2 -0
- package/fs/dev/tf/scenarios/thenable.pass.d.ts +3 -0
- package/fs/dev/tf/scenarios/thenable.pass.js +9 -0
- package/fs/dev/tf/scenarios/thenable2.pass.f.d.ts +3 -0
- package/fs/dev/tf/scenarios/thenable2.pass.f.js +3 -0
- package/fs/{bnf/test.f.d.ts → dev/tf/scenarios/throw.pass.f.d.ts} +3 -1
- package/fs/dev/tf/scenarios/throw.pass.f.js +3 -0
- package/fs/dev/version/proof.f.d.ts +3 -0
- package/fs/dev/version/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/ast/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/ast/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/parser/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/serializer/module.f.d.ts +2 -2
- package/fs/djs/serializer/module.f.js +47 -79
- package/fs/djs/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/serializer/{test.f.js → proof.f.js} +8 -8
- package/fs/djs/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/tokenizer/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/tokenizer-new/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/tokenizer-new/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/transpiler/module.f.d.ts +15 -0
- package/fs/djs/transpiler/module.f.js +10 -2
- package/fs/djs/transpiler/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/transpiler/{test.f.js → proof.f.js} +1 -1
- package/fs/fsc/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/fsc/{test.f.js → proof.f.js} +1 -1
- package/fs/fsm/proof.f.d.ts +4 -0
- package/fs/fsm/{test.f.js → proof.f.js} +1 -1
- package/fs/html/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/html/{test.f.js → proof.f.js} +1 -1
- package/fs/io/module.d.ts +1 -1
- package/fs/io/module.f.d.ts +8 -3
- package/fs/io/module.f.js +12 -12
- package/fs/io/module.js +43 -5
- package/fs/js/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/js/tokenizer/{test.f.js → proof.f.js} +1 -1
- package/fs/json/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/json/parser/{test.f.js → proof.f.js} +1 -1
- package/fs/json/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/json/{test.f.js → proof.f.js} +1 -1
- package/fs/json/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/json/serializer/{test.f.js → proof.f.js} +1 -1
- package/fs/json/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/json/tokenizer/{test.f.js → proof.f.js} +1 -1
- package/fs/path/proof.f.d.ts +5 -0
- package/fs/path/{test.f.js → proof.f.js} +4 -3
- package/fs/sul/id/module.f.js +3 -4
- package/fs/sul/id/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/sul/id/{test.f.js → proof.f.js} +1 -1
- package/fs/sul/level/hash/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/sul/level/hash/{test.f.js → proof.f.js} +1 -1
- package/fs/sul/level/literal/module.f.js +3 -3
- package/fs/sul/level/literal/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/sul/level/literal/{test.f.js → proof.f.js} +1 -1
- package/fs/sul/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/sul/{test.f.js → proof.f.js} +1 -1
- package/fs/text/ascii/proof.f.d.ts +3 -0
- package/fs/text/ascii/{test.f.js → proof.f.js} +1 -1
- package/fs/text/code_point/module.f.d.ts +28 -0
- package/fs/text/code_point/module.f.js +31 -0
- package/fs/text/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/text/{test.f.js → proof.f.js} +1 -1
- package/fs/text/sgr/proof.f.d.ts +1 -0
- package/fs/text/sgr/proof.f.js +23 -0
- package/fs/text/utf16/module.f.js +3 -53
- package/fs/text/utf16/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/text/utf16/{test.f.js → proof.f.js} +1 -1
- package/fs/text/utf8/module.f.js +3 -25
- package/fs/text/utf8/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/text/utf8/{test.f.js → proof.f.js} +1 -1
- package/fs/types/array/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/array/{test.f.js → proof.f.js} +1 -1
- package/fs/types/bigfloat/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/bigfloat/{test.f.js → proof.f.js} +1 -1
- package/fs/types/bigint/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/bigint/{test.f.js → proof.f.js} +1 -1
- package/fs/types/bit_vec/module.f.d.ts +9 -4
- package/fs/types/bit_vec/module.f.js +7 -9
- package/fs/types/bit_vec/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/bit_vec/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/find/proof.f.d.ts +1 -0
- package/fs/types/btree/find/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/btree/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/remove/module.f.d.ts +1 -1
- package/fs/types/btree/remove/module.f.js +7 -2
- package/fs/types/btree/remove/proof.f.d.ts +4 -0
- package/fs/types/btree/remove/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/set/module.f.d.ts +1 -1
- package/fs/types/btree/set/module.f.js +7 -2
- package/fs/types/btree/set/proof.f.d.ts +1 -0
- package/fs/types/btree/set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/types/module.f.d.ts +9 -0
- package/fs/types/btree/types/module.f.js +9 -1
- package/fs/types/byte_set/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/byte_set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/effects/module.f.d.ts +17 -0
- package/fs/types/effects/module.f.js +17 -0
- package/fs/types/effects/node/module.f.d.ts +66 -4
- package/fs/types/effects/node/module.f.js +5 -1
- package/fs/types/effects/node/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/effects/node/{test.f.js → proof.f.js} +1 -1
- package/fs/types/effects/node/virtual/module.f.d.ts +2 -1
- package/fs/types/effects/node/virtual/module.f.js +2 -0
- package/fs/types/effects/proof.f.d.ts +11 -0
- package/fs/types/effects/proof.f.js +57 -0
- package/fs/types/function/compare/proof.f.d.ts +1 -0
- package/fs/types/function/compare/{test.f.js → proof.f.js} +1 -1
- package/fs/types/function/operator/proof.f.d.ts +12 -0
- package/fs/types/function/operator/{test.f.js → proof.f.js} +11 -10
- package/fs/types/function/proof.f.d.ts +1 -0
- package/fs/types/function/{test.f.js → proof.f.js} +1 -1
- package/fs/types/list/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/list/{test.f.js → proof.f.js} +1 -1
- package/fs/types/map/proof.f.d.ts +4 -0
- package/fs/types/map/{test.f.js → proof.f.js} +1 -1
- package/fs/types/monoid/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/monoid/{test.f.js → proof.f.js} +1 -1
- package/fs/types/nibble_set/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/nibble_set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/nominal/proof.f.d.ts +4 -0
- package/fs/types/nominal/{test.f.js → proof.f.js} +1 -1
- package/fs/types/nullable/proof.f.d.ts +1 -0
- package/fs/types/nullable/{test.f.js → proof.f.js} +11 -2
- package/fs/types/number/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/number/{test.f.js → proof.f.js} +1 -1
- package/fs/types/object/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/object/{test.f.js → proof.f.js} +1 -1
- package/fs/types/ordered_map/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/ordered_map/{test.f.js → proof.f.js} +1 -1
- package/fs/types/patricia_trie/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/patricia_trie/{test.f.js → proof.f.js} +1 -1
- package/fs/types/prime_field/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/prime_field/{test.f.js → proof.f.js} +1 -1
- package/fs/types/range/proof.f.d.ts +1 -0
- package/fs/types/range/{test.f.js → proof.f.js} +1 -1
- package/fs/types/range_map/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/range_map/{test.f.js → proof.f.js} +1 -1
- package/fs/types/result/proof.f.d.ts +5 -0
- package/fs/types/result/{test.f.js → proof.f.js} +18 -2
- package/fs/types/rtti/parse/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/rtti/parse/{test.f.js → proof.f.js} +1 -1
- package/fs/types/rtti/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/rtti/{test.f.js → proof.f.js} +1 -1
- package/fs/types/rtti/ts/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/rtti/ts/{test.f.js → proof.f.js} +1 -1
- package/fs/types/rtti/validate/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/rtti/validate/{test.f.js → proof.f.js} +1 -1
- package/fs/types/sorted_list/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/sorted_list/{test.f.js → proof.f.js} +1 -1
- package/fs/types/sorted_set/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/sorted_set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/string/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/string/{test.f.js → proof.f.js} +1 -1
- package/fs/types/string_set/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/string_set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/ts/{test.f.d.ts → proof.f.d.ts} +20 -0
- package/fs/types/ts/{test.f.js → proof.f.js} +1 -0
- package/fs/types/uint8array/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/uint8array/{test.f.js → proof.f.js} +1 -1
- package/issues/demo/sample/{test.f.js → proof.f.js} +1 -1
- package/issues/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/issues/{test.f.js → proof.f.js} +1 -1
- package/nanvm-lib/tests/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/nanvm-lib/tests/{test.f.js → proof.f.js} +1 -1
- package/nanvm-lib/tests/vm/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/nanvm-lib/tests/vm/{test.f.js → proof.f.js} +1 -1
- package/package.json +5 -5
- package/fs/base128/test.f.d.ts +0 -2
- package/fs/cas/test.f.d.ts +0 -2
- package/fs/cas/test.f.js +0 -1
- package/fs/dev/version/test.f.d.ts +0 -4
- package/fs/fsm/test.f.d.ts +0 -5
- package/fs/path/test.f.d.ts +0 -3
- package/fs/text/ascii/test.f.d.ts +0 -4
- package/fs/text/sgr/test.f.d.ts +0 -2
- package/fs/text/sgr/test.f.js +0 -8
- package/fs/types/btree/find/test.f.d.ts +0 -2
- package/fs/types/btree/remove/test.f.d.ts +0 -5
- package/fs/types/btree/set/test.f.d.ts +0 -2
- package/fs/types/function/compare/test.f.d.ts +0 -2
- package/fs/types/function/operator/test.f.d.ts +0 -10
- package/fs/types/function/test.f.d.ts +0 -2
- package/fs/types/map/test.f.d.ts +0 -5
- package/fs/types/nominal/test.f.d.ts +0 -5
- package/fs/types/nullable/test.f.d.ts +0 -2
- package/fs/types/range/test.f.d.ts +0 -2
- package/fs/types/result/test.f.d.ts +0 -2
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
import { log2 } from "../../../types/bigint/module.f.js";
|
|
8
|
-
import {
|
|
8
|
+
import { msb, vec } from "../../../types/bit_vec/module.f.js";
|
|
9
9
|
import { strictEqual } from "../../../types/function/operator/module.f.js";
|
|
10
10
|
import { equal, map } from "../../../types/list/module.f.js";
|
|
11
11
|
import { join } from "../../../types/string/module.f.js";
|
|
@@ -73,12 +73,12 @@ export const pipelineStep = (bit, [l1s, l2s, l3s]) => {
|
|
|
73
73
|
const [l3Out, newL3s] = l3.encode(l2Out, l3s);
|
|
74
74
|
return [l3Out, [newL1s, newL2s, newL3s]];
|
|
75
75
|
};
|
|
76
|
-
const concat = listToVec(msb);
|
|
77
76
|
const vec1 = vec(1n);
|
|
77
|
+
const { listToVec } = msb;
|
|
78
78
|
const literalToVec = (prior, e) => {
|
|
79
79
|
const m = map(prior);
|
|
80
80
|
const { decode } = level(e);
|
|
81
|
-
return literal =>
|
|
81
|
+
return literal => listToVec(m(decode(literal)));
|
|
82
82
|
};
|
|
83
83
|
/** Decodes a level-1 symbol to its canonical MSB bit vector. */
|
|
84
84
|
export const literal1ToVec = literalToVec(vec1, 0n);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
export declare const proof: {
|
|
2
2
|
deterministic: () => void;
|
|
3
3
|
distinct: () => void;
|
|
4
4
|
order_matters: () => void;
|
|
@@ -7,4 +7,3 @@ declare const _default: {
|
|
|
7
7
|
compress_correct: () => void;
|
|
8
8
|
isSymbol_terminal_only: () => void;
|
|
9
9
|
};
|
|
10
|
-
export default _default;
|
|
@@ -2,7 +2,7 @@ import { range } from "./module.f.js";
|
|
|
2
2
|
import { stringify as jsonStringify } from "../../json/module.f.js";
|
|
3
3
|
import { sort } from "../../types/object/module.f.js";
|
|
4
4
|
const stringify = jsonStringify(sort);
|
|
5
|
-
export
|
|
5
|
+
export const proof = {
|
|
6
6
|
range: () => {
|
|
7
7
|
const r = stringify(range("A"));
|
|
8
8
|
if (r !== '[65,65]') {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Unicode code-point contract for the UTF-8 and UTF-16 decoders: the
|
|
3
|
+
* error-tag mask used to flag invalid sequences, and a streaming `decoder`
|
|
4
|
+
* factory that wraps a per-unit step and an end-of-input step into a single
|
|
5
|
+
* `List`-to-`List` conversion.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { type List } from '../../types/list/module.f.ts';
|
|
10
|
+
import type { StateScan } from '../../types/function/operator/module.f.ts';
|
|
11
|
+
/**
|
|
12
|
+
* Error mask used to tag invalid code points or encoding errors. A decoded
|
|
13
|
+
* value with this bit set represents a malformed unit rather than a valid
|
|
14
|
+
* code point.
|
|
15
|
+
*/
|
|
16
|
+
export declare const errorMask = 2147483648;
|
|
17
|
+
/**
|
|
18
|
+
* Builds a streaming decoder from the two direction-specific steps.
|
|
19
|
+
*
|
|
20
|
+
* Decoding starts from the empty (`null`) state. The input is processed unit by
|
|
21
|
+
* unit through `byteOp`, then a trailing end-of-input marker drives `eofOp` to
|
|
22
|
+
* flush any leftover decoding state.
|
|
23
|
+
*
|
|
24
|
+
* @param byteOp - The per-unit decoding step.
|
|
25
|
+
* @param eofOp - The end-of-input step that flushes the remaining state.
|
|
26
|
+
* @returns A function converting a list of code units into a list of code points.
|
|
27
|
+
*/
|
|
28
|
+
export declare const decoder: <Unit, S, Cp>(byteOp: StateScan<Unit, S | null, List<Cp>>, eofOp: (state: S | null) => readonly [List<Cp>, S | null]) => (input: List<Unit>) => List<Cp>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Unicode code-point contract for the UTF-8 and UTF-16 decoders: the
|
|
3
|
+
* error-tag mask used to flag invalid sequences, and a streaming `decoder`
|
|
4
|
+
* factory that wraps a per-unit step and an end-of-input step into a single
|
|
5
|
+
* `List`-to-`List` conversion.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { flat, stateScan } from "../../types/list/module.f.js";
|
|
10
|
+
/**
|
|
11
|
+
* Error mask used to tag invalid code points or encoding errors. A decoded
|
|
12
|
+
* value with this bit set represents a malformed unit rather than a valid
|
|
13
|
+
* code point.
|
|
14
|
+
*/
|
|
15
|
+
export const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000;
|
|
16
|
+
/**
|
|
17
|
+
* Builds a streaming decoder from the two direction-specific steps.
|
|
18
|
+
*
|
|
19
|
+
* Decoding starts from the empty (`null`) state. The input is processed unit by
|
|
20
|
+
* unit through `byteOp`, then a trailing end-of-input marker drives `eofOp` to
|
|
21
|
+
* flush any leftover decoding state.
|
|
22
|
+
*
|
|
23
|
+
* @param byteOp - The per-unit decoding step.
|
|
24
|
+
* @param eofOp - The end-of-input step that flushes the remaining state.
|
|
25
|
+
* @returns A function converting a list of code units into a list of code points.
|
|
26
|
+
*/
|
|
27
|
+
export const decoder = (byteOp, eofOp) => {
|
|
28
|
+
const op = (input, state) => input === null ? eofOp(state) : byteOp(input, state);
|
|
29
|
+
const run = stateScan(op)(null);
|
|
30
|
+
return input => flat(run(flat([input, [null]])));
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const proof: (() => void)[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { fgRed, createConsoleText, backspace } from "./module.f.js";
|
|
2
|
+
export const proof = [
|
|
3
|
+
() => {
|
|
4
|
+
if (fgRed !== '\x1b[31m') {
|
|
5
|
+
throw new Error('Test failed: sgr(0)');
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
() => {
|
|
9
|
+
const output = [];
|
|
10
|
+
const stdout = { write: (s) => { output.push(s); } };
|
|
11
|
+
const writer1 = createConsoleText(stdout);
|
|
12
|
+
const writer2 = writer1('hello');
|
|
13
|
+
if (output[0] !== 'hello') {
|
|
14
|
+
throw output[0];
|
|
15
|
+
}
|
|
16
|
+
// replacing 'hello' (len=5) with 'hi' (len=2): suffixLength=3
|
|
17
|
+
writer2('hi');
|
|
18
|
+
const expected = backspace.repeat(5) + 'hi' + ' '.repeat(3) + backspace.repeat(3);
|
|
19
|
+
if (output[1] !== expected) {
|
|
20
|
+
throw output[1];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
];
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
8
|
-
import { map,
|
|
8
|
+
import { map, reduce, flatMap, empty, } from "../../types/list/module.f.js";
|
|
9
9
|
import { concat } from "../../types/function/operator/module.f.js";
|
|
10
10
|
import { contains } from "../../types/range/module.f.js";
|
|
11
11
|
import { fn } from "../../types/function/module.f.js";
|
|
12
|
+
import { decoder, errorMask } from "../code_point/module.f.js";
|
|
12
13
|
/**
|
|
13
14
|
* Ranges of code points for the lower (Low) and higher (High) parts of the BMP (Basic Multilingual Plane) plane.
|
|
14
15
|
*/
|
|
@@ -29,10 +30,6 @@ const isHighSurrogate = contains([0xd800, 0xdbff]);
|
|
|
29
30
|
* Range: 0xDC00 – 0xDFFF.
|
|
30
31
|
*/
|
|
31
32
|
const isLowSurrogate = contains([0xdc00, 0xdfff]);
|
|
32
|
-
/**
|
|
33
|
-
* Mask of mistakes. Used to indicate invalid code points or coding errors
|
|
34
|
-
*/
|
|
35
|
-
const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000;
|
|
36
33
|
/**
|
|
37
34
|
* Checks whether the code point belongs to the additional (Supplementary) plane of Unicode.
|
|
38
35
|
* Additional planes include code points from 0x010000 to 0x10FFFF.
|
|
@@ -219,53 +216,6 @@ const utf16ByteToCodePointOp = (word, state) => {
|
|
|
219
216
|
* ```
|
|
220
217
|
*/
|
|
221
218
|
const utf16EofToCodePointOp = (state) => [state === null ? empty : [state | errorMask], null];
|
|
222
|
-
/**
|
|
223
|
-
* A stateful scan operation that processes UTF-16 input (word or EOF).
|
|
224
|
-
* This function determines whether to handle a UTF-16 word or an end-of-file (EOF)
|
|
225
|
-
* signal during decoding:
|
|
226
|
-
* 1. If the input is `null` (EOF), it calls `utf16EofToCodePointOp` to process
|
|
227
|
-
* any remaining state.
|
|
228
|
-
* 2. If the input is a valid UTF-16 word, it calls `utf16ByteToCodePointOp` to
|
|
229
|
-
* process the word and update the state accordingly.
|
|
230
|
-
* @param state - The current state in the UTF-16 decoding process:
|
|
231
|
-
* - `null`: No pending surrogate.
|
|
232
|
-
* - A high surrogate waiting for a low surrogate.
|
|
233
|
-
* @param input - The current UTF-16 word to process, or `null` to signal EOF.
|
|
234
|
-
* @returns A tuple:
|
|
235
|
-
* - A list of decoded code points (if any).
|
|
236
|
-
* - The updated decoding state.
|
|
237
|
-
*
|
|
238
|
-
* @example
|
|
239
|
-
*
|
|
240
|
-
* ```ts
|
|
241
|
-
* // Example 1: Process a valid UTF-16 word
|
|
242
|
-
* const input1 = 0x0041 // 'A' (BMP code point)
|
|
243
|
-
* const result1 = utf16ByteOrEofToCodePointOp(input1, null)
|
|
244
|
-
* console.log(result1) // [[0x0041], null]
|
|
245
|
-
* // Example 2: Process a high surrogate, followed by EOF
|
|
246
|
-
* const input2 = 0xD83D // High surrogate
|
|
247
|
-
* const result2 = utf16ByteOrEofToCodePointOp(input2, null)
|
|
248
|
-
* console.log(result2) // [[], 0xD83D] (waiting for a low surrogate)
|
|
249
|
-
* const eofResult = utf16ByteOrEofToCodePointOp(null, 0xD83D)
|
|
250
|
-
* console.log(eofResult) // [[0xD83D | errorMask], null] (unpaired high surrogate)
|
|
251
|
-
* // Example 3: Handle EOF with no pending state
|
|
252
|
-
* const eofResult2 = utf16ByteOrEofToCodePointOp(null, null)
|
|
253
|
-
* ```
|
|
254
|
-
*/
|
|
255
|
-
const utf16ByteOrEofToCodePointOp = (input, state) => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(input, state);
|
|
256
|
-
/**
|
|
257
|
-
* Represents an end-of-file (EOF) indicator in a list of UTF-16 code units.
|
|
258
|
-
*
|
|
259
|
-
* This list contains a single element, `null`, which is used to signal the end
|
|
260
|
-
* of input during UTF-16 decoding operations.
|
|
261
|
-
* @example
|
|
262
|
-
*
|
|
263
|
-
* ```ts
|
|
264
|
-
* const input = [...utf16Data, ...eofList]
|
|
265
|
-
* // Ensures the EOF is handled during processing.
|
|
266
|
-
* ```
|
|
267
|
-
*/
|
|
268
|
-
const eofList = [null];
|
|
269
219
|
/**
|
|
270
220
|
* Converts a list of UTF-16 code units to a list of Unicode code points (CodePoint).
|
|
271
221
|
* This function processes each UTF-16 code unit, decoding them into their corresponding Unicode code points.
|
|
@@ -281,7 +231,7 @@ const eofList = [null];
|
|
|
281
231
|
* const codePoints = toCodePointList(utf16List)
|
|
282
232
|
* ```
|
|
283
233
|
*/
|
|
284
|
-
export const toCodePointList = (
|
|
234
|
+
export const toCodePointList = decoder(utf16ByteToCodePointOp, utf16EofToCodePointOp);
|
|
285
235
|
/**
|
|
286
236
|
* Converts a string to a list of UTF-16 code units (U16).
|
|
287
237
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
export declare const proof: {
|
|
2
2
|
toCodePointList: (() => void)[];
|
|
3
3
|
fromCodePointList: (() => void)[];
|
|
4
4
|
string: (() => void)[];
|
|
@@ -7,4 +7,3 @@ declare const _default: {
|
|
|
7
7
|
stringToCodePointList: (() => void)[];
|
|
8
8
|
codePointListToString: (() => void)[];
|
|
9
9
|
};
|
|
10
|
-
export default _default;
|
|
@@ -3,7 +3,7 @@ import { stringify as jsonStringify } from "../../json/module.f.js";
|
|
|
3
3
|
import { sort } from "../../types/object/module.f.js";
|
|
4
4
|
import { toArray } from "../../types/list/module.f.js";
|
|
5
5
|
const stringify = (a) => jsonStringify(sort)(a);
|
|
6
|
-
export
|
|
6
|
+
export const proof = {
|
|
7
7
|
toCodePointList: [
|
|
8
8
|
() => {
|
|
9
9
|
const result = stringify(toArray(toCodePointList([-1, 65536])));
|
package/fs/text/utf8/module.f.js
CHANGED
|
@@ -3,11 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
* Error mask constant used to represent invalid code points or encoding errors in UTF-8.
|
|
9
|
-
*/
|
|
10
|
-
const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000;
|
|
6
|
+
import { flatMap } from "../../types/list/module.f.js";
|
|
7
|
+
import { decoder, errorMask } from "../code_point/module.f.js";
|
|
11
8
|
/**
|
|
12
9
|
* Converts a Unicode code point to a sequence of UTF-8 bytes.
|
|
13
10
|
* @param input The Unicode code point to be converted. Valid range:
|
|
@@ -175,29 +172,10 @@ const utf8EofToCodePointOp = (state) => [
|
|
|
175
172
|
state === null ? null : [utf8StateToError(state)],
|
|
176
173
|
null,
|
|
177
174
|
];
|
|
178
|
-
/**
|
|
179
|
-
* Combines UTF-8 byte and EOF handling into a single decoding operation.
|
|
180
|
-
*
|
|
181
|
-
* @param state - The current UTF-8 decoding state.
|
|
182
|
-
* @param input - The next byte or EOF indicator.
|
|
183
|
-
* @returns A tuple containing:
|
|
184
|
-
* - A list of decoded Unicode code points or error codes.
|
|
185
|
-
* - The updated UTF-8 state.
|
|
186
|
-
*/
|
|
187
|
-
const utf8ByteOrEofToCodePointOp = (input, state) => input === null ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(input, state);
|
|
188
|
-
/**
|
|
189
|
-
* A constant representing the end-of-file (EOF) marker for UTF-8 decoding.
|
|
190
|
-
*
|
|
191
|
-
* @remarks
|
|
192
|
-
* This is used as a sentinel value in decoding operations to signify the
|
|
193
|
-
* termination of input. The list contains a single `null` value, which
|
|
194
|
-
* represents the EOF condition.
|
|
195
|
-
*/
|
|
196
|
-
const eofList = [null];
|
|
197
175
|
/**
|
|
198
176
|
* Converts a list of UTF-8 bytes into a list of Unicode code points.
|
|
199
177
|
*
|
|
200
178
|
* @param input - A list of UTF-8 bytes.
|
|
201
179
|
* @returns A list of Unicode code points or error codes.
|
|
202
180
|
*/
|
|
203
|
-
export const toCodePointList = (
|
|
181
|
+
export const toCodePointList = decoder(utf8ByteToCodePointOp, utf8EofToCodePointOp);
|
|
@@ -3,7 +3,7 @@ import { stringify as jsonStringify } from "../../json/module.f.js";
|
|
|
3
3
|
import { sort } from "../../types/object/module.f.js";
|
|
4
4
|
import { toArray } from "../../types/list/module.f.js";
|
|
5
5
|
const stringify = jsonStringify(sort);
|
|
6
|
-
export
|
|
6
|
+
export const proof = {
|
|
7
7
|
toCodePoint: [
|
|
8
8
|
() => {
|
|
9
9
|
const result = stringify(toArray(toCodePointList([-1, 256])));
|
|
@@ -2,7 +2,7 @@ import { at, first, last, head, tail, splitFirst, splitLast, empty } from "./mod
|
|
|
2
2
|
import { stringify as jsonStringify } from "../../json/module.f.js";
|
|
3
3
|
import { sort } from "../object/module.f.js";
|
|
4
4
|
const stringify = jsonStringify(sort);
|
|
5
|
-
export
|
|
5
|
+
export const proof = {
|
|
6
6
|
stringify: () => {
|
|
7
7
|
const result = stringify([1, 20, 300]);
|
|
8
8
|
if (result !== '[1,20,300]') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const clz32Log2: (v: bigint) => bigint;
|
|
2
|
-
declare const
|
|
2
|
+
export declare const proof: {
|
|
3
3
|
example: () => void;
|
|
4
4
|
benchmark: () => {
|
|
5
5
|
big: {
|
|
@@ -30,4 +30,3 @@ declare const _default: {
|
|
|
30
30
|
divUp: () => void;
|
|
31
31
|
roundUp: () => void;
|
|
32
32
|
};
|
|
33
|
-
export default _default;
|
|
@@ -146,6 +146,15 @@ export type BitOrder = {
|
|
|
146
146
|
* ```
|
|
147
147
|
*/
|
|
148
148
|
readonly concat: Reduce;
|
|
149
|
+
/**
|
|
150
|
+
* Folds a list of vectors into a single vector in this bit order.
|
|
151
|
+
*
|
|
152
|
+
* Unlike `concat`, which joins exactly two vectors, this joins a whole list.
|
|
153
|
+
*
|
|
154
|
+
* @returns The concatenation of every vector in the list, or `empty` when the
|
|
155
|
+
* list is empty.
|
|
156
|
+
*/
|
|
157
|
+
readonly listToVec: (list: List<Vec>) => Vec;
|
|
149
158
|
/**
|
|
150
159
|
* Computes the bitwise exclusive OR of two vectors after normalizing their lengths.
|
|
151
160
|
*
|
|
@@ -219,10 +228,6 @@ export declare const chunkList: (bo: BitOrder) => (n: bigint) => (v: Vec) => Thu
|
|
|
219
228
|
* @returns A thunk that produces a list of unsigned 8-bit integers.
|
|
220
229
|
*/
|
|
221
230
|
export declare const u8List: (bo: BitOrder) => (v: Vec) => Thunk<number>;
|
|
222
|
-
/**
|
|
223
|
-
* Concatenates a list of vectors using the provided bit order.
|
|
224
|
-
*/
|
|
225
|
-
export declare const listToVec: ({ concat }: BitOrder) => (list: List<Vec>) => Vec;
|
|
226
231
|
/**
|
|
227
232
|
* Repeats a vector to create a padded block of the desired length.
|
|
228
233
|
*/
|
|
@@ -127,14 +127,16 @@ const bo = ({ front, removeFront, norm, uintCmp, unpackSplit, unpackConcatUint }
|
|
|
127
127
|
return [uint, pack(u)];
|
|
128
128
|
};
|
|
129
129
|
};
|
|
130
|
+
const concat = a => b => {
|
|
131
|
+
const au = unpack(a);
|
|
132
|
+
const bu = unpack(b);
|
|
133
|
+
return pack(unpackConcat(au)(bu));
|
|
134
|
+
};
|
|
130
135
|
return {
|
|
131
136
|
front,
|
|
132
137
|
removeFront,
|
|
133
|
-
concat
|
|
134
|
-
|
|
135
|
-
const bu = unpack(b);
|
|
136
|
-
return pack(unpackConcat(au)(bu));
|
|
137
|
-
},
|
|
138
|
+
concat,
|
|
139
|
+
listToVec: fold(flip(concat))(empty),
|
|
138
140
|
xor: op(norm)(xor),
|
|
139
141
|
unpackPopFront,
|
|
140
142
|
popFront,
|
|
@@ -301,10 +303,6 @@ const vecToU8 = ({ unpackSplit }) => {
|
|
|
301
303
|
* @returns A thunk that produces a list of unsigned 8-bit integers.
|
|
302
304
|
*/
|
|
303
305
|
export const u8List = (bo) => (v) => map(vecToU8(bo))(chunkList(bo)(8n)(v));
|
|
304
|
-
/**
|
|
305
|
-
* Concatenates a list of vectors using the provided bit order.
|
|
306
|
-
*/
|
|
307
|
-
export const listToVec = ({ concat }) => fold(flip(concat))(empty);
|
|
308
306
|
/**
|
|
309
307
|
* Repeats a vector to create a padded block of the desired length.
|
|
310
308
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const proof: () => void;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import type
|
|
6
|
+
import { type TNode, type Tree } from '../types/module.f.ts';
|
|
7
7
|
import type { Compare } from '../../function/compare/module.f.ts';
|
|
8
8
|
export declare const nodeRemove: <T>(c: Compare<T>) => (node: TNode<T>) => Tree<T>;
|
|
9
9
|
export declare const remove: <T>(c: Compare<T>) => (tree: Tree<T>) => Tree<T>;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removal operations for persistent B-tree structures.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { collapseRoot } from "../types/module.f.js";
|
|
1
7
|
import { find } from "../find/module.f.js";
|
|
2
8
|
import { fold, concat, next } from "../../list/module.f.js";
|
|
3
9
|
import { map } from "../../nullable/module.f.js";
|
|
@@ -163,7 +169,6 @@ export const nodeRemove = (c) => (node) => {
|
|
|
163
169
|
return first;
|
|
164
170
|
}
|
|
165
171
|
const { first: tf, tail: tt } = tailR;
|
|
166
|
-
|
|
167
|
-
return result.length === 1 ? result[0] : result;
|
|
172
|
+
return collapseRoot(reduce(initReduce(tf)(first))(tt));
|
|
168
173
|
};
|
|
169
174
|
export const remove = c => map(nodeRemove(c));
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import type
|
|
6
|
+
import { type TNode, type Tree } from '../types/module.f.ts';
|
|
7
7
|
import type { Compare } from '../../function/compare/module.f.ts';
|
|
8
8
|
export declare const set: <T>(c: Compare<T>) => (f: (value: T | null) => T) => (tree: Tree<T>) => TNode<T>;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Insertion and update operations for persistent B-tree structures.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { collapseRoot } from "../types/module.f.js";
|
|
1
7
|
import { find } from "../find/module.f.js";
|
|
2
8
|
import { fold } from "../../list/module.f.js";
|
|
3
9
|
const b57 = b => b.length === 5 ? [b] : [[b[0], b[1], b[2]], b[3], [b[4], b[5], b[6]]];
|
|
@@ -114,7 +120,6 @@ const nodeSet = (c) => (g) => (node) => {
|
|
|
114
120
|
}
|
|
115
121
|
}
|
|
116
122
|
};
|
|
117
|
-
|
|
118
|
-
return r.length === 1 ? r[0] : r;
|
|
123
|
+
return collapseRoot(reduceBranch(f())(tail));
|
|
119
124
|
};
|
|
120
125
|
export const set = c => f => tree => tree === null ? [f(null)] : nodeSet(c)(f)(tree);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const proof: (() => void)[];
|
|
@@ -12,3 +12,12 @@ export type TNode<T> = Leaf1<T> | Leaf2<T> | Branch3<T> | Branch5<T>;
|
|
|
12
12
|
export type Tree<T> = TNode<T> | null;
|
|
13
13
|
export type Branch1<T> = readonly [TNode<T>];
|
|
14
14
|
export type Branch7<T> = readonly [...Branch5<T>, T, TNode<T>];
|
|
15
|
+
/**
|
|
16
|
+
* Demotes a single-child branch root to its only child.
|
|
17
|
+
*
|
|
18
|
+
* After an insert or remove the root may temporarily hold exactly one child
|
|
19
|
+
* (a `Branch1`). In that case the tree is one level taller than necessary;
|
|
20
|
+
* returning the child directly restores the correct height. If the root has
|
|
21
|
+
* more than one child it is returned unchanged.
|
|
22
|
+
*/
|
|
23
|
+
export declare const collapseRoot: <T>(b: Branch1<T> | Branch3<T> | Branch5<T>) => TNode<T>;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Demotes a single-child branch root to its only child.
|
|
3
|
+
*
|
|
4
|
+
* After an insert or remove the root may temporarily hold exactly one child
|
|
5
|
+
* (a `Branch1`). In that case the tree is one level taller than necessary;
|
|
6
|
+
* returning the child directly restores the correct height. If the root has
|
|
7
|
+
* more than one child it is returned unchanged.
|
|
8
|
+
*/
|
|
9
|
+
export const collapseRoot = b => b.length === 1 ? b[0] : b;
|