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.
Files changed (219) hide show
  1. package/fs/asn.1/{test.f.d.ts → proof.f.d.ts} +1 -2
  2. package/fs/asn.1/{test.f.js → proof.f.js} +1 -1
  3. package/fs/base128/proof.f.d.ts +1 -0
  4. package/fs/base128/{test.f.js → proof.f.js} +1 -1
  5. package/fs/bnf/data/{test.f.d.ts → proof.f.d.ts} +1 -2
  6. package/fs/bnf/data/{test.f.js → proof.f.js} +1 -1
  7. package/fs/bnf/proof.f.d.ts +3 -0
  8. package/fs/bnf/{test.f.js → proof.f.js} +1 -1
  9. package/fs/cas/module.f.js +2 -12
  10. package/fs/cas/proof.f.d.ts +1 -0
  11. package/fs/cas/proof.f.js +1 -0
  12. package/fs/cbase32/{test.f.d.ts → proof.f.d.ts} +1 -2
  13. package/fs/cbase32/{test.f.js → proof.f.js} +1 -1
  14. package/fs/ci/node/module.f.js +12 -7
  15. package/fs/ci/{test.f.d.ts → proof.f.d.ts} +1 -2
  16. package/fs/ci/{test.f.js → proof.f.js} +1 -1
  17. package/fs/crypto/hmac/{test.f.d.ts → proof.f.d.ts} +1 -2
  18. package/fs/crypto/hmac/{test.f.js → proof.f.js} +1 -1
  19. package/fs/crypto/secp/{test.f.d.ts → proof.f.d.ts} +1 -2
  20. package/fs/crypto/secp/{test.f.js → proof.f.js} +1 -1
  21. package/fs/crypto/sha2/{test.f.d.ts → proof.f.d.ts} +1 -2
  22. package/fs/crypto/sha2/{test.f.js → proof.f.js} +1 -1
  23. package/fs/crypto/sign/{test.f.d.ts → proof.f.d.ts} +1 -2
  24. package/fs/crypto/sign/{test.f.js → proof.f.js} +1 -1
  25. package/fs/dev/module.f.d.ts +28 -2
  26. package/fs/dev/module.f.js +38 -22
  27. package/fs/dev/{test.f.d.ts → proof.f.d.ts} +5 -2
  28. package/fs/dev/{test.f.js → proof.f.js} +25 -2
  29. package/fs/dev/tf/module.f.d.ts +63 -5
  30. package/fs/dev/tf/module.f.js +77 -20
  31. package/fs/dev/tf/{test.f.d.ts → proof.f.d.ts} +26 -0
  32. package/fs/dev/tf/{test.f.js → proof.f.js} +76 -34
  33. package/fs/dev/tf/scenarios/async-subtests.fail.d.ts +4 -0
  34. package/fs/dev/tf/scenarios/async-subtests.fail.js +7 -0
  35. package/fs/dev/tf/scenarios/async-subtests.pass.d.ts +4 -0
  36. package/fs/dev/tf/scenarios/async-subtests.pass.js +7 -0
  37. package/fs/dev/tf/scenarios/async.fail.d.ts +1 -0
  38. package/fs/dev/tf/scenarios/async.fail.js +4 -0
  39. package/fs/dev/tf/scenarios/async.pass.d.ts +1 -0
  40. package/fs/dev/tf/scenarios/async.pass.js +3 -0
  41. package/fs/dev/tf/scenarios/thenable.pass.d.ts +3 -0
  42. package/fs/dev/tf/scenarios/thenable.pass.js +9 -0
  43. package/fs/dev/tf/scenarios/thenable2.pass.f.d.ts +3 -0
  44. package/fs/dev/tf/scenarios/thenable2.pass.f.js +3 -0
  45. package/fs/dev/version/proof.f.d.ts +3 -0
  46. package/fs/dev/version/{test.f.js → proof.f.js} +1 -1
  47. package/fs/djs/ast/{test.f.d.ts → proof.f.d.ts} +1 -2
  48. package/fs/djs/ast/{test.f.js → proof.f.js} +1 -1
  49. package/fs/djs/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
  50. package/fs/djs/parser/{test.f.js → proof.f.js} +1 -1
  51. package/fs/djs/{test.f.d.ts → proof.f.d.ts} +1 -2
  52. package/fs/djs/{test.f.js → proof.f.js} +1 -1
  53. package/fs/djs/serializer/module.f.d.ts +2 -2
  54. package/fs/djs/serializer/module.f.js +47 -79
  55. package/fs/djs/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
  56. package/fs/djs/serializer/{test.f.js → proof.f.js} +8 -8
  57. package/fs/djs/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
  58. package/fs/djs/tokenizer/{test.f.js → proof.f.js} +1 -1
  59. package/fs/djs/tokenizer-new/{test.f.d.ts → proof.f.d.ts} +1 -2
  60. package/fs/djs/tokenizer-new/{test.f.js → proof.f.js} +1 -1
  61. package/fs/djs/transpiler/module.f.d.ts +15 -0
  62. package/fs/djs/transpiler/module.f.js +10 -2
  63. package/fs/djs/transpiler/{test.f.d.ts → proof.f.d.ts} +1 -2
  64. package/fs/djs/transpiler/{test.f.js → proof.f.js} +1 -1
  65. package/fs/fsc/{test.f.d.ts → proof.f.d.ts} +1 -2
  66. package/fs/fsc/{test.f.js → proof.f.js} +1 -1
  67. package/fs/fsm/proof.f.d.ts +4 -0
  68. package/fs/fsm/{test.f.js → proof.f.js} +1 -1
  69. package/fs/html/{test.f.d.ts → proof.f.d.ts} +1 -2
  70. package/fs/html/{test.f.js → proof.f.js} +1 -1
  71. package/fs/io/module.d.ts +1 -1
  72. package/fs/io/module.f.d.ts +3 -2
  73. package/fs/io/module.f.js +4 -3
  74. package/fs/io/module.js +19 -11
  75. package/fs/js/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
  76. package/fs/js/tokenizer/{test.f.js → proof.f.js} +1 -1
  77. package/fs/json/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
  78. package/fs/json/parser/{test.f.js → proof.f.js} +1 -1
  79. package/fs/json/{test.f.d.ts → proof.f.d.ts} +1 -2
  80. package/fs/json/{test.f.js → proof.f.js} +1 -1
  81. package/fs/json/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
  82. package/fs/json/serializer/{test.f.js → proof.f.js} +1 -1
  83. package/fs/json/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
  84. package/fs/json/tokenizer/{test.f.js → proof.f.js} +1 -1
  85. package/fs/path/proof.f.d.ts +5 -0
  86. package/fs/path/{test.f.js → proof.f.js} +4 -3
  87. package/fs/sul/id/{test.f.d.ts → proof.f.d.ts} +1 -2
  88. package/fs/sul/id/{test.f.js → proof.f.js} +1 -1
  89. package/fs/sul/level/hash/{test.f.d.ts → proof.f.d.ts} +1 -2
  90. package/fs/sul/level/hash/{test.f.js → proof.f.js} +1 -1
  91. package/fs/sul/level/literal/{test.f.d.ts → proof.f.d.ts} +1 -2
  92. package/fs/sul/level/literal/{test.f.js → proof.f.js} +1 -1
  93. package/fs/sul/{test.f.d.ts → proof.f.d.ts} +1 -2
  94. package/fs/sul/{test.f.js → proof.f.js} +1 -1
  95. package/fs/text/ascii/proof.f.d.ts +3 -0
  96. package/fs/text/ascii/{test.f.js → proof.f.js} +1 -1
  97. package/fs/text/code_point/module.f.d.ts +28 -0
  98. package/fs/text/code_point/module.f.js +31 -0
  99. package/fs/text/{test.f.d.ts → proof.f.d.ts} +1 -2
  100. package/fs/text/{test.f.js → proof.f.js} +1 -1
  101. package/fs/text/sgr/proof.f.d.ts +1 -0
  102. package/fs/text/sgr/{test.f.js → proof.f.js} +1 -1
  103. package/fs/text/utf16/module.f.js +3 -53
  104. package/fs/text/utf16/{test.f.d.ts → proof.f.d.ts} +1 -2
  105. package/fs/text/utf16/{test.f.js → proof.f.js} +1 -1
  106. package/fs/text/utf8/module.f.js +3 -25
  107. package/fs/text/utf8/{test.f.d.ts → proof.f.d.ts} +1 -2
  108. package/fs/text/utf8/{test.f.js → proof.f.js} +1 -1
  109. package/fs/types/array/{test.f.d.ts → proof.f.d.ts} +1 -2
  110. package/fs/types/array/{test.f.js → proof.f.js} +1 -1
  111. package/fs/types/bigfloat/{test.f.d.ts → proof.f.d.ts} +1 -2
  112. package/fs/types/bigfloat/{test.f.js → proof.f.js} +1 -1
  113. package/fs/types/bigint/{test.f.d.ts → proof.f.d.ts} +1 -2
  114. package/fs/types/bigint/{test.f.js → proof.f.js} +1 -1
  115. package/fs/types/bit_vec/{test.f.d.ts → proof.f.d.ts} +1 -2
  116. package/fs/types/bit_vec/{test.f.js → proof.f.js} +1 -1
  117. package/fs/types/btree/find/proof.f.d.ts +1 -0
  118. package/fs/types/btree/find/{test.f.js → proof.f.js} +1 -1
  119. package/fs/types/btree/{test.f.d.ts → proof.f.d.ts} +1 -2
  120. package/fs/types/btree/{test.f.js → proof.f.js} +1 -1
  121. package/fs/types/btree/remove/proof.f.d.ts +4 -0
  122. package/fs/types/btree/remove/{test.f.js → proof.f.js} +1 -1
  123. package/fs/types/btree/set/proof.f.d.ts +1 -0
  124. package/fs/types/btree/set/{test.f.js → proof.f.js} +1 -1
  125. package/fs/types/btree/types/module.f.d.ts +8 -0
  126. package/fs/types/btree/types/module.f.js +8 -0
  127. package/fs/types/byte_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  128. package/fs/types/byte_set/{test.f.js → proof.f.js} +1 -1
  129. package/fs/types/effects/module.f.d.ts +17 -0
  130. package/fs/types/effects/module.f.js +17 -0
  131. package/fs/types/effects/node/module.f.d.ts +54 -5
  132. package/fs/types/effects/node/module.f.js +4 -1
  133. package/fs/types/effects/node/{test.f.d.ts → proof.f.d.ts} +1 -2
  134. package/fs/types/effects/node/{test.f.js → proof.f.js} +1 -1
  135. package/fs/types/effects/node/virtual/module.f.js +1 -0
  136. package/fs/types/effects/proof.f.d.ts +11 -0
  137. package/fs/types/effects/proof.f.js +57 -0
  138. package/fs/types/function/compare/proof.f.d.ts +1 -0
  139. package/fs/types/function/compare/{test.f.js → proof.f.js} +1 -1
  140. package/fs/types/function/operator/proof.f.d.ts +12 -0
  141. package/fs/types/function/operator/{test.f.js → proof.f.js} +11 -10
  142. package/fs/types/function/proof.f.d.ts +1 -0
  143. package/fs/types/function/{test.f.js → proof.f.js} +1 -1
  144. package/fs/types/list/{test.f.d.ts → proof.f.d.ts} +1 -2
  145. package/fs/types/list/{test.f.js → proof.f.js} +1 -1
  146. package/fs/types/map/proof.f.d.ts +4 -0
  147. package/fs/types/map/{test.f.js → proof.f.js} +1 -1
  148. package/fs/types/monoid/{test.f.d.ts → proof.f.d.ts} +1 -2
  149. package/fs/types/monoid/{test.f.js → proof.f.js} +1 -1
  150. package/fs/types/nibble_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  151. package/fs/types/nibble_set/{test.f.js → proof.f.js} +1 -1
  152. package/fs/types/nominal/proof.f.d.ts +4 -0
  153. package/fs/types/nominal/{test.f.js → proof.f.js} +1 -1
  154. package/fs/types/nullable/proof.f.d.ts +1 -0
  155. package/fs/types/nullable/{test.f.js → proof.f.js} +1 -1
  156. package/fs/types/number/{test.f.d.ts → proof.f.d.ts} +1 -2
  157. package/fs/types/number/{test.f.js → proof.f.js} +1 -1
  158. package/fs/types/object/{test.f.d.ts → proof.f.d.ts} +1 -2
  159. package/fs/types/object/{test.f.js → proof.f.js} +1 -1
  160. package/fs/types/ordered_map/{test.f.d.ts → proof.f.d.ts} +1 -2
  161. package/fs/types/ordered_map/{test.f.js → proof.f.js} +1 -1
  162. package/fs/types/patricia_trie/{test.f.d.ts → proof.f.d.ts} +1 -2
  163. package/fs/types/patricia_trie/{test.f.js → proof.f.js} +1 -1
  164. package/fs/types/prime_field/{test.f.d.ts → proof.f.d.ts} +1 -2
  165. package/fs/types/prime_field/{test.f.js → proof.f.js} +1 -1
  166. package/fs/types/range/proof.f.d.ts +1 -0
  167. package/fs/types/range/{test.f.js → proof.f.js} +1 -1
  168. package/fs/types/range_map/{test.f.d.ts → proof.f.d.ts} +1 -2
  169. package/fs/types/range_map/{test.f.js → proof.f.js} +1 -1
  170. package/fs/types/result/proof.f.d.ts +5 -0
  171. package/fs/types/result/{test.f.js → proof.f.js} +18 -2
  172. package/fs/types/rtti/parse/{test.f.d.ts → proof.f.d.ts} +1 -2
  173. package/fs/types/rtti/parse/{test.f.js → proof.f.js} +1 -1
  174. package/fs/types/rtti/{test.f.d.ts → proof.f.d.ts} +1 -2
  175. package/fs/types/rtti/{test.f.js → proof.f.js} +1 -1
  176. package/fs/types/rtti/ts/{test.f.d.ts → proof.f.d.ts} +1 -2
  177. package/fs/types/rtti/ts/{test.f.js → proof.f.js} +1 -1
  178. package/fs/types/rtti/validate/{test.f.d.ts → proof.f.d.ts} +1 -2
  179. package/fs/types/rtti/validate/{test.f.js → proof.f.js} +1 -1
  180. package/fs/types/sorted_list/{test.f.d.ts → proof.f.d.ts} +1 -2
  181. package/fs/types/sorted_list/{test.f.js → proof.f.js} +1 -1
  182. package/fs/types/sorted_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  183. package/fs/types/sorted_set/{test.f.js → proof.f.js} +1 -1
  184. package/fs/types/string/{test.f.d.ts → proof.f.d.ts} +1 -2
  185. package/fs/types/string/{test.f.js → proof.f.js} +1 -1
  186. package/fs/types/string_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  187. package/fs/types/string_set/{test.f.js → proof.f.js} +1 -1
  188. package/fs/types/ts/{test.f.d.ts → proof.f.d.ts} +20 -0
  189. package/fs/types/ts/{test.f.js → proof.f.js} +1 -0
  190. package/fs/types/uint8array/{test.f.d.ts → proof.f.d.ts} +1 -2
  191. package/fs/types/uint8array/{test.f.js → proof.f.js} +1 -1
  192. package/issues/demo/sample/{test.f.js → proof.f.js} +1 -1
  193. package/issues/{test.f.d.ts → proof.f.d.ts} +1 -2
  194. package/issues/{test.f.js → proof.f.js} +1 -1
  195. package/nanvm-lib/tests/{test.f.d.ts → proof.f.d.ts} +1 -2
  196. package/nanvm-lib/tests/{test.f.js → proof.f.js} +1 -1
  197. package/nanvm-lib/tests/vm/{test.f.d.ts → proof.f.d.ts} +1 -2
  198. package/nanvm-lib/tests/vm/{test.f.js → proof.f.js} +1 -1
  199. package/package.json +2 -2
  200. package/fs/base128/test.f.d.ts +0 -2
  201. package/fs/bnf/test.f.d.ts +0 -4
  202. package/fs/cas/test.f.d.ts +0 -2
  203. package/fs/cas/test.f.js +0 -1
  204. package/fs/dev/version/test.f.d.ts +0 -4
  205. package/fs/fsm/test.f.d.ts +0 -5
  206. package/fs/path/test.f.d.ts +0 -3
  207. package/fs/text/ascii/test.f.d.ts +0 -4
  208. package/fs/text/sgr/test.f.d.ts +0 -2
  209. package/fs/types/btree/find/test.f.d.ts +0 -2
  210. package/fs/types/btree/remove/test.f.d.ts +0 -5
  211. package/fs/types/btree/set/test.f.d.ts +0 -2
  212. package/fs/types/function/compare/test.f.d.ts +0 -2
  213. package/fs/types/function/operator/test.f.d.ts +0 -10
  214. package/fs/types/function/test.f.d.ts +0 -2
  215. package/fs/types/map/test.f.d.ts +0 -5
  216. package/fs/types/nominal/test.f.d.ts +0 -5
  217. package/fs/types/nullable/test.f.d.ts +0 -2
  218. package/fs/types/range/test.f.d.ts +0 -2
  219. package/fs/types/result/test.f.d.ts +0 -2
