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.
Files changed (242) hide show
  1. package/fs/asn.1/module.f.js +7 -8
  2. package/fs/asn.1/{test.f.d.ts → proof.f.d.ts} +1 -2
  3. package/fs/asn.1/{test.f.js → proof.f.js} +12 -13
  4. package/fs/base128/proof.f.d.ts +1 -0
  5. package/fs/base128/{test.f.js → proof.f.js} +1 -1
  6. package/fs/bnf/data/{test.f.d.ts → proof.f.d.ts} +1 -2
  7. package/fs/bnf/data/{test.f.js → proof.f.js} +1 -1
  8. package/fs/bnf/proof.f.d.ts +3 -0
  9. package/fs/bnf/{test.f.js → proof.f.js} +1 -1
  10. package/fs/cas/module.f.js +2 -12
  11. package/fs/cas/proof.f.d.ts +1 -0
  12. package/fs/cas/proof.f.js +1 -0
  13. package/fs/cbase32/{test.f.d.ts → proof.f.d.ts} +1 -2
  14. package/fs/cbase32/{test.f.js → proof.f.js} +1 -1
  15. package/fs/ci/config/module.f.d.ts +4 -4
  16. package/fs/ci/config/module.f.js +4 -4
  17. package/fs/ci/node/module.f.js +12 -7
  18. package/fs/ci/{test.f.d.ts → proof.f.d.ts} +1 -2
  19. package/fs/ci/{test.f.js → proof.f.js} +1 -1
  20. package/fs/crypto/hmac/{test.f.d.ts → proof.f.d.ts} +1 -2
  21. package/fs/crypto/hmac/{test.f.js → proof.f.js} +1 -1
  22. package/fs/crypto/secp/{test.f.d.ts → proof.f.d.ts} +1 -2
  23. package/fs/crypto/secp/{test.f.js → proof.f.js} +1 -1
  24. package/fs/crypto/sha2/{test.f.d.ts → proof.f.d.ts} +1 -2
  25. package/fs/crypto/sha2/{test.f.js → proof.f.js} +1 -1
  26. package/fs/crypto/sign/module.f.js +3 -3
  27. package/fs/crypto/sign/{test.f.d.ts → proof.f.d.ts} +1 -2
  28. package/fs/crypto/sign/{test.f.js → proof.f.js} +1 -1
  29. package/fs/dev/module.f.d.ts +28 -2
  30. package/fs/dev/module.f.js +38 -22
  31. package/fs/dev/{test.f.d.ts → proof.f.d.ts} +5 -2
  32. package/fs/dev/{test.f.js → proof.f.js} +25 -2
  33. package/fs/dev/tf/module.d.ts +1 -2
  34. package/fs/dev/tf/module.f.d.ts +70 -7
  35. package/fs/dev/tf/module.f.js +115 -27
  36. package/fs/dev/tf/module.js +4 -103
  37. package/fs/dev/tf/{test.f.d.ts → proof.f.d.ts} +26 -0
  38. package/fs/dev/tf/{test.f.js → proof.f.js} +85 -38
  39. package/fs/dev/tf/scenarios/all.d.ts +1 -0
  40. package/fs/dev/tf/scenarios/all.js +3 -0
  41. package/fs/dev/tf/scenarios/async-subtests.fail.d.ts +4 -0
  42. package/fs/dev/tf/scenarios/async-subtests.fail.js +7 -0
  43. package/fs/dev/tf/scenarios/async-subtests.pass.d.ts +4 -0
  44. package/fs/dev/tf/scenarios/async-subtests.pass.js +7 -0
  45. package/fs/dev/tf/scenarios/async.fail.d.ts +1 -0
  46. package/fs/dev/tf/scenarios/async.fail.js +4 -0
  47. package/fs/dev/tf/scenarios/async.pass.d.ts +1 -0
  48. package/fs/dev/tf/scenarios/async.pass.js +3 -0
  49. package/fs/dev/tf/scenarios/fail.fail.f.d.ts +1 -0
  50. package/fs/dev/tf/scenarios/fail.fail.f.js +1 -0
  51. package/fs/dev/tf/scenarios/return-value.pass.f.d.ts +1 -0
  52. package/fs/dev/tf/scenarios/return-value.pass.f.js +2 -0
  53. package/fs/dev/tf/scenarios/thenable.pass.d.ts +3 -0
  54. package/fs/dev/tf/scenarios/thenable.pass.js +9 -0
  55. package/fs/dev/tf/scenarios/thenable2.pass.f.d.ts +3 -0
  56. package/fs/dev/tf/scenarios/thenable2.pass.f.js +3 -0
  57. package/fs/{bnf/test.f.d.ts → dev/tf/scenarios/throw.pass.f.d.ts} +3 -1
  58. package/fs/dev/tf/scenarios/throw.pass.f.js +3 -0
  59. package/fs/dev/version/proof.f.d.ts +3 -0
  60. package/fs/dev/version/{test.f.js → proof.f.js} +1 -1
  61. package/fs/djs/ast/{test.f.d.ts → proof.f.d.ts} +1 -2
  62. package/fs/djs/ast/{test.f.js → proof.f.js} +1 -1
  63. package/fs/djs/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
  64. package/fs/djs/parser/{test.f.js → proof.f.js} +1 -1
  65. package/fs/djs/{test.f.d.ts → proof.f.d.ts} +1 -2
  66. package/fs/djs/{test.f.js → proof.f.js} +1 -1
  67. package/fs/djs/serializer/module.f.d.ts +2 -2
  68. package/fs/djs/serializer/module.f.js +47 -79
  69. package/fs/djs/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
  70. package/fs/djs/serializer/{test.f.js → proof.f.js} +8 -8
  71. package/fs/djs/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
  72. package/fs/djs/tokenizer/{test.f.js → proof.f.js} +1 -1
  73. package/fs/djs/tokenizer-new/{test.f.d.ts → proof.f.d.ts} +1 -2
  74. package/fs/djs/tokenizer-new/{test.f.js → proof.f.js} +1 -1
  75. package/fs/djs/transpiler/module.f.d.ts +15 -0
  76. package/fs/djs/transpiler/module.f.js +10 -2
  77. package/fs/djs/transpiler/{test.f.d.ts → proof.f.d.ts} +1 -2
  78. package/fs/djs/transpiler/{test.f.js → proof.f.js} +1 -1
  79. package/fs/fsc/{test.f.d.ts → proof.f.d.ts} +1 -2
  80. package/fs/fsc/{test.f.js → proof.f.js} +1 -1
  81. package/fs/fsm/proof.f.d.ts +4 -0
  82. package/fs/fsm/{test.f.js → proof.f.js} +1 -1
  83. package/fs/html/{test.f.d.ts → proof.f.d.ts} +1 -2
  84. package/fs/html/{test.f.js → proof.f.js} +1 -1
  85. package/fs/io/module.d.ts +1 -1
  86. package/fs/io/module.f.d.ts +8 -3
  87. package/fs/io/module.f.js +12 -12
  88. package/fs/io/module.js +43 -5
  89. package/fs/js/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
  90. package/fs/js/tokenizer/{test.f.js → proof.f.js} +1 -1
  91. package/fs/json/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
  92. package/fs/json/parser/{test.f.js → proof.f.js} +1 -1
  93. package/fs/json/{test.f.d.ts → proof.f.d.ts} +1 -2
  94. package/fs/json/{test.f.js → proof.f.js} +1 -1
  95. package/fs/json/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
  96. package/fs/json/serializer/{test.f.js → proof.f.js} +1 -1
  97. package/fs/json/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
  98. package/fs/json/tokenizer/{test.f.js → proof.f.js} +1 -1
  99. package/fs/path/proof.f.d.ts +5 -0
  100. package/fs/path/{test.f.js → proof.f.js} +4 -3
  101. package/fs/sul/id/module.f.js +3 -4
  102. package/fs/sul/id/{test.f.d.ts → proof.f.d.ts} +1 -2
  103. package/fs/sul/id/{test.f.js → proof.f.js} +1 -1
  104. package/fs/sul/level/hash/{test.f.d.ts → proof.f.d.ts} +1 -2
  105. package/fs/sul/level/hash/{test.f.js → proof.f.js} +1 -1
  106. package/fs/sul/level/literal/module.f.js +3 -3
  107. package/fs/sul/level/literal/{test.f.d.ts → proof.f.d.ts} +1 -2
  108. package/fs/sul/level/literal/{test.f.js → proof.f.js} +1 -1
  109. package/fs/sul/{test.f.d.ts → proof.f.d.ts} +1 -2
  110. package/fs/sul/{test.f.js → proof.f.js} +1 -1
  111. package/fs/text/ascii/proof.f.d.ts +3 -0
  112. package/fs/text/ascii/{test.f.js → proof.f.js} +1 -1
  113. package/fs/text/code_point/module.f.d.ts +28 -0
  114. package/fs/text/code_point/module.f.js +31 -0
  115. package/fs/text/{test.f.d.ts → proof.f.d.ts} +1 -2
  116. package/fs/text/{test.f.js → proof.f.js} +1 -1
  117. package/fs/text/sgr/proof.f.d.ts +1 -0
  118. package/fs/text/sgr/proof.f.js +23 -0
  119. package/fs/text/utf16/module.f.js +3 -53
  120. package/fs/text/utf16/{test.f.d.ts → proof.f.d.ts} +1 -2
  121. package/fs/text/utf16/{test.f.js → proof.f.js} +1 -1
  122. package/fs/text/utf8/module.f.js +3 -25
  123. package/fs/text/utf8/{test.f.d.ts → proof.f.d.ts} +1 -2
  124. package/fs/text/utf8/{test.f.js → proof.f.js} +1 -1
  125. package/fs/types/array/{test.f.d.ts → proof.f.d.ts} +1 -2
  126. package/fs/types/array/{test.f.js → proof.f.js} +1 -1
  127. package/fs/types/bigfloat/{test.f.d.ts → proof.f.d.ts} +1 -2
  128. package/fs/types/bigfloat/{test.f.js → proof.f.js} +1 -1
  129. package/fs/types/bigint/{test.f.d.ts → proof.f.d.ts} +1 -2
  130. package/fs/types/bigint/{test.f.js → proof.f.js} +1 -1
  131. package/fs/types/bit_vec/module.f.d.ts +9 -4
  132. package/fs/types/bit_vec/module.f.js +7 -9
  133. package/fs/types/bit_vec/{test.f.d.ts → proof.f.d.ts} +1 -2
  134. package/fs/types/bit_vec/{test.f.js → proof.f.js} +1 -1
  135. package/fs/types/btree/find/proof.f.d.ts +1 -0
  136. package/fs/types/btree/find/{test.f.js → proof.f.js} +1 -1
  137. package/fs/types/btree/{test.f.d.ts → proof.f.d.ts} +1 -2
  138. package/fs/types/btree/{test.f.js → proof.f.js} +1 -1
  139. package/fs/types/btree/remove/module.f.d.ts +1 -1
  140. package/fs/types/btree/remove/module.f.js +7 -2
  141. package/fs/types/btree/remove/proof.f.d.ts +4 -0
  142. package/fs/types/btree/remove/{test.f.js → proof.f.js} +1 -1
  143. package/fs/types/btree/set/module.f.d.ts +1 -1
  144. package/fs/types/btree/set/module.f.js +7 -2
  145. package/fs/types/btree/set/proof.f.d.ts +1 -0
  146. package/fs/types/btree/set/{test.f.js → proof.f.js} +1 -1
  147. package/fs/types/btree/types/module.f.d.ts +9 -0
  148. package/fs/types/btree/types/module.f.js +9 -1
  149. package/fs/types/byte_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  150. package/fs/types/byte_set/{test.f.js → proof.f.js} +1 -1
  151. package/fs/types/effects/module.f.d.ts +17 -0
  152. package/fs/types/effects/module.f.js +17 -0
  153. package/fs/types/effects/node/module.f.d.ts +66 -4
  154. package/fs/types/effects/node/module.f.js +5 -1
  155. package/fs/types/effects/node/{test.f.d.ts → proof.f.d.ts} +1 -2
  156. package/fs/types/effects/node/{test.f.js → proof.f.js} +1 -1
  157. package/fs/types/effects/node/virtual/module.f.d.ts +2 -1
  158. package/fs/types/effects/node/virtual/module.f.js +2 -0
  159. package/fs/types/effects/proof.f.d.ts +11 -0
  160. package/fs/types/effects/proof.f.js +57 -0
  161. package/fs/types/function/compare/proof.f.d.ts +1 -0
  162. package/fs/types/function/compare/{test.f.js → proof.f.js} +1 -1
  163. package/fs/types/function/operator/proof.f.d.ts +12 -0
  164. package/fs/types/function/operator/{test.f.js → proof.f.js} +11 -10
  165. package/fs/types/function/proof.f.d.ts +1 -0
  166. package/fs/types/function/{test.f.js → proof.f.js} +1 -1
  167. package/fs/types/list/{test.f.d.ts → proof.f.d.ts} +1 -2
  168. package/fs/types/list/{test.f.js → proof.f.js} +1 -1
  169. package/fs/types/map/proof.f.d.ts +4 -0
  170. package/fs/types/map/{test.f.js → proof.f.js} +1 -1
  171. package/fs/types/monoid/{test.f.d.ts → proof.f.d.ts} +1 -2
  172. package/fs/types/monoid/{test.f.js → proof.f.js} +1 -1
  173. package/fs/types/nibble_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  174. package/fs/types/nibble_set/{test.f.js → proof.f.js} +1 -1
  175. package/fs/types/nominal/proof.f.d.ts +4 -0
  176. package/fs/types/nominal/{test.f.js → proof.f.js} +1 -1
  177. package/fs/types/nullable/proof.f.d.ts +1 -0
  178. package/fs/types/nullable/{test.f.js → proof.f.js} +11 -2
  179. package/fs/types/number/{test.f.d.ts → proof.f.d.ts} +1 -2
  180. package/fs/types/number/{test.f.js → proof.f.js} +1 -1
  181. package/fs/types/object/{test.f.d.ts → proof.f.d.ts} +1 -2
  182. package/fs/types/object/{test.f.js → proof.f.js} +1 -1
  183. package/fs/types/ordered_map/{test.f.d.ts → proof.f.d.ts} +1 -2
  184. package/fs/types/ordered_map/{test.f.js → proof.f.js} +1 -1
  185. package/fs/types/patricia_trie/{test.f.d.ts → proof.f.d.ts} +1 -2
  186. package/fs/types/patricia_trie/{test.f.js → proof.f.js} +1 -1
  187. package/fs/types/prime_field/{test.f.d.ts → proof.f.d.ts} +1 -2
  188. package/fs/types/prime_field/{test.f.js → proof.f.js} +1 -1
  189. package/fs/types/range/proof.f.d.ts +1 -0
  190. package/fs/types/range/{test.f.js → proof.f.js} +1 -1
  191. package/fs/types/range_map/{test.f.d.ts → proof.f.d.ts} +1 -2
  192. package/fs/types/range_map/{test.f.js → proof.f.js} +1 -1
  193. package/fs/types/result/proof.f.d.ts +5 -0
  194. package/fs/types/result/{test.f.js → proof.f.js} +18 -2
  195. package/fs/types/rtti/parse/{test.f.d.ts → proof.f.d.ts} +1 -2
  196. package/fs/types/rtti/parse/{test.f.js → proof.f.js} +1 -1
  197. package/fs/types/rtti/{test.f.d.ts → proof.f.d.ts} +1 -2
  198. package/fs/types/rtti/{test.f.js → proof.f.js} +1 -1
  199. package/fs/types/rtti/ts/{test.f.d.ts → proof.f.d.ts} +1 -2
  200. package/fs/types/rtti/ts/{test.f.js → proof.f.js} +1 -1
  201. package/fs/types/rtti/validate/{test.f.d.ts → proof.f.d.ts} +1 -2
  202. package/fs/types/rtti/validate/{test.f.js → proof.f.js} +1 -1
  203. package/fs/types/sorted_list/{test.f.d.ts → proof.f.d.ts} +1 -2
  204. package/fs/types/sorted_list/{test.f.js → proof.f.js} +1 -1
  205. package/fs/types/sorted_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  206. package/fs/types/sorted_set/{test.f.js → proof.f.js} +1 -1
  207. package/fs/types/string/{test.f.d.ts → proof.f.d.ts} +1 -2
  208. package/fs/types/string/{test.f.js → proof.f.js} +1 -1
  209. package/fs/types/string_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  210. package/fs/types/string_set/{test.f.js → proof.f.js} +1 -1
  211. package/fs/types/ts/{test.f.d.ts → proof.f.d.ts} +20 -0
  212. package/fs/types/ts/{test.f.js → proof.f.js} +1 -0
  213. package/fs/types/uint8array/{test.f.d.ts → proof.f.d.ts} +1 -2
  214. package/fs/types/uint8array/{test.f.js → proof.f.js} +1 -1
  215. package/issues/demo/sample/{test.f.js → proof.f.js} +1 -1
  216. package/issues/{test.f.d.ts → proof.f.d.ts} +1 -2
  217. package/issues/{test.f.js → proof.f.js} +1 -1
  218. package/nanvm-lib/tests/{test.f.d.ts → proof.f.d.ts} +1 -2
  219. package/nanvm-lib/tests/{test.f.js → proof.f.js} +1 -1
  220. package/nanvm-lib/tests/vm/{test.f.d.ts → proof.f.d.ts} +1 -2
  221. package/nanvm-lib/tests/vm/{test.f.js → proof.f.js} +1 -1
  222. package/package.json +5 -5
  223. package/fs/base128/test.f.d.ts +0 -2
  224. package/fs/cas/test.f.d.ts +0 -2
  225. package/fs/cas/test.f.js +0 -1
  226. package/fs/dev/version/test.f.d.ts +0 -4
  227. package/fs/fsm/test.f.d.ts +0 -5
  228. package/fs/path/test.f.d.ts +0 -3
  229. package/fs/text/ascii/test.f.d.ts +0 -4
  230. package/fs/text/sgr/test.f.d.ts +0 -2
  231. package/fs/text/sgr/test.f.js +0 -8
  232. package/fs/types/btree/find/test.f.d.ts +0 -2
  233. package/fs/types/btree/remove/test.f.d.ts +0 -5
  234. package/fs/types/btree/set/test.f.d.ts +0 -2
  235. package/fs/types/function/compare/test.f.d.ts +0 -2
  236. package/fs/types/function/operator/test.f.d.ts +0 -10
  237. package/fs/types/function/test.f.d.ts +0 -2
  238. package/fs/types/map/test.f.d.ts +0 -5
  239. package/fs/types/nominal/test.f.d.ts +0 -5
  240. package/fs/types/nullable/test.f.d.ts +0 -2
  241. package/fs/types/range/test.f.d.ts +0 -2
  242. 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 { listToVec, msb, vec } from "../../../types/bit_vec/module.f.js";
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 => concat(m(decode(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 _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)[];
@@ -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, 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) {
@@ -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: a => b => {
134
- const au = unpack(a);
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
  */
@@ -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,
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import type { TNode, Tree } from '../types/module.f.ts';
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
- const result = reduce(initReduce(tf)(first))(tt);
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));
@@ -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
  };
@@ -3,6 +3,6 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import type { TNode, Tree } from '../types/module.f.ts';
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
- const r = reduceBranch(f())(tail);
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)[];
@@ -354,4 +354,4 @@ const test = [
354
354
  }
355
355
  }
356
356
  ];
357
- export default test;
357
+ export const proof = test;
@@ -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
- export {};
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;