functionalscript 0.1.609 → 0.2.1

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 (393) hide show
  1. package/com/cpp/module.f.mjs +20 -25
  2. package/com/cpp/testlib.f.mjs +3 -4
  3. package/com/cs/module.f.mjs +18 -23
  4. package/com/cs/testlib.f.mjs +3 -5
  5. package/com/rust/module.f.mjs +25 -30
  6. package/com/rust/testlib.f.mjs +3 -5
  7. package/com/test/build.f.mjs +2 -2
  8. package/com/test/build.mjs +4 -4
  9. package/com/types/module.f.mjs +5 -12
  10. package/commonjs/build/module.f.mjs +23 -28
  11. package/commonjs/build/test.f.mjs +4 -4
  12. package/commonjs/module/function/module.f.mjs +0 -2
  13. package/commonjs/module/module.f.mjs +2 -9
  14. package/commonjs/module.f.mjs +0 -2
  15. package/commonjs/module.mjs +2 -7
  16. package/commonjs/package/dependencies/module.f.mjs +5 -10
  17. package/commonjs/package/dependencies/test.f.mjs +1 -1
  18. package/commonjs/package/module.f.mjs +6 -13
  19. package/commonjs/package/test.f.mjs +1 -1
  20. package/commonjs/path/module.f.mjs +12 -23
  21. package/commonjs/path/test.f.mjs +11 -11
  22. package/commonjs/test.mjs +1 -1
  23. package/dev/module.f.mjs +1 -4
  24. package/dev/module.mjs +1 -1
  25. package/dev/test/module.f.mjs +4 -6
  26. package/djs/module.f.mjs +12 -19
  27. package/djs/parser/module.f.mjs +18 -24
  28. package/djs/parser/test.f.mjs +9 -9
  29. package/djs/test.f.mjs +4 -4
  30. package/djs/tokenizer/module.f.mjs +18 -23
  31. package/djs/tokenizer/test.f.mjs +6 -6
  32. package/fsc/module.f.mjs +17 -24
  33. package/fsc/test.f.mjs +3 -3
  34. package/fsm/module.f.mjs +27 -38
  35. package/fsm/test.f.mjs +8 -8
  36. package/html/module.f.mjs +14 -23
  37. package/html/test.f.mjs +4 -4
  38. package/js/tokenizer/module.f.mjs +55 -62
  39. package/js/tokenizer/test.f.mjs +6 -6
  40. package/json/module.f.mjs +18 -31
  41. package/json/parser/module.f.mjs +9 -14
  42. package/json/parser/test.f.mjs +7 -7
  43. package/json/serializer/module.f.mjs +14 -29
  44. package/json/serializer/test.f.mjs +2 -2
  45. package/json/test.f.mjs +3 -3
  46. package/json/tokenizer/module.f.mjs +14 -19
  47. package/json/tokenizer/test.f.mjs +6 -6
  48. package/jsr.json +59 -59
  49. package/nodejs/version/main.mjs +1 -1
  50. package/nodejs/version/module.f.mjs +2 -7
  51. package/nodejs/version/test.f.mjs +3 -3
  52. package/out/com/cpp/module.f.d.mts +4 -0
  53. package/out/com/cpp/module.f.mjs +123 -0
  54. package/out/com/cpp/test.f.mjs +40 -0
  55. package/out/com/cpp/testlib.f.mjs +7 -0
  56. package/out/com/cs/module.f.d.mts +4 -0
  57. package/out/com/cs/module.f.mjs +95 -0
  58. package/out/com/cs/test.f.mjs +43 -0
  59. package/out/com/cs/testlib.f.mjs +7 -0
  60. package/{com → out/com}/rust/module.f.d.mts +3 -7
  61. package/out/com/rust/module.f.mjs +213 -0
  62. package/out/com/rust/test.f.mjs +123 -0
  63. package/out/com/rust/testlib.f.mjs +7 -0
  64. package/{com → out/com}/test/build.f.d.mts +2 -2
  65. package/out/com/test/build.f.mjs +98 -0
  66. package/out/com/test/build.mjs +40 -0
  67. package/{com → out/com}/types/module.f.d.mts +5 -10
  68. package/out/com/types/module.f.mjs +51 -0
  69. package/out/com/types/testlib.f.mjs +30 -0
  70. package/out/commonjs/build/module.f.d.mts +20 -0
  71. package/out/commonjs/build/module.f.mjs +107 -0
  72. package/out/commonjs/build/test.f.mjs +102 -0
  73. package/{commonjs → out/commonjs}/module/function/module.f.d.mts +0 -2
  74. package/out/commonjs/module/function/module.f.mjs +15 -0
  75. package/{commonjs → out/commonjs}/module/module.f.d.mts +16 -21
  76. package/out/commonjs/module/module.f.mjs +48 -0
  77. package/out/commonjs/module.d.mts +3 -0
  78. package/{commonjs → out/commonjs}/module.f.d.mts +0 -2
  79. package/out/commonjs/module.f.mjs +10 -0
  80. package/out/commonjs/module.mjs +26 -0
  81. package/out/commonjs/package/dependencies/module.f.d.mts +6 -0
  82. package/out/commonjs/package/dependencies/module.f.mjs +21 -0
  83. package/out/commonjs/package/dependencies/test.f.mjs +15 -0
  84. package/out/commonjs/package/module.f.d.mts +21 -0
  85. package/out/commonjs/package/module.f.mjs +40 -0
  86. package/out/commonjs/package/test.f.mjs +27 -0
  87. package/{commonjs → out/commonjs}/path/module.f.d.mts +25 -32
  88. package/out/commonjs/path/module.f.mjs +171 -0
  89. package/out/commonjs/path/test.f.mjs +231 -0
  90. package/out/commonjs/test.mjs +87 -0
  91. package/out/dev/index.mjs +2 -0
  92. package/out/dev/module.f.d.mts +1 -0
  93. package/out/dev/module.f.mjs +2 -0
  94. package/out/dev/module.mjs +167 -0
  95. package/{dev → out/dev}/test/module.f.d.mts +2 -3
  96. package/out/dev/test/module.f.mjs +134 -0
  97. package/out/dev/test.f.mjs +58 -0
  98. package/out/dev/test.mjs +52 -0
  99. package/{djs → out/djs}/module.f.d.mts +13 -18
  100. package/out/djs/module.f.mjs +75 -0
  101. package/{djs → out/djs}/parser/module.f.d.mts +11 -15
  102. package/out/djs/parser/module.f.mjs +432 -0
  103. package/out/djs/parser/test.f.mjs +535 -0
  104. package/out/djs/test.f.mjs +84 -0
  105. package/out/djs/tokenizer/module.f.d.mts +13 -0
  106. package/out/djs/tokenizer/module.f.mjs +87 -0
  107. package/out/djs/tokenizer/test.f.mjs +480 -0
  108. package/out/fsc/module.f.d.mts +7 -0
  109. package/out/fsc/module.f.mjs +105 -0
  110. package/out/fsc/test.f.mjs +19 -0
  111. package/out/fsm/module.f.d.mts +14 -0
  112. package/out/fsm/module.f.mjs +80 -0
  113. package/out/fsm/test.f.mjs +138 -0
  114. package/out/html/module.f.d.mts +15 -0
  115. package/out/html/module.f.mjs +94 -0
  116. package/out/html/test.f.mjs +45 -0
  117. package/out/issues/test.f.mjs +66 -0
  118. package/{js → out/js}/tokenizer/module.f.d.mts +10 -15
  119. package/out/js/tokenizer/module.f.mjs +686 -0
  120. package/out/js/tokenizer/test.f.mjs +844 -0
  121. package/out/json/module.f.d.mts +33 -0
  122. package/out/json/module.f.mjs +89 -0
  123. package/{json → out/json}/parser/module.f.d.mts +9 -13
  124. package/out/json/parser/module.f.mjs +224 -0
  125. package/out/json/parser/test.f.mjs +321 -0
  126. package/out/json/serializer/module.f.d.mts +36 -0
  127. package/out/json/serializer/module.f.mjs +67 -0
  128. package/out/json/serializer/test.f.mjs +87 -0
  129. package/out/json/test.f.mjs +61 -0
  130. package/out/json/tokenizer/module.f.d.mts +13 -0
  131. package/out/json/tokenizer/module.f.mjs +78 -0
  132. package/out/json/tokenizer/test.f.mjs +420 -0
  133. package/out/nanvm-lib/tests/test.f.mjs +87 -0
  134. package/out/nodejs/version/main.mjs +3 -0
  135. package/{nodejs → out/nodejs}/version/module.f.d.mts +4 -9
  136. package/out/nodejs/version/module.f.mjs +34 -0
  137. package/out/nodejs/version/test.f.mjs +97 -0
  138. package/{prime_field → out/prime_field}/module.f.d.mts +20 -23
  139. package/out/prime_field/module.f.mjs +87 -0
  140. package/out/prime_field/test.f.mjs +145 -0
  141. package/{secp → out/secp}/module.f.d.mts +27 -28
  142. package/out/secp/module.f.mjs +113 -0
  143. package/out/secp/test.f.mjs +63 -0
  144. package/out/sha2/module.f.d.mts +15 -0
  145. package/out/sha2/module.f.mjs +172 -0
  146. package/out/sha2/test.f.mjs +86 -0
  147. package/out/text/ascii/module.f.d.mts +70 -0
  148. package/out/text/ascii/module.f.mjs +154 -0
  149. package/out/text/ascii/test.f.mjs +14 -0
  150. package/out/text/module.f.d.mts +13 -0
  151. package/out/text/module.f.mjs +19 -0
  152. package/out/text/sgr/module.f.d.mts +12 -0
  153. package/out/text/sgr/module.f.mjs +17 -0
  154. package/out/text/test.f.mjs +19 -0
  155. package/out/text/utf16/module.f.d.mts +12 -0
  156. package/out/text/utf16/module.f.mjs +86 -0
  157. package/out/text/utf16/test.f.mjs +145 -0
  158. package/out/text/utf8/module.f.d.mts +10 -0
  159. package/out/text/utf8/module.f.mjs +126 -0
  160. package/out/text/utf8/test.f.mjs +175 -0
  161. package/{types → out/types}/array/module.f.d.mts +14 -24
  162. package/out/types/array/module.f.mjs +95 -0
  163. package/out/types/array/test.f.mjs +116 -0
  164. package/out/types/bigfloat/module.f.d.mts +6 -0
  165. package/out/types/bigfloat/module.f.mjs +77 -0
  166. package/out/types/bigfloat/test.f.mjs +349 -0
  167. package/out/types/bigint/module.f.d.mts +29 -0
  168. package/{types/bigint/module.f.d.mts → out/types/bigint/module.f.mjs} +64 -27
  169. package/out/types/bigint/test.f.mjs +192 -0
  170. package/{types → out/types}/btree/find/module.f.d.mts +20 -26
  171. package/out/types/btree/find/module.f.mjs +137 -0
  172. package/out/types/btree/find/test.f.mjs +156 -0
  173. package/out/types/btree/module.f.d.mts +5 -0
  174. package/out/types/btree/module.f.mjs +34 -0
  175. package/{types → out/types}/btree/remove/module.f.d.mts +7 -12
  176. package/out/types/btree/remove/module.f.mjs +209 -0
  177. package/out/types/btree/remove/test.f.mjs +638 -0
  178. package/{types → out/types}/btree/set/module.f.d.mts +3 -7
  179. package/out/types/btree/set/module.f.mjs +114 -0
  180. package/out/types/btree/set/test.f.mjs +390 -0
  181. package/out/types/btree/test.f.mjs +83 -0
  182. package/{types → out/types}/btree/types/module.f.d.mts +0 -2
  183. package/out/types/btree/types/module.f.mjs +50 -0
  184. package/out/types/byte_set/module.f.d.mts +25 -0
  185. package/out/types/byte_set/module.f.mjs +42 -0
  186. package/out/types/byte_set/test.f.mjs +123 -0
  187. package/{types → out/types}/function/compare/module.f.d.mts +9 -15
  188. package/out/types/function/compare/module.f.mjs +22 -0
  189. package/out/types/function/compare/test.f.mjs +8 -0
  190. package/{types → out/types}/function/module.f.d.mts +20 -27
  191. package/out/types/function/module.f.mjs +44 -0
  192. package/{types → out/types}/function/operator/module.f.d.mts +28 -43
  193. package/out/types/function/operator/module.f.mjs +60 -0
  194. package/out/types/function/test.f.mjs +15 -0
  195. package/out/types/list/module.f.d.mts +82 -0
  196. package/out/types/list/module.f.mjs +269 -0
  197. package/out/types/list/test.f.mjs +401 -0
  198. package/out/types/map/module.f.d.mts +21 -0
  199. package/out/types/map/module.f.mjs +54 -0
  200. package/out/types/map/test.f.mjs +115 -0
  201. package/out/types/nibble_set/module.f.d.mts +16 -0
  202. package/out/types/nibble_set/module.f.mjs +19 -0
  203. package/out/types/nibble_set/test.f.mjs +90 -0
  204. package/out/types/nullable/module.f.d.mts +9 -0
  205. package/out/types/nullable/module.f.mjs +9 -0
  206. package/out/types/nullable/test.f.mjs +12 -0
  207. package/out/types/number/module.f.d.mts +7 -0
  208. package/out/types/number/module.f.mjs +12 -0
  209. package/out/types/number/test.f.mjs +126 -0
  210. package/out/types/object/module.f.d.mts +22 -0
  211. package/out/types/object/module.f.mjs +27 -0
  212. package/out/types/object/test.f.mjs +17 -0
  213. package/out/types/range/module.f.d.mts +6 -0
  214. package/out/types/range/module.f.mjs +6 -0
  215. package/out/types/range/test.f.mjs +18 -0
  216. package/{types → out/types}/range_map/module.f.d.mts +9 -15
  217. package/out/types/range_map/module.f.mjs +84 -0
  218. package/out/types/range_map/test.f.mjs +201 -0
  219. package/out/types/result/module.d.mts +7 -0
  220. package/{types → out/types}/result/module.f.d.mts +6 -12
  221. package/out/types/result/module.f.mjs +25 -0
  222. package/out/types/result/module.mjs +16 -0
  223. package/{types → out/types}/sorted_list/module.f.d.mts +22 -28
  224. package/out/types/sorted_list/module.f.mjs +102 -0
  225. package/out/types/sorted_list/test.f.mjs +66 -0
  226. package/{types → out/types}/sorted_set/module.f.d.mts +6 -12
  227. package/out/types/sorted_set/module.f.mjs +29 -0
  228. package/out/types/sorted_set/test.f.mjs +80 -0
  229. package/out/types/string/module.f.d.mts +9 -0
  230. package/out/types/string/module.f.mjs +17 -0
  231. package/out/types/string/test.f.mjs +58 -0
  232. package/out/types/string_set/module.f.d.mts +13 -0
  233. package/out/types/string_set/module.f.mjs +29 -0
  234. package/out/types/string_set/test.f.mjs +65 -0
  235. package/package.json +5 -4
  236. package/prime_field/module.f.mjs +9 -12
  237. package/prime_field/test.f.mjs +1 -1
  238. package/secp/module.f.mjs +38 -39
  239. package/secp/test.f.mjs +4 -4
  240. package/sha2/module.f.mjs +7 -20
  241. package/sha2/test.f.mjs +4 -4
  242. package/text/ascii/module.f.mjs +5 -10
  243. package/text/ascii/test.f.mjs +3 -3
  244. package/text/module.f.mjs +7 -14
  245. package/text/sgr/module.f.mjs +2 -4
  246. package/text/test.f.mjs +3 -3
  247. package/text/utf16/module.f.mjs +17 -28
  248. package/text/utf16/test.f.mjs +5 -5
  249. package/text/utf8/module.f.mjs +9 -16
  250. package/text/utf8/test.f.mjs +4 -4
  251. package/tsconfig.json +2 -2
  252. package/types/array/module.f.mjs +8 -25
  253. package/types/array/test.f.mjs +3 -3
  254. package/types/bigfloat/module.f.mjs +3 -10
  255. package/types/bigfloat/test.f.mjs +1 -1
  256. package/types/bigint/module.f.mjs +11 -30
  257. package/types/bigint/test.f.mjs +1 -1
  258. package/types/btree/find/module.f.mjs +8 -17
  259. package/types/btree/find/test.f.mjs +7 -7
  260. package/types/btree/module.f.mjs +6 -11
  261. package/types/btree/remove/module.f.mjs +10 -17
  262. package/types/btree/remove/test.f.mjs +5 -5
  263. package/types/btree/set/module.f.mjs +4 -9
  264. package/types/btree/set/test.f.mjs +4 -4
  265. package/types/btree/test.f.mjs +9 -9
  266. package/types/btree/types/module.f.mjs +0 -2
  267. package/types/byte_set/module.f.mjs +14 -39
  268. package/types/byte_set/test.f.mjs +5 -5
  269. package/types/function/compare/module.f.mjs +3 -12
  270. package/types/function/compare/test.f.mjs +1 -1
  271. package/types/function/module.f.mjs +4 -15
  272. package/types/function/operator/module.f.mjs +14 -41
  273. package/types/function/test.f.mjs +1 -1
  274. package/types/list/module.f.mjs +45 -114
  275. package/types/list/test.f.mjs +10 -10
  276. package/types/map/module.f.mjs +15 -30
  277. package/types/map/test.f.mjs +2 -2
  278. package/types/nibble_set/module.f.mjs +7 -24
  279. package/types/nibble_set/test.f.mjs +2 -2
  280. package/types/nullable/module.f.mjs +2 -9
  281. package/types/nullable/test.f.mjs +1 -1
  282. package/types/number/module.f.mjs +8 -19
  283. package/types/number/test.f.mjs +1 -1
  284. package/types/object/module.f.mjs +9 -20
  285. package/types/object/test.f.mjs +1 -1
  286. package/types/range/module.f.mjs +2 -9
  287. package/types/range/test.f.mjs +1 -1
  288. package/types/range_map/module.f.mjs +9 -18
  289. package/types/range_map/test.f.mjs +32 -32
  290. package/types/result/module.f.mjs +3 -12
  291. package/types/result/module.mjs +2 -2
  292. package/types/sorted_list/module.f.mjs +10 -19
  293. package/types/sorted_list/test.f.mjs +7 -7
  294. package/types/sorted_set/module.f.mjs +7 -16
  295. package/types/sorted_set/test.f.mjs +7 -7
  296. package/types/string/module.f.mjs +10 -21
  297. package/types/string/test.f.mjs +2 -2
  298. package/types/string_set/module.f.mjs +12 -27
  299. package/types/string_set/test.f.mjs +1 -1
  300. package/com/cpp/module.f.d.mts +0 -8
  301. package/com/cs/module.f.d.mts +0 -8
  302. package/commonjs/build/module.f.d.mts +0 -24
  303. package/commonjs/module.d.mts +0 -7
  304. package/commonjs/package/dependencies/module.f.d.mts +0 -10
  305. package/commonjs/package/module.f.d.mts +0 -27
  306. package/dev/module.f.d.mts +0 -4
  307. package/djs/tokenizer/module.f.d.mts +0 -17
  308. package/fsc/module.f.d.mts +0 -12
  309. package/fsm/module.f.d.mts +0 -21
  310. package/html/module.f.d.mts +0 -20
  311. package/json/module.f.d.mts +0 -41
  312. package/json/serializer/module.f.d.mts +0 -45
  313. package/json/tokenizer/module.f.d.mts +0 -17
  314. package/sha2/module.f.d.mts +0 -23
  315. package/text/ascii/module.f.d.mts +0 -73
  316. package/text/module.f.d.mts +0 -18
  317. package/text/sgr/module.f.d.mts +0 -14
  318. package/text/utf16/module.f.d.mts +0 -19
  319. package/text/utf8/module.f.d.mts +0 -15
  320. package/types/bigfloat/module.f.d.mts +0 -11
  321. package/types/btree/module.f.d.mts +0 -9
  322. package/types/byte_set/module.f.d.mts +0 -38
  323. package/types/list/module.f.d.mts +0 -117
  324. package/types/map/module.f.d.mts +0 -30
  325. package/types/nibble_set/module.f.d.mts +0 -26
  326. package/types/nullable/module.f.d.mts +0 -14
  327. package/types/number/module.f.d.mts +0 -13
  328. package/types/object/module.f.d.mts +0 -29
  329. package/types/range/module.f.d.mts +0 -11
  330. package/types/result/module.d.mts +0 -7
  331. package/types/string/module.f.d.mts +0 -15
  332. package/types/string_set/module.f.d.mts +0 -21
  333. /package/{com → out/com}/cpp/test.f.d.mts +0 -0
  334. /package/{com → out/com}/cpp/testlib.f.d.mts +0 -0
  335. /package/{com → out/com}/cs/test.f.d.mts +0 -0
  336. /package/{com → out/com}/cs/testlib.f.d.mts +0 -0
  337. /package/{com → out/com}/rust/test.f.d.mts +0 -0
  338. /package/{com → out/com}/rust/testlib.f.d.mts +0 -0
  339. /package/{com → out/com}/test/build.d.mts +0 -0
  340. /package/{com → out/com}/types/testlib.f.d.mts +0 -0
  341. /package/{commonjs → out/commonjs}/build/test.f.d.mts +0 -0
  342. /package/{commonjs → out/commonjs}/package/dependencies/test.f.d.mts +0 -0
  343. /package/{commonjs → out/commonjs}/package/test.f.d.mts +0 -0
  344. /package/{commonjs → out/commonjs}/path/test.f.d.mts +0 -0
  345. /package/{commonjs → out/commonjs}/test.d.mts +0 -0
  346. /package/{dev → out/dev}/index.d.mts +0 -0
  347. /package/{dev → out/dev}/module.d.mts +0 -0
  348. /package/{dev → out/dev}/test.d.mts +0 -0
  349. /package/{dev → out/dev}/test.f.d.mts +0 -0
  350. /package/{djs → out/djs}/parser/test.f.d.mts +0 -0
  351. /package/{djs → out/djs}/test.f.d.mts +0 -0
  352. /package/{djs → out/djs}/tokenizer/test.f.d.mts +0 -0
  353. /package/{fsc → out/fsc}/test.f.d.mts +0 -0
  354. /package/{fsm → out/fsm}/test.f.d.mts +0 -0
  355. /package/{html → out/html}/test.f.d.mts +0 -0
  356. /package/{issues → out/issues}/test.f.d.mts +0 -0
  357. /package/{js → out/js}/tokenizer/test.f.d.mts +0 -0
  358. /package/{json → out/json}/parser/test.f.d.mts +0 -0
  359. /package/{json → out/json}/serializer/test.f.d.mts +0 -0
  360. /package/{json → out/json}/test.f.d.mts +0 -0
  361. /package/{json → out/json}/tokenizer/test.f.d.mts +0 -0
  362. /package/{nanvm-lib → out/nanvm-lib}/tests/test.f.d.mts +0 -0
  363. /package/{nodejs → out/nodejs}/version/main.d.mts +0 -0
  364. /package/{nodejs → out/nodejs}/version/test.f.d.mts +0 -0
  365. /package/{prime_field → out/prime_field}/test.f.d.mts +0 -0
  366. /package/{secp → out/secp}/test.f.d.mts +0 -0
  367. /package/{sha2 → out/sha2}/test.f.d.mts +0 -0
  368. /package/{text → out/text}/ascii/test.f.d.mts +0 -0
  369. /package/{text → out/text}/test.f.d.mts +0 -0
  370. /package/{text → out/text}/utf16/test.f.d.mts +0 -0
  371. /package/{text → out/text}/utf8/test.f.d.mts +0 -0
  372. /package/{types → out/types}/array/test.f.d.mts +0 -0
  373. /package/{types → out/types}/bigfloat/test.f.d.mts +0 -0
  374. /package/{types → out/types}/bigint/test.f.d.mts +0 -0
  375. /package/{types → out/types}/btree/find/test.f.d.mts +0 -0
  376. /package/{types → out/types}/btree/remove/test.f.d.mts +0 -0
  377. /package/{types → out/types}/btree/set/test.f.d.mts +0 -0
  378. /package/{types → out/types}/btree/test.f.d.mts +0 -0
  379. /package/{types → out/types}/byte_set/test.f.d.mts +0 -0
  380. /package/{types → out/types}/function/compare/test.f.d.mts +0 -0
  381. /package/{types → out/types}/function/test.f.d.mts +0 -0
  382. /package/{types → out/types}/list/test.f.d.mts +0 -0
  383. /package/{types → out/types}/map/test.f.d.mts +0 -0
  384. /package/{types → out/types}/nibble_set/test.f.d.mts +0 -0
  385. /package/{types → out/types}/nullable/test.f.d.mts +0 -0
  386. /package/{types → out/types}/number/test.f.d.mts +0 -0
  387. /package/{types → out/types}/object/test.f.d.mts +0 -0
  388. /package/{types → out/types}/range/test.f.d.mts +0 -0
  389. /package/{types → out/types}/range_map/test.f.d.mts +0 -0
  390. /package/{types → out/types}/sorted_list/test.f.d.mts +0 -0
  391. /package/{types → out/types}/sorted_set/test.f.d.mts +0 -0
  392. /package/{types → out/types}/string/test.f.d.mts +0 -0
  393. /package/{types → out/types}/string_set/test.f.d.mts +0 -0
