functionalscript 0.2.6 → 0.3.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 (428) hide show
  1. package/.github/workflows/ci.yml +19 -4
  2. package/CHANGELOG.md +5 -0
  3. package/com/cpp/{module.f.mjs → module.f.ts} +65 -44
  4. package/com/cpp/{test.f.mjs → test.f.ts} +1 -1
  5. package/com/cpp/testlib.f.ts +8 -0
  6. package/com/cs/{module.f.mjs → module.f.ts} +47 -38
  7. package/com/cs/{test.f.mjs → test.f.ts} +2 -2
  8. package/com/cs/testlib.f.ts +8 -0
  9. package/com/rust/module.f.ts +287 -0
  10. package/com/rust/{test.f.mjs → test.f.ts} +1 -1
  11. package/com/rust/testlib.f.ts +8 -0
  12. package/com/test/{build.f.mjs → build.f.ts} +47 -45
  13. package/com/test/{build.mjs → build.ts} +7 -6
  14. package/com/types/module.f.ts +62 -0
  15. package/com/types/{testlib.f.mjs → testlib.f.ts} +2 -3
  16. package/commonjs/build/module.f.ts +100 -0
  17. package/commonjs/build/{test.f.mjs → test.f.ts} +21 -17
  18. package/commonjs/module/function/module.f.ts +13 -0
  19. package/commonjs/module/module.f.ts +41 -0
  20. package/commonjs/module.f.ts +7 -0
  21. package/commonjs/{module.mjs → module.ts} +12 -9
  22. package/commonjs/package/dependencies/module.f.ts +22 -0
  23. package/commonjs/package/dependencies/{test.f.mjs → test.f.ts} +1 -1
  24. package/commonjs/package/module.f.ts +31 -0
  25. package/commonjs/package/{test.f.mjs → test.f.ts} +1 -1
  26. package/commonjs/path/{module.f.mjs → module.f.ts} +72 -67
  27. package/commonjs/path/{test.f.mjs → test.f.ts} +25 -19
  28. package/commonjs/{test.mjs → test.ts} +5 -4
  29. package/crypto/prime_field/{module.f.mjs → module.f.ts} +40 -37
  30. package/crypto/prime_field/{test.f.mjs → test.f.ts} +7 -5
  31. package/crypto/secp/{module.f.mjs → module.f.ts} +44 -44
  32. package/crypto/secp/{test.f.mjs → test.f.ts} +16 -11
  33. package/crypto/sha2/{module.f.mjs → module.f.ts} +61 -46
  34. package/crypto/sha2/{test.f.mjs → test.f.ts} +12 -9
  35. package/deno.json +71 -0
  36. package/dev/README.md +8 -0
  37. package/dev/index.ts +3 -0
  38. package/dev/{module.f.mjs → module.f.ts} +0 -2
  39. package/dev/{module.mjs → module.ts} +65 -60
  40. package/dev/test/{module.f.mjs → module.f.ts} +57 -70
  41. package/dev/{test.f.mjs → test.f.ts} +7 -5
  42. package/dev/test.ts +53 -0
  43. package/djs/{module.f.mjs → module.f.ts} +31 -31
  44. package/djs/parser/{module.f.mjs → module.f.ts} +190 -182
  45. package/djs/parser/{test.f.mjs → test.f.ts} +173 -150
  46. package/djs/serializer/module.f.ts +90 -0
  47. package/djs/{test.f.mjs → test.f.ts} +4 -4
  48. package/djs/tokenizer/{module.f.mjs → module.f.ts} +35 -42
  49. package/djs/tokenizer/{test.f.mjs → test.f.ts} +9 -8
  50. package/fsc/{module.f.mjs → module.f.ts} +41 -44
  51. package/fsc/{test.f.mjs → test.f.ts} +8 -6
  52. package/fsm/module.f.ts +107 -0
  53. package/fsm/{test.f.mjs → test.f.ts} +10 -9
  54. package/html/module.f.ts +108 -0
  55. package/html/{test.f.mjs → test.f.ts} +10 -7
  56. package/issues/lang/3110-function.md +25 -1
  57. package/issues/{test.f.mjs → test.f.ts} +3 -2
  58. package/js/tokenizer/module.f.ts +882 -0
  59. package/js/tokenizer/{test.f.mjs → test.f.ts} +11 -10
  60. package/json/module.f.ts +94 -0
  61. package/json/parser/{module.f.mjs → module.f.ts} +113 -109
  62. package/json/parser/{test.f.mjs → test.f.ts} +10 -9
  63. package/json/serializer/module.f.ts +70 -0
  64. package/json/serializer/{test.f.mjs → test.f.ts} +3 -3
  65. package/json/{test.f.mjs → test.f.ts} +3 -3
  66. package/json/tokenizer/{module.f.mjs → module.f.ts} +29 -36
  67. package/json/tokenizer/{test.f.mjs → test.f.ts} +9 -8
  68. package/nanvm-lib/src/extension.rs +15 -4
  69. package/nanvm-lib/src/interface.rs +7 -10
  70. package/nanvm-lib/src/lib.rs +3 -3
  71. package/nanvm-lib/src/naive.rs +10 -3
  72. package/nanvm-lib/src/nanenum.rs +5 -1
  73. package/nanvm-lib/tests/{test.f.mjs → test.f.ts} +7 -6
  74. package/nodejs/version/{main.mjs → main.ts} +1 -1
  75. package/nodejs/version/module.f.ts +42 -0
  76. package/nodejs/version/{test.f.mjs → test.f.ts} +11 -12
  77. package/package.json +9 -9
  78. package/text/ascii/{module.f.mjs → module.f.ts} +10 -8
  79. package/text/ascii/{test.f.mjs → test.f.ts} +4 -4
  80. package/text/module.f.ts +30 -0
  81. package/text/sgr/{module.f.mjs → module.f.ts} +3 -5
  82. package/text/{test.f.mjs → test.f.ts} +5 -4
  83. package/text/utf16/module.f.ts +108 -0
  84. package/text/utf16/{test.f.mjs → test.f.ts} +7 -6
  85. package/text/utf8/{module.f.mjs → module.f.ts} +29 -23
  86. package/text/utf8/{test.f.mjs → test.f.ts} +4 -4
  87. package/tsconfig.json +4 -1
  88. package/types/array/module.f.ts +89 -0
  89. package/types/array/{test.f.mjs → test.f.ts} +3 -3
  90. package/types/bigfloat/{module.f.mjs → module.f.ts} +25 -20
  91. package/types/bigfloat/{test.f.mjs → test.f.ts} +1 -1
  92. package/types/bigint/{module.f.mjs → module.f.ts} +29 -28
  93. package/types/bigint/{test.f.mjs → test.f.ts} +2 -2
  94. package/types/bit_vec/{module.f.mjs → module.f.ts} +16 -37
  95. package/types/bit_vec/{test.f.mjs → test.f.ts} +1 -1
  96. package/types/btree/find/module.f.ts +92 -0
  97. package/types/btree/find/{test.f.mjs → test.f.ts} +20 -16
  98. package/types/btree/{module.f.mjs → module.f.ts} +9 -9
  99. package/types/btree/remove/{module.f.mjs → module.f.ts} +43 -53
  100. package/types/btree/remove/{test.f.mjs → test.f.ts} +19 -15
  101. package/types/btree/set/{module.f.mjs → module.f.ts} +17 -20
  102. package/types/btree/set/{test.f.mjs → test.f.ts} +96 -66
  103. package/types/btree/{test.f.mjs → test.f.ts} +34 -26
  104. package/types/btree/types/module.f.ts +27 -0
  105. package/types/byte_set/module.f.ts +70 -0
  106. package/types/byte_set/{test.f.mjs → test.f.ts} +8 -7
  107. package/types/function/compare/module.f.ts +26 -0
  108. package/types/function/compare/{test.f.mjs → test.f.ts} +1 -1
  109. package/types/function/module.f.ts +43 -0
  110. package/types/function/operator/module.f.ts +63 -0
  111. package/types/function/test.f.ts +20 -0
  112. package/types/list/module.f.ts +345 -0
  113. package/types/list/{test.f.mjs → test.f.ts} +30 -24
  114. package/types/map/module.f.ts +65 -0
  115. package/types/map/{test.f.mjs → test.f.ts} +6 -5
  116. package/types/nibble_set/module.f.ts +34 -0
  117. package/types/nibble_set/{test.f.mjs → test.f.ts} +3 -3
  118. package/types/nullable/module.f.ts +9 -0
  119. package/types/nullable/{test.f.mjs → test.f.ts} +2 -2
  120. package/types/number/module.f.ts +16 -0
  121. package/types/number/{test.f.mjs → test.f.ts} +7 -5
  122. package/types/object/module.f.ts +30 -0
  123. package/types/object/{test.f.mjs → test.f.ts} +2 -2
  124. package/types/range/module.f.ts +10 -0
  125. package/types/range/{test.f.mjs → test.f.ts} +1 -1
  126. package/types/range_map/module.f.ts +70 -0
  127. package/types/range_map/{test.f.mjs → test.f.ts} +82 -57
  128. package/types/result/module.f.ts +20 -0
  129. package/types/result/{module.mjs → module.ts} +4 -3
  130. package/types/sorted_list/module.f.ts +83 -0
  131. package/types/sorted_list/{test.f.mjs → test.f.ts} +14 -12
  132. package/types/sorted_set/module.f.ts +36 -0
  133. package/types/sorted_set/{test.f.mjs → test.f.ts} +14 -12
  134. package/types/string/module.f.ts +24 -0
  135. package/types/string/{test.f.mjs → test.f.ts} +2 -2
  136. package/types/string_set/module.f.ts +37 -0
  137. package/types/string_set/{test.f.mjs → test.f.ts} +2 -2
  138. package/com/cpp/testlib.f.mjs +0 -8
  139. package/com/cs/testlib.f.mjs +0 -8
  140. package/com/rust/module.f.mjs +0 -272
  141. package/com/rust/testlib.f.mjs +0 -8
  142. package/com/types/module.f.mjs +0 -67
  143. package/commonjs/build/module.f.mjs +0 -100
  144. package/commonjs/module/function/module.f.mjs +0 -21
  145. package/commonjs/module/module.f.mjs +0 -53
  146. package/commonjs/module.f.mjs +0 -11
  147. package/commonjs/package/dependencies/module.f.mjs +0 -22
  148. package/commonjs/package/module.f.mjs +0 -36
  149. package/dev/index.mjs +0 -3
  150. package/dev/test.mjs +0 -60
  151. package/fsm/module.f.mjs +0 -99
  152. package/html/module.f.mjs +0 -102
  153. package/js/tokenizer/module.f.mjs +0 -872
  154. package/json/module.f.mjs +0 -89
  155. package/json/serializer/module.f.mjs +0 -87
  156. package/jsr.json +0 -66
  157. package/nodejs/version/module.f.mjs +0 -47
  158. package/out/com/cpp/module.f.d.mts +0 -7
  159. package/out/com/cpp/module.f.mjs +0 -130
  160. package/out/com/cpp/test.f.d.mts +0 -2
  161. package/out/com/cpp/test.f.mjs +0 -40
  162. package/out/com/cpp/testlib.f.d.mts +0 -2
  163. package/out/com/cpp/testlib.f.mjs +0 -7
  164. package/out/com/cs/module.f.d.mts +0 -7
  165. package/out/com/cs/module.f.mjs +0 -104
  166. package/out/com/cs/test.f.d.mts +0 -2
  167. package/out/com/cs/test.f.mjs +0 -43
  168. package/out/com/cs/testlib.f.d.mts +0 -2
  169. package/out/com/cs/testlib.f.mjs +0 -7
  170. package/out/com/rust/module.f.d.mts +0 -23
  171. package/out/com/rust/module.f.mjs +0 -224
  172. package/out/com/rust/test.f.d.mts +0 -2
  173. package/out/com/rust/test.f.mjs +0 -123
  174. package/out/com/rust/testlib.f.d.mts +0 -2
  175. package/out/com/rust/testlib.f.mjs +0 -7
  176. package/out/com/test/build.d.mts +0 -1
  177. package/out/com/test/build.f.d.mts +0 -26
  178. package/out/com/test/build.f.mjs +0 -98
  179. package/out/com/test/build.mjs +0 -40
  180. package/out/com/types/module.f.d.mts +0 -23
  181. package/out/com/types/module.f.mjs +0 -51
  182. package/out/com/types/testlib.f.d.mts +0 -44
  183. package/out/com/types/testlib.f.mjs +0 -30
  184. package/out/commonjs/build/module.f.d.mts +0 -20
  185. package/out/commonjs/build/module.f.mjs +0 -107
  186. package/out/commonjs/build/test.f.d.mts +0 -3
  187. package/out/commonjs/build/test.f.mjs +0 -102
  188. package/out/commonjs/module/function/module.f.d.mts +0 -5
  189. package/out/commonjs/module/function/module.f.mjs +0 -15
  190. package/out/commonjs/module/module.f.d.mts +0 -52
  191. package/out/commonjs/module/module.f.mjs +0 -48
  192. package/out/commonjs/module.d.mts +0 -3
  193. package/out/commonjs/module.f.d.mts +0 -2
  194. package/out/commonjs/module.f.mjs +0 -10
  195. package/out/commonjs/module.mjs +0 -26
  196. package/out/commonjs/package/dependencies/module.f.d.mts +0 -6
  197. package/out/commonjs/package/dependencies/module.f.mjs +0 -21
  198. package/out/commonjs/package/dependencies/test.f.d.mts +0 -2
  199. package/out/commonjs/package/dependencies/test.f.mjs +0 -15
  200. package/out/commonjs/package/module.f.d.mts +0 -21
  201. package/out/commonjs/package/module.f.mjs +0 -40
  202. package/out/commonjs/package/test.f.d.mts +0 -2
  203. package/out/commonjs/package/test.f.mjs +0 -27
  204. package/out/commonjs/path/module.f.d.mts +0 -60
  205. package/out/commonjs/path/module.f.mjs +0 -171
  206. package/out/commonjs/path/test.f.d.mts +0 -25
  207. package/out/commonjs/path/test.f.mjs +0 -231
  208. package/out/commonjs/test.d.mts +0 -8
  209. package/out/commonjs/test.mjs +0 -87
  210. package/out/crypto/prime_field/module.f.d.mts +0 -67
  211. package/out/crypto/prime_field/module.f.mjs +0 -110
  212. package/out/crypto/prime_field/test.f.d.mts +0 -13
  213. package/out/crypto/prime_field/test.f.mjs +0 -152
  214. package/out/crypto/secp/module.f.d.mts +0 -110
  215. package/out/crypto/secp/module.f.mjs +0 -173
  216. package/out/crypto/secp/test.f.d.mts +0 -5
  217. package/out/crypto/secp/test.f.mjs +0 -78
  218. package/out/crypto/sha2/module.f.d.mts +0 -15
  219. package/out/crypto/sha2/module.f.mjs +0 -172
  220. package/out/crypto/sha2/test.f.d.mts +0 -10
  221. package/out/crypto/sha2/test.f.mjs +0 -86
  222. package/out/dev/index.d.mts +0 -1
  223. package/out/dev/index.mjs +0 -2
  224. package/out/dev/module.d.mts +0 -26
  225. package/out/dev/module.f.d.mts +0 -1
  226. package/out/dev/module.f.mjs +0 -2
  227. package/out/dev/module.mjs +0 -167
  228. package/out/dev/test/module.f.d.mts +0 -25
  229. package/out/dev/test/module.f.mjs +0 -134
  230. package/out/dev/test.d.mts +0 -3
  231. package/out/dev/test.f.d.mts +0 -9
  232. package/out/dev/test.f.mjs +0 -58
  233. package/out/dev/test.mjs +0 -52
  234. package/out/djs/module.f.d.mts +0 -20
  235. package/out/djs/module.f.mjs +0 -79
  236. package/out/djs/parser/module.f.d.mts +0 -56
  237. package/out/djs/parser/module.f.mjs +0 -448
  238. package/out/djs/parser/test.f.d.mts +0 -13
  239. package/out/djs/parser/test.f.mjs +0 -569
  240. package/out/djs/test.f.d.mts +0 -12
  241. package/out/djs/test.f.mjs +0 -84
  242. package/out/djs/tokenizer/module.f.d.mts +0 -13
  243. package/out/djs/tokenizer/module.f.mjs +0 -91
  244. package/out/djs/tokenizer/test.f.d.mts +0 -7
  245. package/out/djs/tokenizer/test.f.mjs +0 -530
  246. package/out/fsc/module.f.d.mts +0 -7
  247. package/out/fsc/module.f.mjs +0 -105
  248. package/out/fsc/test.f.d.mts +0 -4
  249. package/out/fsc/test.f.mjs +0 -19
  250. package/out/fsm/module.f.d.mts +0 -14
  251. package/out/fsm/module.f.mjs +0 -80
  252. package/out/fsm/test.f.d.mts +0 -5
  253. package/out/fsm/test.f.mjs +0 -138
  254. package/out/html/module.f.d.mts +0 -17
  255. package/out/html/module.f.mjs +0 -80
  256. package/out/html/test.f.d.mts +0 -10
  257. package/out/html/test.f.mjs +0 -45
  258. package/out/issues/test.f.d.mts +0 -16
  259. package/out/issues/test.f.mjs +0 -66
  260. package/out/js/tokenizer/module.f.d.mts +0 -163
  261. package/out/js/tokenizer/module.f.mjs +0 -729
  262. package/out/js/tokenizer/test.f.d.mts +0 -9
  263. package/out/js/tokenizer/test.f.mjs +0 -906
  264. package/out/json/module.f.d.mts +0 -33
  265. package/out/json/module.f.mjs +0 -89
  266. package/out/json/parser/module.f.d.mts +0 -32
  267. package/out/json/parser/module.f.mjs +0 -224
  268. package/out/json/parser/test.f.d.mts +0 -5
  269. package/out/json/parser/test.f.mjs +0 -329
  270. package/out/json/serializer/module.f.d.mts +0 -36
  271. package/out/json/serializer/module.f.mjs +0 -67
  272. package/out/json/serializer/test.f.d.mts +0 -8
  273. package/out/json/serializer/test.f.mjs +0 -87
  274. package/out/json/test.f.d.mts +0 -8
  275. package/out/json/test.f.mjs +0 -61
  276. package/out/json/tokenizer/module.f.d.mts +0 -13
  277. package/out/json/tokenizer/module.f.mjs +0 -78
  278. package/out/json/tokenizer/test.f.d.mts +0 -6
  279. package/out/json/tokenizer/test.f.mjs +0 -420
  280. package/out/nanvm-lib/tests/test.f.d.mts +0 -36
  281. package/out/nanvm-lib/tests/test.f.mjs +0 -87
  282. package/out/nodejs/version/main.d.mts +0 -1
  283. package/out/nodejs/version/main.mjs +0 -3
  284. package/out/nodejs/version/module.f.d.mts +0 -12
  285. package/out/nodejs/version/module.f.mjs +0 -34
  286. package/out/nodejs/version/test.f.d.mts +0 -2
  287. package/out/nodejs/version/test.f.mjs +0 -97
  288. package/out/text/ascii/module.f.d.mts +0 -70
  289. package/out/text/ascii/module.f.mjs +0 -154
  290. package/out/text/ascii/test.f.d.mts +0 -4
  291. package/out/text/ascii/test.f.mjs +0 -14
  292. package/out/text/module.f.d.mts +0 -13
  293. package/out/text/module.f.mjs +0 -19
  294. package/out/text/sgr/module.f.d.mts +0 -12
  295. package/out/text/sgr/module.f.mjs +0 -17
  296. package/out/text/test.f.d.mts +0 -2
  297. package/out/text/test.f.mjs +0 -19
  298. package/out/text/utf16/module.f.d.mts +0 -12
  299. package/out/text/utf16/module.f.mjs +0 -86
  300. package/out/text/utf16/test.f.d.mts +0 -6
  301. package/out/text/utf16/test.f.mjs +0 -145
  302. package/out/text/utf8/module.f.d.mts +0 -10
  303. package/out/text/utf8/module.f.mjs +0 -126
  304. package/out/text/utf8/test.f.d.mts +0 -6
  305. package/out/text/utf8/test.f.mjs +0 -175
  306. package/out/types/array/module.f.d.mts +0 -31
  307. package/out/types/array/module.f.mjs +0 -95
  308. package/out/types/array/test.f.d.mts +0 -10
  309. package/out/types/array/test.f.mjs +0 -116
  310. package/out/types/bigfloat/module.f.d.mts +0 -6
  311. package/out/types/bigfloat/module.f.mjs +0 -77
  312. package/out/types/bigfloat/test.f.d.mts +0 -6
  313. package/out/types/bigfloat/test.f.mjs +0 -349
  314. package/out/types/bigint/module.f.d.mts +0 -29
  315. package/out/types/bigint/module.f.mjs +0 -114
  316. package/out/types/bigint/test.f.d.mts +0 -16
  317. package/out/types/bigint/test.f.mjs +0 -199
  318. package/out/types/bit_vec/module.f.d.mts +0 -158
  319. package/out/types/bit_vec/module.f.mjs +0 -194
  320. package/out/types/bit_vec/test.f.d.mts +0 -23
  321. package/out/types/bit_vec/test.f.mjs +0 -210
  322. package/out/types/btree/find/module.f.d.mts +0 -36
  323. package/out/types/btree/find/module.f.mjs +0 -137
  324. package/out/types/btree/find/test.f.d.mts +0 -2
  325. package/out/types/btree/find/test.f.mjs +0 -156
  326. package/out/types/btree/module.f.d.mts +0 -5
  327. package/out/types/btree/module.f.mjs +0 -34
  328. package/out/types/btree/remove/module.f.d.mts +0 -14
  329. package/out/types/btree/remove/module.f.mjs +0 -209
  330. package/out/types/btree/remove/test.f.d.mts +0 -7
  331. package/out/types/btree/remove/test.f.mjs +0 -638
  332. package/out/types/btree/set/module.f.d.mts +0 -5
  333. package/out/types/btree/set/module.f.mjs +0 -114
  334. package/out/types/btree/set/test.f.d.mts +0 -2
  335. package/out/types/btree/set/test.f.mjs +0 -390
  336. package/out/types/btree/test.f.d.mts +0 -13
  337. package/out/types/btree/test.f.mjs +0 -83
  338. package/out/types/btree/types/module.f.d.mts +0 -14
  339. package/out/types/btree/types/module.f.mjs +0 -50
  340. package/out/types/byte_set/module.f.d.mts +0 -25
  341. package/out/types/byte_set/module.f.mjs +0 -42
  342. package/out/types/byte_set/test.f.d.mts +0 -13
  343. package/out/types/byte_set/test.f.mjs +0 -123
  344. package/out/types/function/compare/module.f.d.mts +0 -23
  345. package/out/types/function/compare/module.f.mjs +0 -22
  346. package/out/types/function/compare/test.f.d.mts +0 -2
  347. package/out/types/function/compare/test.f.mjs +0 -8
  348. package/out/types/function/module.f.d.mts +0 -51
  349. package/out/types/function/module.f.mjs +0 -44
  350. package/out/types/function/operator/module.f.d.mts +0 -60
  351. package/out/types/function/operator/module.f.mjs +0 -60
  352. package/out/types/function/test.f.d.mts +0 -2
  353. package/out/types/function/test.f.mjs +0 -15
  354. package/out/types/list/module.f.d.mts +0 -82
  355. package/out/types/list/module.f.mjs +0 -269
  356. package/out/types/list/test.f.d.mts +0 -38
  357. package/out/types/list/test.f.mjs +0 -401
  358. package/out/types/map/module.f.d.mts +0 -21
  359. package/out/types/map/module.f.mjs +0 -54
  360. package/out/types/map/test.f.d.mts +0 -5
  361. package/out/types/map/test.f.mjs +0 -115
  362. package/out/types/nibble_set/module.f.d.mts +0 -16
  363. package/out/types/nibble_set/module.f.mjs +0 -19
  364. package/out/types/nibble_set/test.f.d.mts +0 -13
  365. package/out/types/nibble_set/test.f.mjs +0 -90
  366. package/out/types/nullable/module.f.d.mts +0 -9
  367. package/out/types/nullable/module.f.mjs +0 -9
  368. package/out/types/nullable/test.f.d.mts +0 -2
  369. package/out/types/nullable/test.f.mjs +0 -12
  370. package/out/types/number/module.f.d.mts +0 -7
  371. package/out/types/number/module.f.mjs +0 -12
  372. package/out/types/number/test.f.d.mts +0 -11
  373. package/out/types/number/test.f.mjs +0 -126
  374. package/out/types/object/module.f.d.mts +0 -22
  375. package/out/types/object/module.f.mjs +0 -27
  376. package/out/types/object/test.f.d.mts +0 -5
  377. package/out/types/object/test.f.mjs +0 -17
  378. package/out/types/range/module.f.d.mts +0 -6
  379. package/out/types/range/module.f.mjs +0 -6
  380. package/out/types/range/test.f.d.mts +0 -2
  381. package/out/types/range/test.f.mjs +0 -18
  382. package/out/types/range_map/module.f.d.mts +0 -19
  383. package/out/types/range_map/module.f.mjs +0 -84
  384. package/out/types/range_map/test.f.d.mts +0 -6
  385. package/out/types/range_map/test.f.mjs +0 -201
  386. package/out/types/result/module.d.mts +0 -7
  387. package/out/types/result/module.f.d.mts +0 -22
  388. package/out/types/result/module.f.mjs +0 -25
  389. package/out/types/result/module.mjs +0 -16
  390. package/out/types/sorted_list/module.f.d.mts +0 -53
  391. package/out/types/sorted_list/module.f.mjs +0 -102
  392. package/out/types/sorted_list/test.f.d.mts +0 -5
  393. package/out/types/sorted_list/test.f.mjs +0 -66
  394. package/out/types/sorted_set/module.f.d.mts +0 -19
  395. package/out/types/sorted_set/module.f.mjs +0 -29
  396. package/out/types/sorted_set/test.f.d.mts +0 -6
  397. package/out/types/sorted_set/test.f.mjs +0 -80
  398. package/out/types/string/module.f.d.mts +0 -9
  399. package/out/types/string/module.f.mjs +0 -17
  400. package/out/types/string/test.f.d.mts +0 -15
  401. package/out/types/string/test.f.mjs +0 -58
  402. package/out/types/string_set/module.f.d.mts +0 -13
  403. package/out/types/string_set/module.f.mjs +0 -29
  404. package/out/types/string_set/test.f.d.mts +0 -5
  405. package/out/types/string_set/test.f.mjs +0 -65
  406. package/text/module.f.mjs +0 -27
  407. package/text/utf16/module.f.mjs +0 -96
  408. package/types/array/module.f.mjs +0 -119
  409. package/types/btree/find/module.f.mjs +0 -125
  410. package/types/btree/types/module.f.mjs +0 -64
  411. package/types/byte_set/module.f.mjs +0 -61
  412. package/types/function/compare/module.f.mjs +0 -29
  413. package/types/function/module.f.mjs +0 -50
  414. package/types/function/operator/module.f.mjs +0 -78
  415. package/types/function/test.f.mjs +0 -17
  416. package/types/list/module.f.mjs +0 -320
  417. package/types/map/module.f.mjs +0 -67
  418. package/types/nibble_set/module.f.mjs +0 -28
  419. package/types/nullable/module.f.mjs +0 -11
  420. package/types/number/module.f.mjs +0 -16
  421. package/types/object/module.f.mjs +0 -33
  422. package/types/range/module.f.mjs +0 -8
  423. package/types/range_map/module.f.mjs +0 -84
  424. package/types/result/module.f.mjs +0 -28
  425. package/types/sorted_list/module.f.mjs +0 -107
  426. package/types/sorted_set/module.f.mjs +0 -38
  427. package/types/string/module.f.mjs +0 -22
  428. package/types/string_set/module.f.mjs +0 -36
