functionalscript 0.19.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/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/asn.1/{test.f.js → proof.f.js} +1 -1
- 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/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/{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.f.d.ts +63 -5
- package/fs/dev/tf/module.f.js +77 -20
- package/fs/dev/tf/{test.f.d.ts → proof.f.d.ts} +26 -0
- package/fs/dev/tf/{test.f.js → proof.f.js} +76 -34
- 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/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/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 +3 -2
- package/fs/io/module.f.js +4 -3
- package/fs/io/module.js +19 -11
- 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/{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/{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/{test.f.js → proof.f.js} +1 -1
- 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/{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/proof.f.d.ts +4 -0
- package/fs/types/btree/remove/{test.f.js → proof.f.js} +1 -1
- 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 +8 -0
- package/fs/types/btree/types/module.f.js +8 -0
- 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 +54 -5
- package/fs/types/effects/node/module.f.js +4 -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.js +1 -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} +1 -1
- 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 +2 -2
- package/fs/base128/test.f.d.ts +0 -2
- package/fs/bnf/test.f.d.ts +0 -4
- 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/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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { concat, normalize, relativize } from "./module.f.js";
|
|
2
|
-
|
|
2
|
+
const normalizeTest = [
|
|
3
3
|
() => {
|
|
4
4
|
const norm = normalize("dir/file.json");
|
|
5
5
|
if (norm !== "dir/file.json") {
|
|
@@ -25,7 +25,7 @@ export const normalizeTest = [
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
];
|
|
28
|
-
|
|
28
|
+
const concatTest = [
|
|
29
29
|
() => {
|
|
30
30
|
const c = concat("a")("b");
|
|
31
31
|
if (c !== "a/b") {
|
|
@@ -45,7 +45,7 @@ export const concatTest = [
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
];
|
|
48
|
-
|
|
48
|
+
const relativizeTest = [
|
|
49
49
|
() => {
|
|
50
50
|
const r = relativize('/repo', '/repo/fs/a.ts');
|
|
51
51
|
if (r !== './fs/a.ts') {
|
|
@@ -65,3 +65,4 @@ export const relativizeTest = [
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
];
|
|
68
|
+
export const proof = { normalizeTest, concatTest, relativizeTest };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
export declare const proof: {
|
|
2
2
|
inline_00_00: () => void;
|
|
3
3
|
inline_00_01: () => void;
|
|
4
4
|
inline_01_00: () => void;
|
|
@@ -18,4 +18,3 @@ declare const _default: {
|
|
|
18
18
|
hash_merge_b_sensitivity: () => void;
|
|
19
19
|
hash_merge_shift: () => void;
|
|
20
20
|
};
|
|
21
|
-
export default _default;
|
|
@@ -15,7 +15,7 @@ const hFE = hashId(mask(0xffn) - 1n);
|
|
|
15
15
|
assertEq(asBase(level3Id(0n)), 0n);
|
|
16
16
|
assertEq(asBase(hashId(0n)), 1n << 0xffn);
|
|
17
17
|
assertEq(asBase(hFF), mask(0x100n));
|
|
18
|
-
export
|
|
18
|
+
export const proof = {
|
|
19
19
|
// Two level-3 literals whose combined bit vectors fit inline (≤ 253 bits)
|
|
20
20
|
inline_00_00: () => assertEq(compress(level3Id(0x00n), level3Id(0x00n)), rawId(vec(16n)(0x0000n))),
|
|
21
21
|
inline_00_01: () => assertEq(compress(level3Id(0x00n), level3Id(0x01n)), rawId(vec(16n)(0x0001n))),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
export declare const proof: {
|
|
2
2
|
min_equal: () => void;
|
|
3
3
|
min_greater: () => void;
|
|
4
4
|
intermediate_undefined: () => void;
|
|
@@ -11,4 +11,3 @@ declare const _default: {
|
|
|
11
11
|
isSymbol_terminal_only: () => void;
|
|
12
12
|
isSymbol_min_word: () => void;
|
|
13
13
|
};
|
|
14
|
-
export default _default;
|
|
@@ -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)[];
|
|
@@ -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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const proof: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const proof: (() => void)[];
|
|
@@ -12,4 +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
|
+
*/
|
|
15
23
|
export declare const collapseRoot: <T>(b: Branch1<T> | Branch3<T> | Branch5<T>) => TNode<T>;
|
|
@@ -1 +1,9 @@
|
|
|
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
|
+
*/
|
|
1
9
|
export const collapseRoot = b => b.length === 1 ? b[0] : b;
|
|
@@ -3,7 +3,7 @@ import { every, countdown, map, toArray } from "../list/module.f.js";
|
|
|
3
3
|
import { stringify as jsonStringify } from "../../json/module.f.js";
|
|
4
4
|
import { sort } from "../object/module.f.js";
|
|
5
5
|
const stringify = jsonStringify(sort);
|
|
6
|
-
export
|
|
6
|
+
export const proof = {
|
|
7
7
|
has: [
|
|
8
8
|
() => {
|
|
9
9
|
if (has(0)(empty)) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
+
import { type List } from '../list/module.f.ts';
|
|
6
7
|
export type Operation = readonly [string, (..._: readonly never[]) => unknown];
|
|
7
8
|
export type Effect<O extends Operation, T> = {
|
|
8
9
|
value: Value<O, T>;
|
|
@@ -20,6 +21,22 @@ export type Param<O extends Operation> = F<O>[0];
|
|
|
20
21
|
export type Return<O extends Operation> = F<O>[1];
|
|
21
22
|
export declare const do_: <O extends Operation>(cmd: O[0]) => (...param: Param<O>) => Effect<O, Return<O>>;
|
|
22
23
|
export declare const begin: Effect<never, void>;
|
|
24
|
+
/**
|
|
25
|
+
* Sequentially threads a state value through an effect for each item in `items`.
|
|
26
|
+
*
|
|
27
|
+
* Given `f: item => state => Effect<O, state>`, `init: S`, and `items: [x₀, x₁, …]`,
|
|
28
|
+
* builds `f(x₀)(init).step(f(x₁)).step(f(x₂)).…` and yields a single
|
|
29
|
+
* `Effect<O, S>` that produces the final state.
|
|
30
|
+
*
|
|
31
|
+
* Sequential — each step depends on the previous state. Compare to `all`,
|
|
32
|
+
* which fans out independent effects.
|
|
33
|
+
*/
|
|
34
|
+
export declare const foldStep: <O extends Operation, T, S>(f: (item: T) => (state: S) => Effect<O, S>) => (init: S) => (items: List<T>) => Effect<O, S>;
|
|
35
|
+
/**
|
|
36
|
+
* Sequentially runs `f(item)` for each item in `items`, discarding intermediate
|
|
37
|
+
* results. The `void` accumulator sibling of `foldStep`.
|
|
38
|
+
*/
|
|
39
|
+
export declare const forEachStep: <O extends Operation, T>(f: (item: T) => Effect<O, void>) => (items: List<T>) => Effect<O, void>;
|
|
23
40
|
export type ToAsyncOperationMap<O extends Operation> = {
|
|
24
41
|
readonly [K in O[0]]: (...payload: Pr<O, K>[0]) => Promise<Pr<O, K>[1]>;
|
|
25
42
|
};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
+
import { fold } from "../list/module.f.js";
|
|
6
7
|
export const pure = (v) => ({
|
|
7
8
|
value: [v],
|
|
8
9
|
step: f => f(v)
|
|
@@ -13,3 +14,19 @@ export const doFull = (cmd, param, cont) => ({
|
|
|
13
14
|
});
|
|
14
15
|
export const do_ = (cmd) => (...param) => doFull(cmd, param, pure);
|
|
15
16
|
export const begin = pure(undefined);
|
|
17
|
+
/**
|
|
18
|
+
* Sequentially threads a state value through an effect for each item in `items`.
|
|
19
|
+
*
|
|
20
|
+
* Given `f: item => state => Effect<O, state>`, `init: S`, and `items: [x₀, x₁, …]`,
|
|
21
|
+
* builds `f(x₀)(init).step(f(x₁)).step(f(x₂)).…` and yields a single
|
|
22
|
+
* `Effect<O, S>` that produces the final state.
|
|
23
|
+
*
|
|
24
|
+
* Sequential — each step depends on the previous state. Compare to `all`,
|
|
25
|
+
* which fans out independent effects.
|
|
26
|
+
*/
|
|
27
|
+
export const foldStep = (f) => (init) => (items) => fold(item => acc => acc.step(f(item)))(pure(init))(items);
|
|
28
|
+
/**
|
|
29
|
+
* Sequentially runs `f(item)` for each item in `items`, discarding intermediate
|
|
30
|
+
* results. The `void` accumulator sibling of `foldStep`.
|
|
31
|
+
*/
|
|
32
|
+
export const forEachStep = (f) => (items) => foldStep((item) => () => f(item))(undefined)(items);
|