@@ -1,25 +1,3 @@
1
- declare namespace _default {
2
- export { prime_field };
3
- export let sqrt: (f: PrimeField) => (a: bigint) => bigint | null;
4
- }
5
- export default _default;
6
- export type Reduce = Operator.Reduce<bigint>;
7
- export type Unary = Operator.Unary<bigint, bigint>;
8
- export type PrimeField = {
9
- readonly p: bigint;
10
- readonly middle: bigint;
11
- readonly max: bigint;
12
- readonly neg: Unary;
13
- readonly sub: Reduce;
14
- readonly add: Reduce;
15
- readonly abs: Unary;
16
- readonly mul: Reduce;
17
- readonly reciprocal: Unary;
18
- readonly div: Reduce;
19
- readonly pow: Reduce;
20
- readonly pow2: Unary;
21
- readonly pow3: Unary;
22
- };
23
1
  /** @typedef {Operator.Reduce<bigint>} Reduce */
24
2
  /** @typedef {Operator.Unary<bigint, bigint>} Unary*/
25
3
  /**
@@ -40,5 +18,24 @@ export type PrimeField = {
40
18
  * }} PrimeField
41
19
  */
42
20
  /** @type {(p: bigint) => PrimeField} */
43
- declare const prime_field: (p: bigint) => PrimeField;
21
+ export const prime_field: (p: bigint) => PrimeField;
22
+ /** @type {(f: PrimeField) => (a: bigint) => bigint|null} */
23
+ export const sqrt: (f: PrimeField) => (a: bigint) => bigint | null;
24
+ export type Reduce = Operator.Reduce<bigint>;
25
+ export type Unary = Operator.Unary<bigint, bigint>;
26
+ export type PrimeField = {
27
+ readonly p: bigint;
28
+ readonly middle: bigint;
29
+ readonly max: bigint;
30
+ readonly neg: Unary;
31
+ readonly sub: Reduce;
32
+ readonly add: Reduce;
33
+ readonly abs: Unary;
34
+ readonly mul: Reduce;
35
+ readonly reciprocal: Unary;
36
+ readonly div: Reduce;
37
+ readonly pow: Reduce;
38
+ readonly pow2: Unary;
39
+ readonly pow3: Unary;
40
+ };
44
41
  import * as Operator from '../types/function/operator/module.f.mjs';