@@ -1,172 +0,0 @@
1
- // @ts-self-types="./module.f.d.mts"
2
- import * as array from '../../types/array/module.f.mjs';
3
- /**
4
- * @typedef {{
5
- * readonly f: (i: number) => number
6
- * readonly length: number
7
- * }} HashInput
8
- */
9
- /** @typedef {array.Array8<number>} Hash8 */
10
- /** @typedef {array.Array16<number>} Array16 */
11
- /** @type {(input: number) => (pos: number) => number} */
12
- const appendOneWithZeros = input => pos => (input >> pos << pos) | (1 << pos);
13
- /** @type {(input: number) => (pos: number) => number} */
14
- const mod = a => b => (a % b + b) % b;
15
- /** @type {(input: readonly number[]) => (bits: number) => HashInput} */
16
- export const padding = input => bitsCount => {
17
- const appendBlockIndex = (bitsCount / 32) | 0;
18
- const length = (bitsCount + mod(447 - bitsCount)(512) + 65) / 32;
19
- /** @type {(i: number) => number} */
20
- const f = i => {
21
- if (i < appendBlockIndex) {
22
- return input[i];
23
- }
24
- if (i === appendBlockIndex) {
25
- return appendBlockIndex >= input.length ? 0x8000_0000 : appendOneWithZeros(input[appendBlockIndex])(31 - bitsCount % 32);
26
- }
27
- if (i === length - 2) {
28
- return (bitsCount / 0x1_0000_0000) | 0;
29
- }
30
- if (i === length - 1) {
31
- return bitsCount % 0x1_0000_0000;
32
- }
33
- return 0;
34
- };
35
- return ({ f, length });
36
- };
37
- /** @type {(d: number) => (n: number) => number} */
38
- const rotr = d => {
39
- const r = 32 - d;
40
- return n => n >>> d | n << r;
41
- };
42
- /** @type {(x: number) => (y: number) => (z: number) => number} */
43
- const ch = x => y => z => x & y ^ ~x & z;
44
- /** @type {(x: number) => (y: number) => (z: number) => number} */
45
- const maj = x => y => z => x & y ^ x & z ^ y & z;
46
- /** @type {(d: number) => (n: number) => number} */
47
- const shr = d => n => n >>> d;
48
- /** @type {(a: number) => (b: number) => (c: number) => (x: number) => number} */
49
- const bigSigma = a => b => c => {
50
- const ra = rotr(a);
51
- const rb = rotr(b);
52
- const rc = rotr(c);
53
- return x => ra(x) ^ rb(x) ^ rc(x);
54
- };
55
- const bigSigma0 = bigSigma(2)(13)(22);
56
- const bigSigma1 = bigSigma(6)(11)(25);
57
- /** @type {(a: number) => (b: number) => (c: number) => (x: number) => number} */
58
- const smallSigma = a => b => c => {
59
- const ra = rotr(a);
60
- const rb = rotr(b);
61
- const sc = shr(c);
62
- return x => ra(x) ^ rb(x) ^ sc(x);
63
- };
64
- const smallSigma0 = smallSigma(7)(18)(3);
65
- const smallSigma1 = smallSigma(17)(19)(10);
66
- /** @type {(a: array.Array4<number>) => number} */
67
- const wi = ([a0, a1, a2, a3]) => (smallSigma1(a0) + a1 + smallSigma0(a2) + a3) | 0;
68
- /** @type {(w: Array16) => Array16} */
69
- const nextW = ([w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, wA, wB, wC, wD, wE, wF]) => {
70
- w0 = wi([wE, w9, w1, w0]);
71
- w1 = wi([wF, wA, w2, w1]);
72
- w2 = wi([w0, wB, w3, w2]);
73
- w3 = wi([w1, wC, w4, w3]);
74
- w4 = wi([w2, wD, w5, w4]);
75
- w5 = wi([w3, wE, w6, w5]);
76
- w6 = wi([w4, wF, w7, w6]);
77
- w7 = wi([w5, w0, w8, w7]);
78
- w8 = wi([w6, w1, w9, w8]);
79
- w9 = wi([w7, w2, wA, w9]);
80
- wA = wi([w8, w3, wB, wA]);
81
- wB = wi([w9, w4, wC, wB]);
82
- wC = wi([wA, w5, wD, wC]);
83
- wD = wi([wB, w6, wE, wD]);
84
- wE = wi([wC, w7, wF, wE]);
85
- wF = wi([wD, w8, w0, wF]);
86
- return [w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, wA, wB, wC, wD, wE, wF];
87
- };
88
- const k = [
89
- [
90
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
91
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
92
- ],
93
- [
94
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
95
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
96
- ],
97
- [
98
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
99
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
100
- ],
101
- [
102
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
103
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
104
- ],
105
- ];
106
- /** @type {(init: Hash8) => (data: Array16) => Hash8} */
107
- const compress = ([a0, b0, c0, d0, e0, f0, g0, h0]) => data => {
108
- let w = data;
109
- let a = a0;
110
- let b = b0;
111
- let c = c0;
112
- let d = d0;
113
- let e = e0;
114
- let f = f0;
115
- let g = g0;
116
- let h = h0;
117
- let i = 0;
118
- while (true) {
119
- const ki = k[i];
120
- for (let j = 0; j < 16; ++j) {
121
- const t1 = h + bigSigma1(e) + ch(e)(f)(g) + ki[j] + w[j];
122
- const t2 = bigSigma0(a) + maj(a)(b)(c);
123
- h = g;
124
- g = f;
125
- f = e;
126
- e = (d + t1) | 0;
127
- d = c;
128
- c = b;
129
- b = a;
130
- a = (t1 + t2) | 0;
131
- }
132
- if (i === 3) {
133
- break;
134
- }
135
- ++i;
136
- w = nextW(w);
137
- }
138
- return [
139
- (a0 + a) | 0,
140
- (b0 + b) | 0,
141
- (c0 + c) | 0,
142
- (d0 + d) | 0,
143
- (e0 + e) | 0,
144
- (f0 + f) | 0,
145
- (g0 + g) | 0,
146
- (h0 + h) | 0,
147
- ];
148
- };
149
- /** @type {(init: Hash8) => (input: readonly number[]) => (bitsCount: number) => Hash8} */
150
- const compute = init => input => bitsCount => {
151
- const { f, length } = padding(input)(bitsCount);
152
- let result = init;
153
- const chunkCount = length / 16;
154
- for (let i = 0; i < chunkCount; i++) {
155
- const s = i * 16;
156
- result = compress(result)([
157
- f(s + 0), f(s + 1), f(s + 2), f(s + 3), f(s + 4), f(s + 5), f(s + 6), f(s + 7),
158
- f(s + 8), f(s + 9), f(s + 10), f(s + 11), f(s + 12), f(s + 13), f(s + 14), f(s + 15)
159
- ]);
160
- }
161
- return result;
162
- };
163
- /** @type {Hash8} */
164
- const init256 = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
165
- /** @type {(input: readonly number[]) => (bitsCount: number) => Hash8} */
166
- export const computeSha256 = compute(init256);
167
- /** @type {Hash8} */
168
- const init224 = [0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4];
169
- /** @type {(input: readonly number[]) => (bitsCount: number) => Hash8} */
170
- export const computeSha224 = compute(init224);
171
- export const compress256 = compress(init256);
172
- export const compress224 = compress(init224);
@@ -1,10 +0,0 @@
1
- declare namespace _default {
2
- export namespace empty {
3
- function sha256(): void;
4
- function sha224(): void;
5
- }
6
- export let sha224compress: (() => void)[];
7
- let sha256_1: (() => void)[];
8
- export { sha256_1 as sha256 };
9
- }
10
- export default _default;
@@ -1,86 +0,0 @@
1
- import * as _ from './module.f.mjs';
2
- import * as json from '../../json/module.f.mjs';
3
- import * as o from '../../types/object/module.f.mjs';
4
- const { sort } = o;
5
- /** @type {(a: number) => number} */
6
- const toU32 = x => (x + 0x1_0000_0000) % 0x1_0000_0000;
7
- /** @type {(a: number) => string} */
8
- const toHexString = x => toU32(x).toString(16).padStart(8, '0');
9
- /** @type {(a: readonly json.Unknown[]) => string} */
10
- const stringify = a => json.stringify(sort)(a);
11
- // {
12
- // const result = _.padding([])(0)
13
- // console.log(result.map(toHexString))
14
- // }
15
- // {
16
- // const result = _.padding([0x61626364, 0x65000000])(40)
17
- // console.log(result.map(toHexString))
18
- // }
19
- // {
20
- // const result = _.padding([0x11111110])(31)
21
- // console.log(result.map(toHexString))
22
- // }
23
- // {
24
- // const result = _.padding([0x11111110])(32)
25
- // console.log(result.map(toHexString))
26
- // }
27
- export default {
28
- empty: {
29
- sha256: () => {
30
- const hash = _.computeSha256([])(0);
31
- const result = stringify(hash.map(toHexString));
32
- if (result !== '["e3b0c442","98fc1c14","9afbf4c8","996fb924","27ae41e4","649b934c","a495991b","7852b855"]') {
33
- throw result;
34
- }
35
- },
36
- sha224: () => {
37
- const hash = _.computeSha224([])(0);
38
- const result = stringify(hash.map(toHexString));
39
- if (result !== '["d14a028c","2a3a2bc9","476102bb","288234c4","15a2b01f","828ea62a","c5b3e42f","bdd387cb"]') {
40
- throw result;
41
- }
42
- }
43
- },
44
- sha224compress: [
45
- () => {
46
- const hash = _.compress224([0x8000_0000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
47
- const result = stringify(hash.map(toHexString));
48
- if (result !== '["d14a028c","2a3a2bc9","476102bb","288234c4","15a2b01f","828ea62a","c5b3e42f","bdd387cb"]') {
49
- throw result;
50
- }
51
- }
52
- ],
53
- sha256: [
54
- () => {
55
- //[0x68656C6C, 0x6F20776F, 0x726C6400] represents phrase 'hello world'
56
- const hash = _.computeSha256([0x68656C6C, 0x6F20776F, 0x726C6400])(88);
57
- const result = stringify(hash.map(toHexString));
58
- if (result !== '["b94d27b9","934d3e08","a52e52d7","da7dabfa","c484efe3","7a5380ee","9088f7ac","e2efcde9"]') {
59
- throw result;
60
- }
61
- },
62
- () => {
63
- //[0x68656C6C, 0x6F20776F, 0x726C6488] represents phrase 'hello world' with 1's at the end
64
- const hash = _.computeSha256([0x68656C6C, 0x6F20776F, 0x726C64FF])(88);
65
- const result = stringify(hash.map(toHexString));
66
- if (result !== '["b94d27b9","934d3e08","a52e52d7","da7dabfa","c484efe3","7a5380ee","9088f7ac","e2efcde9"]') {
67
- throw result;
68
- }
69
- },
70
- () => {
71
- const input = Array(8).fill(0x31313131);
72
- const result = _.computeSha256(input)(256);
73
- if (toU32(result[0]) !== 0x8a83665f) {
74
- throw result[0];
75
- }
76
- },
77
- () => {
78
- const input = Array(16).fill(0x31313131);
79
- const hash = _.computeSha256(input)(512);
80
- const result = stringify(hash.map(toHexString));
81
- if (result !== '["3138bb9b","c78df27c","473ecfd1","410f7bd4","5ebac1f5","9cf3ff9c","fe4db77a","ab7aedd3"]') {
82
- throw result;
83
- }
84
- }
85
- ]
86
- };
@@ -1 +0,0 @@
1
- export {};
package/out/dev/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- import { index } from "./module.mjs";
2
- index();
@@ -1,26 +0,0 @@
1
- /** @type {(code: number) => never} */
2
- export const exit: (code: number) => never;
3
- /** @type {(v: string) => string|undefined} */
4
- export const env: (v: string) => string | undefined;
5
- export function loadModuleMap(): Promise<ModuleMap>;
6
- export function index(): Promise<void>;
7
- export type Options = {
8
- readonly withFileTypes: true;
9
- };
10
- export type Dirent = {
11
- readonly name: string;
12
- readonly isDirectory: () => boolean;
13
- };
14
- export type FsPromises = {
15
- readonly readdir: (path: string, options: Options) => Promise<readonly Dirent[]>;
16
- readonly readFile: (path: string, options: "utf8") => Promise<string>;
17
- };
18
- export type Module = {
19
- readonly default?: unknown;
20
- };
21
- export type Require = (name: string) => unknown;
22
- export type UnknownMap = { readonly [k in string]: unknown; };
23
- export type Entry<T> = readonly [string, T];
24
- export type MutableModuleMap = { [k in string]: Module; };
25
- export type ModuleMap = { readonly [k in string]: Module; };
26
- export type FolderMap = { readonly [k in string]: string | FolderMap; };
@@ -1 +0,0 @@
1
- export function todo(): never;
@@ -1,2 +0,0 @@
1
- // @ts-self-types="./module.f.d.mts"
2
- export const todo = () => { throw 'not implemented'; };
@@ -1,167 +0,0 @@
1
- import { readdir, writeFile, readFile } from 'node:fs/promises';
2
- /**
3
- * @typedef {{
4
- * readonly withFileTypes: true
5
- * }} Options
6
- */
7
- /**
8
- * @typedef {{
9
- * readonly name: string
10
- * readonly isDirectory: () => boolean
11
- * }} Dirent
12
- */
13
- /**
14
- * @typedef {{
15
- * readonly readdir: (path: string, options: Options) => Promise<readonly Dirent[]>
16
- * readonly readFile: (path: string, options: 'utf8') => Promise<string>
17
- * }} FsPromises
18
- */
19
- /**
20
- * @typedef {{
21
- * readonly default?: unknown
22
- * }} Module
23
- */
24
- /** @typedef {(name: string) => unknown} Require */
25
- /**
26
- * @typedef {{
27
- * readonly[k in string]: unknown
28
- * }} UnknownMap
29
- */
30
- /**
31
- * @template T
32
- * @typedef {readonly[string, T]} Entry
33
- */
34
- /** @type {(a: Entry<unknown>, b: Entry<unknown>) => number} */
35
- const cmp = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
36
- /**
37
- * @typedef {{
38
- * [k in string]: Module
39
- * }} MutableModuleMap
40
- */
41
- /**
42
- * @typedef {{
43
- * readonly[k in string]: Module
44
- * }} ModuleMap
45
- */
46
- /** @type {(v: readonly string[]) => (dif: number) => readonly string[]} */
47
- const remove_tail = v => dif => v.slice(0, v.length - dif);
48
- /** @type {any} */
49
- const self = globalThis;
50
- /** @type {(code: number) => never} */
51
- export const exit = self.Deno ? self.Deno.exit : process.exit;
52
- /** @type {(v: string) => string|undefined} */
53
- export const env = self.Deno ? self.Deno.env.get :
54
- a => {
55
- const r = Object.getOwnPropertyDescriptor(process.env, a);
56
- return r === void 0 ? void 0 :
57
- typeof r.get === 'function' ? r.get() :
58
- r.value;
59
- };
60
- export const loadModuleMap = async () => {
61
- /** @type {() => Promise<UnknownMap>} */
62
- const load = async () => {
63
- /** @type {(readonly[string, unknown])[]} */
64
- const map = [];
65
- /** @type {(path: string) => Promise<void>} */
66
- const f = async (p) => {
67
- for (const i of await readdir(p, { withFileTypes: true })) {
68
- const { name } = i;
69
- if (!name.startsWith('.')) {
70
- const file = `${p}/${name}`;
71
- if (i.isDirectory()) {
72
- await f(file);
73
- }
74
- else if (name.endsWith('.f.mjs') || name.endsWith('.f.js')) {
75
- const source = await import(`../${file}`);
76
- map.push([file, source.default]);
77
- }
78
- }
79
- }
80
- };
81
- await f('.');
82
- map.sort(cmp);
83
- return Object.fromEntries(map);
84
- };
85
- const map = await load();
86
- /** @type {() => ModuleMap} */
87
- const build = () => {
88
- /** @type {MutableModuleMap} */
89
- const d = {};
90
- /** @type {(base: readonly string[]) => (k: string) => readonly[string, Module]} */
91
- const getModule = base => k => {
92
- const relativePath = k.split('/');
93
- const dif = relativePath.filter(v => v === '..').length;
94
- const path = [remove_tail(base)(dif), relativePath.filter(v => !['..', '.'].includes(v))]
95
- .flat();
96
- const pathStr = path.join('/');
97
- {
98
- const module = d[pathStr];
99
- if (module !== void 0) {
100
- return [pathStr, module];
101
- }
102
- }
103
- {
104
- /** @type {Module} */
105
- const module = { default: map[pathStr] };
106
- d[pathStr] = module;
107
- return [pathStr, module];
108
- }
109
- };
110
- {
111
- const get = getModule(['.']);
112
- for (const k of Object.keys(map)) {
113
- get(k);
114
- }
115
- }
116
- return d;
117
- };
118
- return build();
119
- };
120
- /**
121
- * @typedef {{
122
- * readonly[k in string]: string | FolderMap
123
- * }} FolderMap
124
- */
125
- /** @type {(m: FolderMap) => (s: readonly string[]) => FolderMap } */
126
- const folderMapAdd = m => s => {
127
- const [first, ...rest] = s;
128
- const firstResult = m[first];
129
- return typeof firstResult === 'string'
130
- ? m
131
- : {
132
- ...m,
133
- [first]: rest.length === 1
134
- ? rest[0]
135
- : folderMapAdd(firstResult === undefined ? {} : firstResult)(rest)
136
- };
137
- };
138
- const indent = ' ';
139
- /** @type {(i: string) => (p: string) => (m: FolderMap) => readonly[string,string]} */
140
- const codeAdd = i => p => m => {
141
- let result = '';
142
- let im = '';
143
- for (const [k, v] of Object.entries(m)) {
144
- const np = `${p}${k}`;
145
- if (typeof v === 'string') {
146
- result += `${i}${k}: ${np},\n`;
147
- im += `import ${np} from './${np.replaceAll('$', '/')}/${v}'\n`;
148
- }
149
- else {
150
- const [r, x] = codeAdd(i + indent)(`${np}\$`)(v);
151
- result += `${i}${k}: \{\n`;
152
- result += r;
153
- result += `${i}\},\n`;
154
- im += x;
155
- }
156
- }
157
- return [result, im];
158
- };
159
- export const index = async () => {
160
- const jj = './jsr.json';
161
- const n = '/module.f.mjs';
162
- const jsr_json = JSON.parse(await readFile(jj, { encoding: 'utf8' }));
163
- const list = Object.keys(await loadModuleMap()).filter(v => v.endsWith(n));
164
- const exportsA = list.filter(v => !v.startsWith('./out')).map(v => [v.replace(n, ''), `./out/${v.substring(2)}`]);
165
- const exports = Object.fromEntries(exportsA);
166
- await writeFile(jj, JSON.stringify({ ...jsr_json, exports }, null, 2));
167
- };
@@ -1,25 +0,0 @@
1
- declare const _default: <T>(input: Input<T>) => readonly [number, T];
2
- export default _default;
3
- export type DependencyMap = { readonly [k in string]?: Module; };
4
- export type Module = {
5
- readonly default?: unknown;
6
- };
7
- export type ModuleMap = { readonly [k in string]: Module; };
8
- export type Log<T> = (v: string) => (state: T) => T;
9
- export type Measure<T> = <R>(f: () => R) => (state: T) => readonly [R, number, T];
10
- export type Input<T> = {
11
- readonly moduleMap: ModuleMap;
12
- readonly log: Log<T>;
13
- readonly error: Log<T>;
14
- readonly measure: Measure<T>;
15
- readonly state: T;
16
- readonly tryCatch: <R>(f: () => R) => Result.Result<R, unknown>;
17
- readonly env: (n: string) => string | undefined;
18
- };
19
- export type TestState = {
20
- readonly time: number;
21
- readonly pass: number;
22
- readonly fail: number;
23
- };
24
- export type FullState<T> = readonly [TestState, T];
25
- import * as Result from '../../types/result/module.f.mjs';
@@ -1,134 +0,0 @@
1
- // @ts-self-types="./module.f.d.mts"
2
- import * as list from '../../types/list/module.f.mjs';
3
- const { fold } = list;
4
- import * as sgr from '../../text/sgr/module.f.mjs';
5
- const { reset, fgGreen, fgRed, bold } = sgr.codes;
6
- import * as Result from '../../types/result/module.f.mjs';
7
- /**
8
- * @typedef {{
9
- * readonly[k in string]?: Module
10
- * }} DependencyMap
11
- */
12
- /**
13
- * @typedef {{
14
- * readonly default?: unknown
15
- * }} Module
16
- */
17
- /**
18
- * @typedef {{
19
- * readonly[k in string]: Module
20
- * }} ModuleMap
21
- */
22
- /**
23
- * @template T
24
- * @typedef {(v: string) => (state: T) => T} Log
25
- */
26
- /**
27
- * @template T
28
- * @typedef {<R>(f: () => R) => (state: T) => readonly[R, number, T]} Measure
29
- */
30
- /**
31
- * @template T
32
- * @typedef {{
33
- * readonly moduleMap: ModuleMap,
34
- * readonly log: Log<T>,
35
- * readonly error: Log<T>,
36
- * readonly measure: Measure<T>,
37
- * readonly state: T,
38
- * readonly tryCatch: <R>(f: () => R) => Result.Result<R, unknown>,
39
- * readonly env: (n: string) => string|undefined
40
- * }} Input
41
- */
42
- /** @type {(s: string) => boolean} */
43
- const isTest = s => s.endsWith('test.f.mjs') || s.endsWith('test.f.js');
44
- /**
45
- * @typedef {{
46
- * readonly time: number,
47
- * readonly pass: number,
48
- * readonly fail: number,
49
- * }} TestState
50
- */
51
- /** @type {(time: number) => (testState: TestState) => TestState} */
52
- const addPass = delta => ts => ({ ...ts, time: ts.time + delta, pass: ts.pass + 1 });
53
- /** @type {(time: number) => (testState: TestState) => TestState} */
54
- const addFail = delta => ts => ({ ...ts, time: ts.time + delta, fail: ts.fail + 1 });
55
- /**
56
- * @template T
57
- * @typedef {readonly[TestState, T]} FullState
58
- */
59
- /** @type {(a: number) => string} */
60
- const timeFormat = a => {
61
- const y = Math.round(a * 10_000).toString();
62
- const yl = 5 - y.length;
63
- const x = '0'.repeat(yl > 0 ? yl : 0) + y;
64
- const s = x.length - 4;
65
- const b = x.substring(0, s);
66
- const e = x.substring(s);
67
- return `${b}.${e} ms`;
68
- };
69
- /** @type {<T>(input: Input<T>) => readonly[number, T]} */
70
- export default input => {
71
- let { moduleMap, log, error, measure, tryCatch, env, state } = input;
72
- const isGitHub = env('GITHUB_ACTION') !== void 0;
73
- /** @typedef {input extends Input<infer T> ? T : never} T */
74
- /** @type {(k: readonly[string, Module]) => (fs: FullState<T>) => FullState<T>} */
75
- const f = ([k, v]) => {
76
- /** @type {(i: string) => (v: unknown) => (fs: FullState<T>) => FullState<T>} */
77
- const test = i => v => ([ts, state]) => {
78
- const next = test(`${i}| `);
79
- switch (typeof v) {
80
- case 'function': {
81
- if (v.length === 0) {
82
- const [[s, r], delta, state0] = measure(() => tryCatch(/** @type {() => unknown} */ (v)))(state);
83
- state = state0;
84
- if (s === 'error') {
85
- ts = addFail(delta)(ts);
86
- if (isGitHub) {
87
- // https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions
88
- // https://github.com/OndraM/ci-detector/blob/main/src/Ci/GitHubActions.php
89
- state = error(`::error file=${k},line=1,title=[3]['a']()::${r}`)(state);
90
- }
91
- else {
92
- state = error(`${i}() ${fgRed}error${reset}, ${timeFormat(delta)}`)(state);
93
- state = error(`${fgRed}${r}${reset}`)(state);
94
- }
95
- }
96
- else {
97
- ts = addPass(delta)(ts);
98
- state = log(`${i}() ${fgGreen}ok${reset}, ${timeFormat(delta)}`)(state);
99
- }
100
- [ts, state] = next(r)([ts, state]);
101
- }
102
- break;
103
- }
104
- case 'object': {
105
- if (v !== null) {
106
- /** @type {(k: readonly[string|number, unknown]) => (fs: FullState<T>) => FullState<T>} */
107
- const f = ([k, v]) => ([time, state]) => {
108
- state = log(`${i}${k}:`)(state);
109
- [time, state] = next(v)([time, state]);
110
- return [time, state];
111
- };
112
- [ts, state] = fold(f)([ts, state])(v instanceof Array ? list.entries(v) : Object.entries(v));
113
- }
114
- break;
115
- }
116
- }
117
- return [ts, state];
118
- };
119
- return ([ts, state]) => {
120
- if (isTest(k)) {
121
- state = log(`testing ${k}`)(state);
122
- [ts, state] = test('| ')(v.default)([ts, state]);
123
- }
124
- return [ts, state];
125
- };
126
- };
127
- /** @type {TestState} */
128
- let ts = { time: 0, pass: 0, fail: 0 };
129
- [ts, state] = fold(f)([ts, state])(Object.entries(moduleMap));
130
- const fgFail = ts.fail === 0 ? fgGreen : fgRed;
131
- state = log(`${bold}Number of tests: pass: ${fgGreen}${ts.pass}${reset}${bold}, fail: ${fgFail}${ts.fail}${reset}${bold}, total: ${ts.pass + ts.fail}${reset}`)(state);
132
- state = log(`${bold}Time: ${timeFormat(ts.time)}${reset}`)(state);
133
- return [ts.fail !== 0 ? 1 : 0, state];
134
- };
@@ -1,3 +0,0 @@
1
- export type Ok<T> = readonly ["ok", T];
2
- export type Error<E> = readonly ["error", E];
3
- export type Result<T, E> = Ok<T> | Error<E>;
@@ -1,9 +0,0 @@
1
- declare namespace _default {
2
- function ctor(): void;
3
- function ctorEmpty(): void;
4
- function ctorUndefined(): void;
5
- function number(): void;
6
- function properties(): void;
7
- function getOwnPropertyDescriptor(): void;
8
- }
9
- export default _default;