@@ -0,0 +1,5 @@
1
+ export declare const proof: {
2
+ normalizeTest: (() => void)[];
3
+ concatTest: (() => void)[];
4
+ relativizeTest: (() => void)[];
5
+ };
@@ -1,5 +1,5 @@
1
1
  import { concat, normalize, relativize } from "./module.f.js";
2
- export const normalizeTest = [
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
- export const concatTest = [
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
- export const relativizeTest = [
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 _default: {
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 default {
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 _default: {
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;
@@ -24,7 +24,7 @@ const verifyStorage = (storage) => {
24
24
  };
25
25
  const s0 = level3Id(0n);
26
26
  const s1 = level3Id(1n);
27
- export default {
27
+ export const proof = {
28
28
  // Minimum word [s0, t] with t == s0
29
29
  min_equal: () => {
30
30
  const [out, storage] = runWord([s0, s0]);
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  x2: () => void;
3
3
  x5: () => void;
4
4
  x81: () => void;
@@ -9,4 +9,3 @@ declare const _default: {
9
9
  };
10
10
  pipeline: () => void;
11
11
  };
12
- export default _default;
@@ -46,7 +46,7 @@ const w = (symbol, expected) => {
46
46
  if (out !== symbol)
47
47
  throw out;
48
48
  };
49
- export default {
49
+ export const proof = {
50
50
  x2: () => {
51
51
  const { c, n } = tests(0n);
52
52
  c(-1n, 0n);
@@ -1,4 +1,4 @@
1
- declare const _default: {
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;
@@ -13,7 +13,7 @@ const run = (bits) => {
13
13
  };
14
14
  const id = (bits) => run(bits)[0];
15
15
  const zeros = (n) => new Array(n).fill(0n);
16
- export default {
16
+ export const proof = {
17
17
  deterministic: () => {
18
18
  assertEq(id(zeros(16)), id(zeros(16)));
19
19
  },
@@ -0,0 +1,3 @@
1
+ export declare const proof: {
2
+ range: () => void;
3
+ };
@@ -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 default {
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
+ };
@@ -1,5 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  block: () => void;
3
3
  encoding: () => void;
4
4
  };
5
- export default _default;
@@ -1,6 +1,6 @@
1
1
  import { flat, utf8, utf8ToString } from "./module.f.js";
2
2
  import { join } from "../types/string/module.f.js";
3
- export default {
3
+ export const proof = {
4
4
  block: () => {
5
5
  const text = [
6
6
  'a',
@@ -0,0 +1 @@
1
+ export declare const proof: (() => void)[];
@@ -1,5 +1,5 @@
1
1
  import { fgRed, createConsoleText, backspace } from "./module.f.js";
2
- export default [
2
+ export const proof = [
3
3
  () => {
4
4
  if (fgRed !== '\x1b[31m') {
5
5
  throw new Error('Test failed: sgr(0)');
@@ -5,10 +5,11 @@
5
5
  *
6
6
  * @module
7
7
  */
8
- import { map, flat, stateScan, reduce, flatMap, empty, } from "../../types/list/module.f.js";
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 = (input) => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])));
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 _default: {
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 default {
6
+ export const proof = {
7
7
  toCodePointList: [
8
8
  () => {
9
9
  const result = stringify(toArray(toCodePointList([-1, 65536])));
@@ -3,11 +3,8 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import { flat, flatMap, stateScan } from "../../types/list/module.f.js";
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 = (input) => flat(stateScan(utf8ByteOrEofToCodePointOp)(null)(flat([input, eofList])));
181
+ export const toCodePointList = decoder(utf8ByteToCodePointOp, utf8EofToCodePointOp);
@@ -1,6 +1,5 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  toCodePoint: (() => void)[];
3
3
  fromCodePointList: (() => void)[];
4
4
  toFrom: (() => void)[];
5
5
  };
6
- 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 = jsonStringify(sort);
6
- export default {
6
+ export const proof = {
7
7
  toCodePoint: [
8
8
  () => {
9
9
  const result = stringify(toArray(toCodePointList([-1, 256])));
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  stringify: () => void;
3
3
  at: (() => void)[];
4
4
  first: (() => void)[];
@@ -9,4 +9,3 @@ declare const _default: {
9
9
  splitLast: (() => void)[];
10
10
  empty: () => void;
11
11
  };
12
- export default _default;
@@ -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 default {
5
+ export const proof = {
6
6
  stringify: () => {
7
7
  const result = stringify([1, 20, 300]);
8
8
  if (result !== '[1,20,300]') {
@@ -1,6 +1,5 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  decToBin: (() => void)[];
3
3
  roundingPositive: (() => void)[];
4
4
  roundingNegative: (() => void)[];
5
5
  };
6
- export default _default;
@@ -1,5 +1,5 @@
1
1
  import { decToBin } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  decToBin: [
4
4
  () => {
5
5
  const result = decToBin([0n, 0]);
@@ -1,5 +1,5 @@
1
1
  export declare const clz32Log2: (v: bigint) => bigint;
2
- declare const _default: {
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;
@@ -148,7 +148,7 @@ const benchmarkSmall = f => () => {
148
148
  --e;
149
149
  } while (c !== 0n);
150
150
  };
151
- export default {
151
+ export const proof = {
152
152
  example: () => {
153
153
  const total = sum([1n, 2n, 3n]); // 6n
154
154
  if (total !== 6n) {
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  examples: {
3
3
  vec: () => void;
4
4
  uint: () => void;
@@ -54,4 +54,3 @@ declare const _default: {
54
54
  msb_unaligned: () => void;
55
55
  };
56
56
  };
57
- export default _default;
@@ -80,7 +80,7 @@ const concat = (e) => (r) => () => {
80
80
  throw ab;
81
81
  }
82
82
  };
83
- export default {
83
+ export const proof = {
84
84
  examples: {
85
85
  vec: () => {
86
86
  const vec4 = vec(4n);
@@ -0,0 +1 @@
1
+ export declare const proof: () => void;
@@ -148,4 +148,4 @@ const test = () => {
148
148
  }
149
149
  }
150
150
  };
151
- export default test;
151
+ export const proof = test;
@@ -1,8 +1,7 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  valueTest1: () => void;
3
3
  valuesTest2: () => void;
4
4
  findTrue: () => void;
5
5
  find: () => void;
6
6
  test: () => void;
7
7
  };
8
- export default _default;
@@ -62,7 +62,7 @@ const test = () => {
62
62
  }
63
63
  }
64
64
  };
65
- export default {
65
+ export const proof = {
66
66
  valueTest1,
67
67
  valuesTest2,
68
68
  findTrue,
@@ -0,0 +1,4 @@
1
+ export declare const proof: {
2
+ test: () => void;
3
+ test2: () => void;
4
+ };
@@ -625,7 +625,7 @@ const test2 = () => {
625
625
  }
626
626
  }
627
627
  };
628
- export default {
628
+ export const proof = {
629
629
  test,
630
630
  test2,
631
631
  };
@@ -0,0 +1 @@
1
+ export declare const proof: (() => void)[];
@@ -354,4 +354,4 @@ const test = [
354
354
  }
355
355
  }
356
356
  ];
357
- export default test;
357
+ export const proof = test;
@@ -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;
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  has: (() => void)[];
3
3
  setRange: () => void;
4
4
  unset: (() => void)[];
@@ -9,4 +9,3 @@ declare const _default: {
9
9
  };
10
10
  toRangeMap: (() => void)[];
11
11
  };
12
- export default _default;
@@ -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 default {
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);