@@ -0,0 +1,87 @@
1
+ // @ts-self-types="./module.f.d.mts"
2
+ import * as Operator from '../types/function/operator/module.f.mjs';
3
+ import * as bi from '../types/bigint/module.f.mjs';
4
+ const { scalar_mul } = bi;
5
+ /** @typedef {Operator.Reduce<bigint>} Reduce */
6
+ /** @typedef {Operator.Unary<bigint, bigint>} Unary*/
7
+ /**
8
+ * @typedef {{
9
+ * readonly p: bigint
10
+ * readonly middle: bigint
11
+ * readonly max: bigint
12
+ * readonly neg: Unary
13
+ * readonly sub: Reduce
14
+ * readonly add: Reduce
15
+ * readonly abs: Unary
16
+ * readonly mul: Reduce
17
+ * readonly reciprocal: Unary
18
+ * readonly div: Reduce
19
+ * readonly pow: Reduce
20
+ * readonly pow2: Unary
21
+ * readonly pow3: Unary
22
+ * }} PrimeField
23
+ */
24
+ /** @type {(p: bigint) => PrimeField} */
25
+ export const prime_field = p => {
26
+ /** @type {Reduce} */
27
+ const sub = a => b => {
28
+ const r = a - b;
29
+ return r < 0 ? r + p : r;
30
+ };
31
+ /** @type {Reduce} */
32
+ const mul = a => b => a * b % p;
33
+ /** @type {Unary} */
34
+ const reciprocal = a => {
35
+ if (a === 0n) {
36
+ throw '1/0';
37
+ }
38
+ let a1 = a;
39
+ let a0 = p;
40
+ let f0 = 0n;
41
+ let f1 = 1n;
42
+ while (a1 !== 1n) {
43
+ const q = a0 / a1;
44
+ const a2 = a0 % a1;
45
+ a0 = a1;
46
+ a1 = a2;
47
+ const f2 = sub(f0)(mul(f1)(q));
48
+ f0 = f1;
49
+ f1 = f2;
50
+ }
51
+ return f1;
52
+ };
53
+ const middle = p >> 1n;
54
+ /** @type {Unary} */
55
+ const pow2 = a => mul(a)(a);
56
+ /** @type {Reduce} */
57
+ const pow = scalar_mul({ 0: 1n, add: mul });
58
+ return {
59
+ p,
60
+ middle,
61
+ max: p - 1n,
62
+ neg: a => a === 0n ? 0n : p - a,
63
+ sub,
64
+ add: a => b => {
65
+ const r = a + b;
66
+ return r < p ? r : r - p;
67
+ },
68
+ abs: a => middle < a ? p - a : a,
69
+ mul,
70
+ reciprocal,
71
+ div: a => b => mul(a)(reciprocal(b)),
72
+ pow,
73
+ pow2,
74
+ pow3: a => mul(a)(pow2(a))
75
+ };
76
+ };
77
+ /** @type {(f: PrimeField) => (a: bigint) => bigint|null} */
78
+ export const sqrt = ({ p, mul, pow }) => {
79
+ if ((p & 3n) !== 3n) {
80
+ throw 'sqrt';
81
+ }
82
+ const sqrt_k = (p + 1n) >> 2n;
83
+ return a => {
84
+ const result = pow(a)(sqrt_k);
85
+ return mul(result)(result) === a ? result : null;
86
+ };
87
+ };
@@ -0,0 +1,145 @@
1
+ import * as _ from './module.f.mjs';
2
+ const { prime_field, sqrt } = _;
3
+ export default {
4
+ prime_field_test: () => {
5
+ const p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn;
6
+ const f = prime_field(p);
7
+ const sqrt_f = sqrt(f);
8
+ return {
9
+ neg: () => {
10
+ if (f.neg(0n) !== 0n) {
11
+ throw '-0';
12
+ }
13
+ if (f.neg(1n) !== p - 1n) {
14
+ throw '-1';
15
+ }
16
+ },
17
+ sub: () => {
18
+ if (f.sub(10n)(4n) !== 6n) {
19
+ throw '10 - 4';
20
+ }
21
+ if (f.sub(11n)(14n) !== p - 3n) {
22
+ throw '11 - 14';
23
+ }
24
+ },
25
+ add: () => {
26
+ if (f.add(13n)(24n) !== 37n) {
27
+ throw '13 + 24';
28
+ }
29
+ if (f.add(77n)(f.neg(12n)) !== 65n) {
30
+ throw '77 + (-12)';
31
+ }
32
+ },
33
+ mul: () => {
34
+ if (f.mul(100n)(0n) !== 0n) {
35
+ throw '100 * 0';
36
+ }
37
+ if (f.mul(101n)(205n) !== 20705n) {
38
+ throw '101 * 205';
39
+ }
40
+ if (f.mul(304n)(f.neg(1n)) !== f.neg(304n)) {
41
+ throw '304 * -1';
42
+ }
43
+ if (f.mul(f.neg(507n))(609n) !== f.neg(308763n)) {
44
+ throw '-507 * 609';
45
+ }
46
+ if (f.mul(f.neg(713n))(f.neg(825n)) !== 588225n) {
47
+ throw '-713 * -825';
48
+ }
49
+ },
50
+ reciprocal: () => {
51
+ let i = 1n;
52
+ while (i < 10000n) {
53
+ const x = f.reciprocal(i);
54
+ if (f.mul(x)(i) !== 1n) {
55
+ throw i;
56
+ }
57
+ ++i;
58
+ }
59
+ },
60
+ pow: () => {
61
+ /** @type {(a: bigint) => void} */
62
+ const test = a => {
63
+ if (f.pow(a)(0n) !== 1n) {
64
+ throw '**0';
65
+ }
66
+ if (f.pow(a)(1n) !== a) {
67
+ throw '**1';
68
+ }
69
+ // https://en.wikipedia.org/wiki/Fermat%27s_little_theorem
70
+ // a^(p-1) % p = 1
71
+ if (f.abs(f.pow(a)(f.middle)) !== 1n) {
72
+ throw '**middle';
73
+ }
74
+ if (f.pow(a)(f.sub(f.max)(1n)) !== f.reciprocal(a)) {
75
+ throw '**(max-1)';
76
+ }
77
+ if (f.pow(a)(f.max) !== 1n) {
78
+ throw '**max';
79
+ }
80
+ };
81
+ // 0
82
+ if (f.pow(0n)(0n) !== 1n) {
83
+ throw '0**0';
84
+ }
85
+ if (f.pow(0n)(f.max) !== 0n) {
86
+ throw '0**max';
87
+ }
88
+ // 1
89
+ test(1n);
90
+ // 2
91
+ test(2n);
92
+ if (f.pow(2n)(2n) !== 4n) {
93
+ throw '2**2';
94
+ }
95
+ if (f.pow(2n)(3n) !== 8n) {
96
+ throw '2**3';
97
+ }
98
+ if (f.pow(2n)(128n) !== 1n << 128n) {
99
+ throw '2**128';
100
+ }
101
+ // 3
102
+ test(3n);
103
+ if (f.pow(3n)(2n) !== 9n) {
104
+ throw '3**2';
105
+ }
106
+ if (f.pow(3n)(3n) !== 27n) {
107
+ throw '3**3';
108
+ }
109
+ if (f.pow(3n)(100n) !== 3n ** 100n) {
110
+ throw '3**100';
111
+ }
112
+ if (f.pow(3n)(110n) !== 3n ** 110n) {
113
+ throw '3**110';
114
+ }
115
+ if (f.pow(3n)(120n) !== 3n ** 120n) {
116
+ throw '3**120';
117
+ }
118
+ if (f.pow(3n)(121n) !== 3n ** 121n) {
119
+ throw '3**121';
120
+ }
121
+ //
122
+ test(f.middle);
123
+ test(f.max - 1n);
124
+ test(f.max);
125
+ },
126
+ sqrt: () => {
127
+ /** @type {(a: bigint) => void} */
128
+ const test = a => {
129
+ const a2 = f.mul(a)(a);
130
+ const s = sqrt_f(a2);
131
+ if (s !== null && f.abs(s) !== f.abs(a)) {
132
+ throw 'sqrt';
133
+ }
134
+ };
135
+ let i = 1n;
136
+ while (i < 1000n) {
137
+ test(i);
138
+ ++i;
139
+ }
140
+ test(f.middle);
141
+ test(f.max);
142
+ }
143
+ };
144
+ }
145
+ };
@@ -1,27 +1,3 @@
1
- declare namespace _default {
2
- export { curve };
3
- export let eq: (a: Point) => (b: Point) => boolean;
4
- export let secp256k1: Init;
5
- export let secp192r1: Init;
6
- }
7
- export default _default;
8
- export type Point2D = readonly [bigint, bigint];
9
- export type Point = Point2D | null;
10
- export type Init = {
11
- readonly p: bigint;
12
- readonly a: readonly [bigint, bigint];
13
- readonly g: readonly [bigint, bigint];
14
- readonly n: bigint;
15
- };
16
- export type Curve = {
17
- readonly pf: Pf.PrimeField;
18
- readonly nf: Pf.PrimeField;
19
- readonly y2: (x: bigint) => bigint;
20
- readonly y: (x: bigint) => bigint | null;
21
- readonly neg: (a: Point) => Point;
22
- readonly add: Operator.Reduce<Point>;
23
- readonly mul: (a: Point) => (n: bigint) => Point;
24
- };
25
1
  /** @typedef {readonly[bigint, bigint]} Point2D */
26
2
  /** @typedef {Point2D|null} Point */
27
3
  /**
@@ -34,8 +10,8 @@ export type Curve = {
34
10
  */
35
11
  /**
36
12
  * @typedef {{
37
- * readonly pf: Pf.PrimeField
38
- * readonly nf: Pf.PrimeField
13
+ * readonly pf: pf.PrimeField
14
+ * readonly nf: pf.PrimeField
39
15
  * readonly y2: (x: bigint) => bigint
40
16
  * readonly y: (x: bigint) => bigint|null
41
17
  * readonly neg: (a: Point) => Point
@@ -44,6 +20,29 @@ export type Curve = {
44
20
  * }} Curve
45
21
  */
46
22
  /** @type {(i: Init) => Curve} */
47
- declare const curve: (i: Init) => Curve;
48
- import * as Pf from '../prime_field/module.f.mjs';
23
+ export const curve: (i: Init) => Curve;
24
+ /** @type {(a: Point) => (b: Point) => boolean} */
25
+ export const eq: (a: Point) => (b: Point) => boolean;
26
+ /** @type {Init} */
27
+ export const secp256k1: Init;
28
+ /** @type {Init} */
29
+ export const secp192r1: Init;
30
+ export type Point2D = readonly [bigint, bigint];
31
+ export type Point = Point2D | null;
32
+ export type Init = {
33
+ readonly p: bigint;
34
+ readonly a: readonly [bigint, bigint];
35
+ readonly g: readonly [bigint, bigint];
36
+ readonly n: bigint;
37
+ };
38
+ export type Curve = {
39
+ readonly pf: pf.PrimeField;
40
+ readonly nf: pf.PrimeField;
41
+ readonly y2: (x: bigint) => bigint;
42
+ readonly y: (x: bigint) => bigint | null;
43
+ readonly neg: (a: Point) => Point;
44
+ readonly add: Operator.Reduce<Point>;
45
+ readonly mul: (a: Point) => (n: bigint) => Point;
46
+ };
47
+ import * as pf from '../prime_field/module.f.mjs';
49
48
  import * as Operator from '../types/function/operator/module.f.mjs';
@@ -0,0 +1,113 @@
1
+ // @ts-self-types="./module.f.d.mts"
2
+ import * as Operator from '../types/function/operator/module.f.mjs';
3
+ import * as pf from '../prime_field/module.f.mjs';
4
+ import * as bi from '../types/bigint/module.f.mjs';
5
+ const { scalar_mul } = bi;
6
+ const { prime_field, sqrt } = pf;
7
+ /** @typedef {readonly[bigint, bigint]} Point2D */
8
+ /** @typedef {Point2D|null} Point */
9
+ /**
10
+ * @typedef {{
11
+ * readonly p: bigint
12
+ * readonly a: readonly[bigint, bigint]
13
+ * readonly g: readonly[bigint, bigint]
14
+ * readonly n: bigint
15
+ * }} Init
16
+ */
17
+ /**
18
+ * @typedef {{
19
+ * readonly pf: pf.PrimeField
20
+ * readonly nf: pf.PrimeField
21
+ * readonly y2: (x: bigint) => bigint
22
+ * readonly y: (x: bigint) => bigint|null
23
+ * readonly neg: (a: Point) => Point
24
+ * readonly add: Operator.Reduce<Point>
25
+ * readonly mul: (a: Point) => (n: bigint) => Point
26
+ * }} Curve
27
+ */
28
+ /** @type {(i: Init) => Curve} */
29
+ export const curve = ({ p, a: [a0, a1], n }) => {
30
+ const pf = prime_field(p);
31
+ const { pow2, pow3, sub, add, mul, neg, div } = pf;
32
+ const mul3 = mul(3n);
33
+ const mul2 = mul(2n);
34
+ const addA1 = add(a1);
35
+ const mulA1 = mul(a1);
36
+ const addA0 = add(a0);
37
+ // y**2 = a1*x**3 + a0
38
+ /** @type {(x: bigint) => bigint} */
39
+ const y2 = x => addA0(add(pow3(x))(mulA1(x)));
40
+ /** @type {Operator.Reduce<Point>} */
41
+ const addPoint = p => q => {
42
+ if (p === null) {
43
+ return q;
44
+ }
45
+ if (q === null) {
46
+ return p;
47
+ }
48
+ const [px, py] = p;
49
+ const [qx, qy] = q;
50
+ const md = px === qx
51
+ // (3 * px ** 2 + a1) / (2 * py)
52
+ ? py !== qy || py === 0n ? null : [addA1(mul3(pow2(px))), mul2(py)]
53
+ // (py - qy) / (px - qx)
54
+ : [sub(py)(qy), sub(px)(qx)];
55
+ if (md === null) {
56
+ return null;
57
+ }
58
+ const [ma, mb] = md;
59
+ const m = div(ma)(mb);
60
+ // m ** 2 - px - qx
61
+ const rx = sub(pow2(m))(add(px)(qx));
62
+ // [rx, m * (px - rx) - py]
63
+ return [rx, sub(mul(m)(sub(px)(rx)))(py)];
64
+ };
65
+ const sqrt_p = sqrt(pf);
66
+ return {
67
+ pf,
68
+ nf: prime_field(n),
69
+ y2,
70
+ y: x => sqrt_p(y2(x)),
71
+ neg: p => {
72
+ if (p === null) {
73
+ return null;
74
+ }
75
+ const [x, y] = p;
76
+ return [x, neg(y)];
77
+ },
78
+ add: addPoint,
79
+ mul: scalar_mul({ 0: null, add: addPoint })
80
+ };
81
+ };
82
+ /** @type {(a: Point) => (b: Point) => boolean} */
83
+ export const eq = a => b => {
84
+ if (a === null || b === null) {
85
+ return a === b;
86
+ }
87
+ const [ax, ay] = a;
88
+ const [bx, by] = b;
89
+ return ax === bx && ay === by;
90
+ };
91
+ /** @type {Init} */
92
+ export const secp256k1 = {
93
+ p: 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,
94
+ a: [7n, 0n],
95
+ g: [
96
+ 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,
97
+ 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n
98
+ ],
99
+ n: 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,
100
+ };
101
+ /** @type {Init} */
102
+ export const secp192r1 = {
103
+ p: 0xfffffffffffffffffffffffffffffffeffffffffffffffffn,
104
+ a: [
105
+ 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1n,
106
+ 0xfffffffffffffffffffffffffffffffefffffffffffffffcn
107
+ ],
108
+ g: [
109
+ 0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012n,
110
+ 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811n
111
+ ],
112
+ n: 0xffffffffffffffffffffffff99def836146bc9b1b4d22831n,
113
+ };
@@ -0,0 +1,63 @@
1
+ import * as _ from './module.f.mjs';
2
+ const { curve, secp256k1, secp192r1, eq } = _;
3
+ export default {
4
+ test: () => {
5
+ /** @type {(c: _.Init) => void} */
6
+ const test_curve = c => {
7
+ const { g } = c;
8
+ const { mul, neg, pf: { abs }, y: yf, nf: { p: n } } = curve(c);
9
+ /** @type {(p: _.Point) => void} */
10
+ const point_check = p => {
11
+ if (p === null) {
12
+ throw 'null';
13
+ }
14
+ const [x, y] = p;
15
+ const ye = yf(x);
16
+ if (ye === null) {
17
+ throw 'null';
18
+ }
19
+ if (abs(ye) !== abs(y)) {
20
+ throw 'ye';
21
+ }
22
+ };
23
+ point_check(g);
24
+ point_check(neg(g));
25
+ /** @type {(p: _.Point) => void} */
26
+ const test_mul = p => {
27
+ if (mul(p)(0n) !== null) {
28
+ throw 'O';
29
+ }
30
+ if (mul(p)(1n) !== p) {
31
+ throw 'p';
32
+ }
33
+ if (mul(p)(n) !== null) {
34
+ throw 'n';
35
+ }
36
+ const pn = neg(p);
37
+ if (!eq(mul(p)(n - 1n))(pn)) {
38
+ throw 'n - 1';
39
+ }
40
+ /** @type {(s: bigint) => void} */
41
+ const f = s => {
42
+ const r = mul(p)(s);
43
+ point_check(r);
44
+ const rn = mul(pn)(s);
45
+ point_check(rn);
46
+ if (!eq(r)(neg(rn))) {
47
+ throw 'r != -rn';
48
+ }
49
+ };
50
+ f(2n);
51
+ f(3n);
52
+ f(4n << 128n);
53
+ f((5n << 128n) + 6n);
54
+ f(7n << 128n);
55
+ f((8n << 128n) + 9n);
56
+ };
57
+ test_mul(g);
58
+ test_mul(neg(g));
59
+ };
60
+ test_curve(secp256k1);
61
+ test_curve(secp192r1);
62
+ }
63
+ };
@@ -0,0 +1,15 @@
1
+ /** @type {(input: readonly number[]) => (bits: number) => HashInput} */
2
+ export const padding: (input: readonly number[]) => (bits: number) => HashInput;
3
+ /** @type {(input: readonly number[]) => (bitsCount: number) => Hash8} */
4
+ export const computeSha256: (input: readonly number[]) => (bitsCount: number) => Hash8;
5
+ /** @type {(input: readonly number[]) => (bitsCount: number) => Hash8} */
6
+ export const computeSha224: (input: readonly number[]) => (bitsCount: number) => Hash8;
7
+ export const compress256: (data: Array16) => Hash8;
8
+ export const compress224: (data: Array16) => Hash8;
9
+ export type HashInput = {
10
+ readonly f: (i: number) => number;
11
+ readonly length: number;
12
+ };
13
+ export type Hash8 = arrayT.Array8<number>;
14
+ export type Array16 = arrayT.Array16<number>;
15
+ import * as arrayT from '../types/array/module.f.mjs';