@elaraai/east 1.0.79 → 1.0.81

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 (379) hide show
  1. package/README.md +1 -1
  2. package/dist/src/builtins.d.ts +1 -1
  3. package/dist/src/builtins.d.ts.map +1 -1
  4. package/dist/src/builtins.js +19 -0
  5. package/dist/src/builtins.js.map +1 -1
  6. package/dist/src/codegen/spellings.d.ts.map +1 -1
  7. package/dist/src/codegen/spellings.js +3 -0
  8. package/dist/src/codegen/spellings.js.map +1 -1
  9. package/dist/src/comparison.d.ts +54 -0
  10. package/dist/src/comparison.d.ts.map +1 -1
  11. package/dist/src/comparison.equivalent.spec.d.ts +6 -0
  12. package/dist/src/comparison.equivalent.spec.d.ts.map +1 -0
  13. package/dist/src/comparison.equivalent.spec.js +130 -0
  14. package/dist/src/comparison.equivalent.spec.js.map +1 -0
  15. package/dist/src/comparison.js +97 -25
  16. package/dist/src/comparison.js.map +1 -1
  17. package/dist/src/compile/builtins/array.d.ts +60 -0
  18. package/dist/src/compile/builtins/array.d.ts.map +1 -0
  19. package/dist/src/compile/builtins/array.js +691 -0
  20. package/dist/src/compile/builtins/array.js.map +1 -0
  21. package/dist/src/compile/builtins/blob.d.ts +18 -0
  22. package/dist/src/compile/builtins/blob.d.ts.map +1 -0
  23. package/dist/src/compile/builtins/blob.js +150 -0
  24. package/dist/src/compile/builtins/blob.js.map +1 -0
  25. package/dist/src/compile/builtins/compare.d.ts +18 -0
  26. package/dist/src/compile/builtins/compare.d.ts.map +1 -0
  27. package/dist/src/compile/builtins/compare.js +52 -0
  28. package/dist/src/compile/builtins/compare.js.map +1 -0
  29. package/dist/src/compile/builtins/datetime.d.ts +21 -0
  30. package/dist/src/compile/builtins/datetime.d.ts.map +1 -0
  31. package/dist/src/compile/builtins/datetime.js +46 -0
  32. package/dist/src/compile/builtins/datetime.js.map +1 -0
  33. package/dist/src/compile/builtins/dict.d.ts +47 -0
  34. package/dist/src/compile/builtins/dict.d.ts.map +1 -0
  35. package/dist/src/compile/builtins/dict.js +576 -0
  36. package/dist/src/compile/builtins/dict.js.map +1 -0
  37. package/dist/src/compile/builtins/index.d.ts +9 -0
  38. package/dist/src/compile/builtins/index.d.ts.map +1 -0
  39. package/dist/src/compile/builtins/index.js +28 -0
  40. package/dist/src/compile/builtins/index.js.map +1 -0
  41. package/dist/src/compile/builtins/matrix.d.ts +31 -0
  42. package/dist/src/compile/builtins/matrix.d.ts.map +1 -0
  43. package/dist/src/compile/builtins/matrix.js +310 -0
  44. package/dist/src/compile/builtins/matrix.js.map +1 -0
  45. package/dist/src/compile/builtins/primitives.d.ts +36 -0
  46. package/dist/src/compile/builtins/primitives.d.ts.map +1 -0
  47. package/dist/src/compile/builtins/primitives.js +67 -0
  48. package/dist/src/compile/builtins/primitives.js.map +1 -0
  49. package/dist/src/compile/builtins/ref.d.ts +11 -0
  50. package/dist/src/compile/builtins/ref.d.ts.map +1 -0
  51. package/dist/src/compile/builtins/ref.js +30 -0
  52. package/dist/src/compile/builtins/ref.js.map +1 -0
  53. package/dist/src/compile/builtins/set.d.ts +42 -0
  54. package/dist/src/compile/builtins/set.d.ts.map +1 -0
  55. package/dist/src/compile/builtins/set.js +410 -0
  56. package/dist/src/compile/builtins/set.js.map +1 -0
  57. package/dist/src/compile/builtins/sparse.d.ts +19 -0
  58. package/dist/src/compile/builtins/sparse.d.ts.map +1 -0
  59. package/dist/src/compile/builtins/sparse.js +143 -0
  60. package/dist/src/compile/builtins/sparse.js.map +1 -0
  61. package/dist/src/compile/builtins/string.d.ts +34 -0
  62. package/dist/src/compile/builtins/string.d.ts.map +1 -0
  63. package/dist/src/compile/builtins/string.js +238 -0
  64. package/dist/src/compile/builtins/string.js.map +1 -0
  65. package/dist/src/compile/builtins/tree.d.ts +32 -0
  66. package/dist/src/compile/builtins/tree.d.ts.map +1 -0
  67. package/dist/src/compile/builtins/tree.js +108 -0
  68. package/dist/src/compile/builtins/tree.js.map +1 -0
  69. package/dist/src/compile/builtins/vector.d.ts +44 -0
  70. package/dist/src/compile/builtins/vector.d.ts.map +1 -0
  71. package/dist/src/compile/builtins/vector.js +463 -0
  72. package/dist/src/compile/builtins/vector.js.map +1 -0
  73. package/dist/src/compile/constructors.d.ts +13 -0
  74. package/dist/src/compile/constructors.d.ts.map +1 -0
  75. package/dist/src/compile/constructors.js +179 -0
  76. package/dist/src/compile/constructors.js.map +1 -0
  77. package/dist/src/compile/control.d.ts +13 -0
  78. package/dist/src/compile/control.d.ts.map +1 -0
  79. package/dist/src/compile/control.js +513 -0
  80. package/dist/src/compile/control.js.map +1 -0
  81. package/dist/src/compile/functions.d.ts +13 -0
  82. package/dist/src/compile/functions.d.ts.map +1 -0
  83. package/dist/src/compile/functions.js +492 -0
  84. package/dist/src/compile/functions.js.map +1 -0
  85. package/dist/src/compile/ir.d.ts +19 -0
  86. package/dist/src/compile/ir.d.ts.map +1 -0
  87. package/dist/src/compile/ir.js +193 -0
  88. package/dist/src/compile/ir.js.map +1 -0
  89. package/dist/src/compile/runtime.d.ts +75 -0
  90. package/dist/src/compile/runtime.d.ts.map +1 -0
  91. package/dist/src/compile/runtime.js +114 -0
  92. package/dist/src/compile/runtime.js.map +1 -0
  93. package/dist/src/compile/type_parameters.d.ts +4 -0
  94. package/dist/src/compile/type_parameters.d.ts.map +1 -0
  95. package/dist/src/compile/type_parameters.js +55 -0
  96. package/dist/src/compile/type_parameters.js.map +1 -0
  97. package/dist/src/compile/typed_arrays.d.ts +28 -0
  98. package/dist/src/compile/typed_arrays.d.ts.map +1 -0
  99. package/dist/src/compile/typed_arrays.js +77 -0
  100. package/dist/src/compile/typed_arrays.js.map +1 -0
  101. package/dist/src/compile.d.ts +6 -41
  102. package/dist/src/compile.d.ts.map +1 -1
  103. package/dist/src/compile.js +8 -4415
  104. package/dist/src/compile.js.map +1 -1
  105. package/dist/src/compile.open_beast.spec.js +5 -4
  106. package/dist/src/compile.open_beast.spec.js.map +1 -1
  107. package/dist/src/compile.signature.spec.d.ts +6 -0
  108. package/dist/src/compile.signature.spec.d.ts.map +1 -0
  109. package/dist/src/compile.signature.spec.js +53 -0
  110. package/dist/src/compile.signature.spec.js.map +1 -0
  111. package/dist/src/containers/sortedmap.d.ts +2 -1
  112. package/dist/src/containers/sortedmap.d.ts.map +1 -1
  113. package/dist/src/containers/sortedmap.js +4 -2
  114. package/dist/src/containers/sortedmap.js.map +1 -1
  115. package/dist/src/containers/sortedset.d.ts +2 -1
  116. package/dist/src/containers/sortedset.d.ts.map +1 -1
  117. package/dist/src/containers/sortedset.js +4 -2
  118. package/dist/src/containers/sortedset.js.map +1 -1
  119. package/dist/src/error.d.ts +15 -0
  120. package/dist/src/error.d.ts.map +1 -1
  121. package/dist/src/error.js +16 -0
  122. package/dist/src/error.js.map +1 -1
  123. package/dist/src/expr/array.d.ts +158 -81
  124. package/dist/src/expr/array.d.ts.map +1 -1
  125. package/dist/src/expr/array.js +68 -51
  126. package/dist/src/expr/array.js.map +1 -1
  127. package/dist/src/expr/ast.d.ts.map +1 -1
  128. package/dist/src/expr/ast.js +13 -0
  129. package/dist/src/expr/ast.js.map +1 -1
  130. package/dist/src/expr/blob.d.ts +8 -8
  131. package/dist/src/expr/blob.js +8 -8
  132. package/dist/src/expr/block.d.ts +18 -5
  133. package/dist/src/expr/block.d.ts.map +1 -1
  134. package/dist/src/expr/block.js +19 -0
  135. package/dist/src/expr/block.js.map +1 -1
  136. package/dist/src/expr/boolean.d.ts +10 -10
  137. package/dist/src/expr/boolean.js +10 -10
  138. package/dist/src/expr/datetime.d.ts +28 -28
  139. package/dist/src/expr/datetime.js +28 -28
  140. package/dist/src/expr/dict.d.ts +101 -51
  141. package/dist/src/expr/dict.d.ts.map +1 -1
  142. package/dist/src/expr/dict.js +97 -36
  143. package/dist/src/expr/dict.js.map +1 -1
  144. package/dist/src/expr/float.d.ts +23 -23
  145. package/dist/src/expr/float.js +23 -23
  146. package/dist/src/expr/integer.d.ts +17 -17
  147. package/dist/src/expr/integer.js +11 -11
  148. package/dist/src/expr/libs/array.d.ts +6 -6
  149. package/dist/src/expr/libs/array.js +6 -6
  150. package/dist/src/expr/libs/blob.d.ts +2 -2
  151. package/dist/src/expr/libs/blob.js +2 -2
  152. package/dist/src/expr/libs/datetime.d.ts +25 -25
  153. package/dist/src/expr/libs/datetime.js +25 -25
  154. package/dist/src/expr/libs/dict.d.ts +2 -2
  155. package/dist/src/expr/libs/dict.js +2 -2
  156. package/dist/src/expr/libs/float.d.ts +15 -15
  157. package/dist/src/expr/libs/float.js +15 -15
  158. package/dist/src/expr/libs/integer.d.ts +12 -12
  159. package/dist/src/expr/libs/integer.js +12 -12
  160. package/dist/src/expr/libs/set.d.ts +2 -2
  161. package/dist/src/expr/libs/set.js +2 -2
  162. package/dist/src/expr/libs/string.d.ts +4 -4
  163. package/dist/src/expr/libs/string.js +4 -4
  164. package/dist/src/expr/recursive.d.ts +22 -5
  165. package/dist/src/expr/recursive.d.ts.map +1 -1
  166. package/dist/src/expr/recursive.js +22 -5
  167. package/dist/src/expr/recursive.js.map +1 -1
  168. package/dist/src/expr/ref.d.ts +5 -5
  169. package/dist/src/expr/ref.js +5 -5
  170. package/dist/src/expr/set.d.ts +96 -51
  171. package/dist/src/expr/set.d.ts.map +1 -1
  172. package/dist/src/expr/set.js +85 -29
  173. package/dist/src/expr/set.js.map +1 -1
  174. package/dist/src/expr/string.d.ts +28 -28
  175. package/dist/src/expr/string.js +28 -28
  176. package/dist/src/expr/struct.d.ts.map +1 -1
  177. package/dist/src/expr/struct.js +2 -2
  178. package/dist/src/expr/variant.d.ts +12 -12
  179. package/dist/src/expr/variant.js +7 -7
  180. package/dist/src/function_symbols.d.ts +28 -0
  181. package/dist/src/function_symbols.d.ts.map +1 -0
  182. package/dist/src/function_symbols.js +28 -0
  183. package/dist/src/function_symbols.js.map +1 -0
  184. package/dist/src/index.d.ts +1 -0
  185. package/dist/src/index.d.ts.map +1 -1
  186. package/dist/src/index.js +1 -0
  187. package/dist/src/index.js.map +1 -1
  188. package/dist/src/location.d.ts +32 -0
  189. package/dist/src/location.d.ts.map +1 -1
  190. package/dist/src/location.js +38 -0
  191. package/dist/src/location.js.map +1 -1
  192. package/dist/src/location.spec.js +89 -1
  193. package/dist/src/location.spec.js.map +1 -1
  194. package/dist/src/patch/index.d.ts +1 -1
  195. package/dist/src/patch/index.d.ts.map +1 -1
  196. package/dist/src/patch/index.js +1 -1
  197. package/dist/src/patch/index.js.map +1 -1
  198. package/dist/src/patch/type_of_patch.d.ts +25 -1
  199. package/dist/src/patch/type_of_patch.d.ts.map +1 -1
  200. package/dist/src/patch/type_of_patch.js +33 -10
  201. package/dist/src/patch/type_of_patch.js.map +1 -1
  202. package/dist/src/platform.spec.js +19 -1
  203. package/dist/src/platform.spec.js.map +1 -1
  204. package/dist/src/runner_protocol.d.ts +357 -0
  205. package/dist/src/runner_protocol.d.ts.map +1 -0
  206. package/dist/src/runner_protocol.js +154 -0
  207. package/dist/src/runner_protocol.js.map +1 -0
  208. package/dist/src/serialization/beast2/index.d.ts +22 -5
  209. package/dist/src/serialization/beast2/index.d.ts.map +1 -1
  210. package/dist/src/serialization/beast2/index.js +13 -2
  211. package/dist/src/serialization/beast2/index.js.map +1 -1
  212. package/dist/src/serialization/beast2/index.spec.js +84 -3
  213. package/dist/src/serialization/beast2/index.spec.js.map +1 -1
  214. package/dist/src/serialization/beast2/shared.d.ts +32 -3
  215. package/dist/src/serialization/beast2/shared.d.ts.map +1 -1
  216. package/dist/src/serialization/beast2/shared.js +135 -10
  217. package/dist/src/serialization/beast2/shared.js.map +1 -1
  218. package/dist/src/serialization/beast2/v4/container.d.ts.map +1 -1
  219. package/dist/src/serialization/beast2/v4/container.js +5 -3
  220. package/dist/src/serialization/beast2/v4/container.js.map +1 -1
  221. package/dist/src/serialization/beast2/v5/aliasing.spec.d.ts +6 -0
  222. package/dist/src/serialization/beast2/v5/aliasing.spec.d.ts.map +1 -0
  223. package/dist/src/serialization/beast2/v5/aliasing.spec.js +75 -0
  224. package/dist/src/serialization/beast2/v5/aliasing.spec.js.map +1 -0
  225. package/dist/src/serialization/beast2/v5/boundary.d.ts +176 -0
  226. package/dist/src/serialization/beast2/v5/boundary.d.ts.map +1 -0
  227. package/dist/src/serialization/beast2/v5/boundary.js +297 -0
  228. package/dist/src/serialization/beast2/v5/boundary.js.map +1 -0
  229. package/dist/src/serialization/beast2/v5/boundary.spec.d.ts +6 -0
  230. package/dist/src/serialization/beast2/v5/boundary.spec.d.ts.map +1 -0
  231. package/dist/src/serialization/beast2/v5/boundary.spec.js +479 -0
  232. package/dist/src/serialization/beast2/v5/boundary.spec.js.map +1 -0
  233. package/dist/src/serialization/beast2/v5/canonical.d.ts +101 -0
  234. package/dist/src/serialization/beast2/v5/canonical.d.ts.map +1 -0
  235. package/dist/src/serialization/beast2/v5/canonical.js +436 -0
  236. package/dist/src/serialization/beast2/v5/canonical.js.map +1 -0
  237. package/dist/src/serialization/beast2/v5/canonical.spec.d.ts +6 -0
  238. package/dist/src/serialization/beast2/v5/canonical.spec.d.ts.map +1 -0
  239. package/dist/src/serialization/beast2/v5/canonical.spec.js +124 -0
  240. package/dist/src/serialization/beast2/v5/canonical.spec.js.map +1 -0
  241. package/dist/src/serialization/beast2/v5/codec.d.ts +6 -5
  242. package/dist/src/serialization/beast2/v5/codec.d.ts.map +1 -1
  243. package/dist/src/serialization/beast2/v5/codec.js +18 -3
  244. package/dist/src/serialization/beast2/v5/codec.js.map +1 -1
  245. package/dist/src/serialization/beast2/v5/deflate.d.ts +24 -2
  246. package/dist/src/serialization/beast2/v5/deflate.d.ts.map +1 -1
  247. package/dist/src/serialization/beast2/v5/deflate.js +47 -12
  248. package/dist/src/serialization/beast2/v5/deflate.js.map +1 -1
  249. package/dist/src/serialization/beast2/v5/deflate.spec.js +15 -1
  250. package/dist/src/serialization/beast2/v5/deflate.spec.js.map +1 -1
  251. package/dist/src/serialization/beast2/v5/elements.d.ts +66 -0
  252. package/dist/src/serialization/beast2/v5/elements.d.ts.map +1 -0
  253. package/dist/src/serialization/beast2/v5/elements.js +325 -0
  254. package/dist/src/serialization/beast2/v5/elements.js.map +1 -0
  255. package/dist/src/serialization/beast2/v5/elements.spec.d.ts +6 -0
  256. package/dist/src/serialization/beast2/v5/elements.spec.d.ts.map +1 -0
  257. package/dist/src/serialization/beast2/v5/elements.spec.js +161 -0
  258. package/dist/src/serialization/beast2/v5/elements.spec.js.map +1 -0
  259. package/dist/src/serialization/beast2/v5/frame-pool.d.ts +62 -21
  260. package/dist/src/serialization/beast2/v5/frame-pool.d.ts.map +1 -1
  261. package/dist/src/serialization/beast2/v5/frame-pool.js +138 -27
  262. package/dist/src/serialization/beast2/v5/frame-pool.js.map +1 -1
  263. package/dist/src/serialization/beast2/v5/frame-pool.spec.js +198 -71
  264. package/dist/src/serialization/beast2/v5/frame-pool.spec.js.map +1 -1
  265. package/dist/src/serialization/beast2/v5/frame-worker.js +25 -15
  266. package/dist/src/serialization/beast2/v5/frame-worker.js.map +1 -1
  267. package/dist/src/serialization/beast2/v5/frames.d.ts +22 -12
  268. package/dist/src/serialization/beast2/v5/frames.d.ts.map +1 -1
  269. package/dist/src/serialization/beast2/v5/frames.js +52 -27
  270. package/dist/src/serialization/beast2/v5/frames.js.map +1 -1
  271. package/dist/src/serialization/beast2/v5/geometry.d.ts +38 -1
  272. package/dist/src/serialization/beast2/v5/geometry.d.ts.map +1 -1
  273. package/dist/src/serialization/beast2/v5/geometry.js +73 -1
  274. package/dist/src/serialization/beast2/v5/geometry.js.map +1 -1
  275. package/dist/src/serialization/beast2/v5/geometry.spec.js +34 -23
  276. package/dist/src/serialization/beast2/v5/geometry.spec.js.map +1 -1
  277. package/dist/src/serialization/beast2/v5/index.spec.js +32 -28
  278. package/dist/src/serialization/beast2/v5/index.spec.js.map +1 -1
  279. package/dist/src/serialization/beast2/v5/intake.d.ts +98 -0
  280. package/dist/src/serialization/beast2/v5/intake.d.ts.map +1 -0
  281. package/dist/src/serialization/beast2/v5/intake.js +462 -0
  282. package/dist/src/serialization/beast2/v5/intake.js.map +1 -0
  283. package/dist/src/serialization/beast2/v5/intake.spec.d.ts +6 -0
  284. package/dist/src/serialization/beast2/v5/intake.spec.d.ts.map +1 -0
  285. package/dist/src/serialization/beast2/v5/intake.spec.js +202 -0
  286. package/dist/src/serialization/beast2/v5/intake.spec.js.map +1 -0
  287. package/dist/src/serialization/beast2/v5/lazy.d.ts +42 -1
  288. package/dist/src/serialization/beast2/v5/lazy.d.ts.map +1 -1
  289. package/dist/src/serialization/beast2/v5/lazy.js +143 -28
  290. package/dist/src/serialization/beast2/v5/lazy.js.map +1 -1
  291. package/dist/src/serialization/beast2/v5/lazy.spec.js +102 -24
  292. package/dist/src/serialization/beast2/v5/lazy.spec.js.map +1 -1
  293. package/dist/src/serialization/beast2/v5/manifest-writer.d.ts +110 -0
  294. package/dist/src/serialization/beast2/v5/manifest-writer.d.ts.map +1 -0
  295. package/dist/src/serialization/beast2/v5/manifest-writer.js +118 -0
  296. package/dist/src/serialization/beast2/v5/manifest-writer.js.map +1 -0
  297. package/dist/src/serialization/beast2/v5/manifest-writer.spec.d.ts +6 -0
  298. package/dist/src/serialization/beast2/v5/manifest-writer.spec.d.ts.map +1 -0
  299. package/dist/src/serialization/beast2/v5/manifest-writer.spec.js +207 -0
  300. package/dist/src/serialization/beast2/v5/manifest-writer.spec.js.map +1 -0
  301. package/dist/src/serialization/beast2/v5/manifest.d.ts +241 -0
  302. package/dist/src/serialization/beast2/v5/manifest.d.ts.map +1 -0
  303. package/dist/src/serialization/beast2/v5/manifest.js +233 -0
  304. package/dist/src/serialization/beast2/v5/manifest.js.map +1 -0
  305. package/dist/src/serialization/beast2/v5/merge.d.ts +93 -0
  306. package/dist/src/serialization/beast2/v5/merge.d.ts.map +1 -0
  307. package/dist/src/serialization/beast2/v5/merge.js +202 -0
  308. package/dist/src/serialization/beast2/v5/merge.js.map +1 -0
  309. package/dist/src/serialization/beast2/v5/merge.spec.d.ts +6 -0
  310. package/dist/src/serialization/beast2/v5/merge.spec.d.ts.map +1 -0
  311. package/dist/src/serialization/beast2/v5/merge.spec.js +118 -0
  312. package/dist/src/serialization/beast2/v5/merge.spec.js.map +1 -0
  313. package/dist/src/serialization/beast2/v5/recut.d.ts +143 -0
  314. package/dist/src/serialization/beast2/v5/recut.d.ts.map +1 -0
  315. package/dist/src/serialization/beast2/v5/recut.js +365 -0
  316. package/dist/src/serialization/beast2/v5/recut.js.map +1 -0
  317. package/dist/src/serialization/beast2/v5/recut.spec.d.ts +6 -0
  318. package/dist/src/serialization/beast2/v5/recut.spec.d.ts.map +1 -0
  319. package/dist/src/serialization/beast2/v5/recut.spec.js +215 -0
  320. package/dist/src/serialization/beast2/v5/recut.spec.js.map +1 -0
  321. package/dist/src/serialization/beast2/v5/runs.d.ts +148 -0
  322. package/dist/src/serialization/beast2/v5/runs.d.ts.map +1 -0
  323. package/dist/src/serialization/beast2/v5/runs.js +260 -0
  324. package/dist/src/serialization/beast2/v5/runs.js.map +1 -0
  325. package/dist/src/serialization/beast2/v5/runs.spec.d.ts +6 -0
  326. package/dist/src/serialization/beast2/v5/runs.spec.d.ts.map +1 -0
  327. package/dist/src/serialization/beast2/v5/runs.spec.js +182 -0
  328. package/dist/src/serialization/beast2/v5/runs.spec.js.map +1 -0
  329. package/dist/src/serialization/beast2/v5/sha256.d.ts +19 -0
  330. package/dist/src/serialization/beast2/v5/sha256.d.ts.map +1 -0
  331. package/dist/src/serialization/beast2/v5/sha256.js +103 -0
  332. package/dist/src/serialization/beast2/v5/sha256.js.map +1 -0
  333. package/dist/src/serialization/beast2/v5/sha256.spec.d.ts +6 -0
  334. package/dist/src/serialization/beast2/v5/sha256.spec.d.ts.map +1 -0
  335. package/dist/src/serialization/beast2/v5/sha256.spec.js +42 -0
  336. package/dist/src/serialization/beast2/v5/sha256.spec.js.map +1 -0
  337. package/dist/src/serialization/beast2/v5/stream.d.ts +273 -86
  338. package/dist/src/serialization/beast2/v5/stream.d.ts.map +1 -1
  339. package/dist/src/serialization/beast2/v5/stream.js +576 -244
  340. package/dist/src/serialization/beast2/v5/stream.js.map +1 -1
  341. package/dist/src/serialization/beast2/v5/sync-reader.spec.js +24 -10
  342. package/dist/src/serialization/beast2/v5/sync-reader.spec.js.map +1 -1
  343. package/dist/src/serialization/index.d.ts +1 -1
  344. package/dist/src/serialization/index.d.ts.map +1 -1
  345. package/dist/src/serialization/index.js +1 -1
  346. package/dist/src/serialization/index.js.map +1 -1
  347. package/dist/src/serialization/json.d.ts +28 -0
  348. package/dist/src/serialization/json.d.ts.map +1 -1
  349. package/dist/src/serialization/json.js +141 -30
  350. package/dist/src/serialization/json.js.map +1 -1
  351. package/dist/src/serialization/json.spec.js +47 -2
  352. package/dist/src/serialization/json.spec.js.map +1 -1
  353. package/dist/src/serialization/json_schema.d.ts +15 -11
  354. package/dist/src/serialization/json_schema.d.ts.map +1 -1
  355. package/dist/src/serialization/json_schema.js +21 -36
  356. package/dist/src/serialization/json_schema.js.map +1 -1
  357. package/dist/src/serialization/json_schema.spec.js +26 -32
  358. package/dist/src/serialization/json_schema.spec.js.map +1 -1
  359. package/dist/src/serialization/json_schema_to_type.d.ts +10 -5
  360. package/dist/src/serialization/json_schema_to_type.d.ts.map +1 -1
  361. package/dist/src/serialization/json_schema_to_type.js +13 -6
  362. package/dist/src/serialization/json_schema_to_type.js.map +1 -1
  363. package/dist/src/serialization/json_schema_to_type.spec.js +19 -0
  364. package/dist/src/serialization/json_schema_to_type.spec.js.map +1 -1
  365. package/dist/src/string_order.d.ts +36 -0
  366. package/dist/src/string_order.d.ts.map +1 -0
  367. package/dist/src/string_order.js +64 -0
  368. package/dist/src/string_order.js.map +1 -0
  369. package/dist/src/string_order.spec.d.ts +6 -0
  370. package/dist/src/string_order.spec.d.ts.map +1 -0
  371. package/dist/src/string_order.spec.js +79 -0
  372. package/dist/src/string_order.spec.js.map +1 -0
  373. package/dist/src/type_of_type.d.ts +17 -0
  374. package/dist/src/type_of_type.d.ts.map +1 -1
  375. package/dist/src/type_of_type.js +66 -0
  376. package/dist/src/type_of_type.js.map +1 -1
  377. package/dist/src/type_of_type.to_etv.spec.js +69 -1
  378. package/dist/src/type_of_type.to_etv.spec.js.map +1 -1
  379. package/package.json +1 -1
@@ -0,0 +1,691 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ import { compareFor } from "../../comparison.js";
6
+ import { call_function, FROZEN_MESSAGE, iterationLocks, lockForIteration, unlockForIteration } from "../runtime.js";
7
+ import { SortedMap } from "../../containers/sortedmap.js";
8
+ import { SortedSet } from "../../containers/sortedset.js";
9
+ import { variant } from "../../containers/variant.js";
10
+ import { EastError } from "../../error.js";
11
+ import { isFrozenValue } from "../../frozen.js";
12
+ import { printFor } from "../../serialization/east.js";
13
+ import { buildTree, treeOrder } from "./tree.js";
14
+ /** The builtins for Arrays. @internal */
15
+ export const array_builtins = {
16
+ ArrayGenerate: (loc_id, source_map, _platformDef, _T) => (size, f) => {
17
+ const result = [];
18
+ for (let i = 0n; i < size; i += 1n) {
19
+ const v = call_function(loc_id, source_map, f, i);
20
+ result.push(v);
21
+ }
22
+ return result;
23
+ },
24
+ ArrayRange: (_loc_id, _source_map) => (start, end, step) => {
25
+ const result = [];
26
+ if (step === 0n) {
27
+ return result; // empty array
28
+ }
29
+ else if (step > 0n) {
30
+ for (let i = start; i < end; i += step) {
31
+ result.push(i);
32
+ }
33
+ }
34
+ else { // step < 0
35
+ for (let i = start; i > end; i += step) {
36
+ result.push(i);
37
+ }
38
+ }
39
+ return result;
40
+ },
41
+ ArrayLinspace: (_loc_id, _source_map) => (start, end, size) => {
42
+ const result = [];
43
+ if (size <= 0n) {
44
+ return result; // empty array
45
+ }
46
+ else if (size === 1n) {
47
+ return [start];
48
+ }
49
+ else {
50
+ const step = (end - start) / Number(size - 1n);
51
+ for (let i = 0n; i < size; i += 1n) {
52
+ result.push(start + Number(i) * step);
53
+ }
54
+ }
55
+ return result;
56
+ },
57
+ ArraySize: (_loc_id, _source_map, _platformDef, _T) => (array) => BigInt(array.length),
58
+ ArrayHas: (_loc_id, _source_map, _platformDef, _T) => (array, key) => {
59
+ const i = Number(key);
60
+ return i >= 0 && i < array.length;
61
+ },
62
+ ArrayGet: (loc_id, source_map, _platformDef, _T) => (array, key) => {
63
+ const i = Number(key);
64
+ if (i < 0 || i >= array.length) {
65
+ throw new EastError(`Array index ${key} out of bounds`, { location: (source_map?.resolve(loc_id) ?? []) });
66
+ }
67
+ else {
68
+ return array[i];
69
+ }
70
+ },
71
+ ArrayGetOrDefault: (loc_id, source_map, _platformDef, _T) => (array, key, defaultFn) => {
72
+ const i = Number(key);
73
+ if (i < 0 || i >= array.length) {
74
+ return call_function(loc_id, source_map, defaultFn, key);
75
+ }
76
+ else {
77
+ return array[i];
78
+ }
79
+ },
80
+ ArrayTryGet: (_loc_id, _source_map, _platformDef, _T) => (array, key) => {
81
+ const i = Number(key);
82
+ if (i < 0 || i >= array.length) {
83
+ return variant("none", null);
84
+ }
85
+ else {
86
+ return variant("some", array[i]);
87
+ }
88
+ },
89
+ ArrayUpdate: (loc_id, source_map, _platformDef, _T) => (array, key, value) => {
90
+ if (isFrozenValue(array)) {
91
+ throw new EastError(FROZEN_MESSAGE, { location: (source_map?.resolve(loc_id) ?? []) });
92
+ }
93
+ const i = Number(key);
94
+ if (i < 0 || i >= array.length) {
95
+ throw new EastError(`Array index ${key} out of bounds`, { location: (source_map?.resolve(loc_id) ?? []) });
96
+ }
97
+ else {
98
+ array[i] = value;
99
+ return null;
100
+ }
101
+ },
102
+ ArrayMerge: (loc_id, source_map, _platformDef, _T) => (array, key, value, merger) => {
103
+ if (isFrozenValue(array)) {
104
+ throw new EastError(FROZEN_MESSAGE, { location: (source_map?.resolve(loc_id) ?? []) });
105
+ }
106
+ const i = Number(key);
107
+ if (i < 0 || i >= array.length) {
108
+ throw new EastError(`Array index ${key} out of bounds`, { location: (source_map?.resolve(loc_id) ?? []) });
109
+ }
110
+ else {
111
+ const new_value = call_function(loc_id, source_map, merger, array[i], value, key);
112
+ array[i] = new_value;
113
+ return null;
114
+ }
115
+ },
116
+ ArrayPushLast: (loc_id, source_map, _platformDef, _T) => (array, value) => {
117
+ if (isFrozenValue(array)) {
118
+ throw new EastError(FROZEN_MESSAGE, { location: (source_map?.resolve(loc_id) ?? []) });
119
+ }
120
+ if ((iterationLocks.get(array) || 0) > 0) {
121
+ throw new EastError("Cannot modify Array during iteration", { location: (source_map?.resolve(loc_id) ?? []) });
122
+ }
123
+ array.push(value);
124
+ return null;
125
+ },
126
+ ArrayPopLast: (loc_id, source_map, _platformDef, _T) => (array) => {
127
+ if (isFrozenValue(array)) {
128
+ throw new EastError(FROZEN_MESSAGE, { location: (source_map?.resolve(loc_id) ?? []) });
129
+ }
130
+ if ((iterationLocks.get(array) || 0) > 0) {
131
+ throw new EastError("Cannot modify Array during iteration", { location: (source_map?.resolve(loc_id) ?? []) });
132
+ }
133
+ if (array.length === 0) {
134
+ throw new EastError("Cannot pop from empty Array", { location: (source_map?.resolve(loc_id) ?? []) });
135
+ }
136
+ else {
137
+ return array.pop();
138
+ }
139
+ },
140
+ ArrayPushFirst: (loc_id, source_map, _platformDef, _T) => (array, value) => {
141
+ if (isFrozenValue(array)) {
142
+ throw new EastError(FROZEN_MESSAGE, { location: (source_map?.resolve(loc_id) ?? []) });
143
+ }
144
+ if ((iterationLocks.get(array) || 0) > 0) {
145
+ throw new EastError("Cannot modify Array during iteration", { location: (source_map?.resolve(loc_id) ?? []) });
146
+ }
147
+ array.unshift(value);
148
+ return null;
149
+ },
150
+ ArrayPopFirst: (loc_id, source_map, _platformDef, _T) => (array) => {
151
+ if (isFrozenValue(array)) {
152
+ throw new EastError(FROZEN_MESSAGE, { location: (source_map?.resolve(loc_id) ?? []) });
153
+ }
154
+ if ((iterationLocks.get(array) || 0) > 0) {
155
+ throw new EastError("Cannot modify Array during iteration", { location: (source_map?.resolve(loc_id) ?? []) });
156
+ }
157
+ if (array.length === 0) {
158
+ throw new EastError("Cannot pop from empty Array", { location: (source_map?.resolve(loc_id) ?? []) });
159
+ }
160
+ else {
161
+ return array.shift();
162
+ }
163
+ },
164
+ ArrayAppend: (loc_id, source_map, _platformDef, _T) => (array, other) => {
165
+ if (isFrozenValue(array)) {
166
+ throw new EastError(FROZEN_MESSAGE, { location: (source_map?.resolve(loc_id) ?? []) });
167
+ }
168
+ if ((iterationLocks.get(array) || 0) > 0) {
169
+ throw new EastError("Cannot modify Array during iteration", { location: (source_map?.resolve(loc_id) ?? []) });
170
+ }
171
+ array.push(...other);
172
+ return null;
173
+ },
174
+ ArrayPrepend: (loc_id, source_map, _platformDef, _T) => (array, other) => {
175
+ if (isFrozenValue(array)) {
176
+ throw new EastError(FROZEN_MESSAGE, { location: (source_map?.resolve(loc_id) ?? []) });
177
+ }
178
+ if ((iterationLocks.get(array) || 0) > 0) {
179
+ throw new EastError("Cannot modify Array during iteration", { location: (source_map?.resolve(loc_id) ?? []) });
180
+ }
181
+ array.unshift(...other);
182
+ return null;
183
+ },
184
+ ArrayMergeAll: (loc_id, source_map, _platformDef, _T, _T2) => (array, other, merger) => {
185
+ if (isFrozenValue(array)) {
186
+ throw new EastError(FROZEN_MESSAGE, { location: (source_map?.resolve(loc_id) ?? []) });
187
+ }
188
+ lockForIteration(array);
189
+ lockForIteration(other);
190
+ try {
191
+ for (let i = 0; i < other.length; i++) {
192
+ const key = BigInt(i);
193
+ if (i < array.length) {
194
+ const new_value = call_function(loc_id, source_map, merger, array[i], other[i], key);
195
+ array[i] = new_value;
196
+ }
197
+ else {
198
+ throw new EastError(`Array index ${key} out of bounds`, { location: (source_map?.resolve(loc_id) ?? []) });
199
+ }
200
+ }
201
+ }
202
+ finally {
203
+ unlockForIteration(other);
204
+ unlockForIteration(array);
205
+ }
206
+ return null;
207
+ },
208
+ ArrayClear: (loc_id, source_map, _platformDef, _T) => (array) => {
209
+ if (isFrozenValue(array)) {
210
+ throw new EastError(FROZEN_MESSAGE, { location: (source_map?.resolve(loc_id) ?? []) });
211
+ }
212
+ if ((iterationLocks.get(array) || 0) > 0) {
213
+ throw new EastError("Cannot modify Array during iteration", { location: (source_map?.resolve(loc_id) ?? []) });
214
+ }
215
+ array.length = 0;
216
+ return null;
217
+ },
218
+ ArraySortInPlace: (loc_id, source_map, _platformDef, T, T2) => (array, by) => {
219
+ if (isFrozenValue(array)) {
220
+ throw new EastError(FROZEN_MESSAGE, { location: (source_map?.resolve(loc_id) ?? []) });
221
+ }
222
+ if ((iterationLocks.get(array) || 0) > 0) {
223
+ throw new EastError("Cannot modify Array during iteration", { location: (source_map?.resolve(loc_id) ?? []) });
224
+ }
225
+ lockForIteration(array);
226
+ try {
227
+ const cmp = compareFor(T2);
228
+ array.sort((a, b) => {
229
+ const projectedA = call_function(loc_id, source_map, by, a);
230
+ const projectedB = call_function(loc_id, source_map, by, b);
231
+ return cmp(projectedA, projectedB);
232
+ });
233
+ }
234
+ finally {
235
+ unlockForIteration(array);
236
+ }
237
+ return null;
238
+ },
239
+ ArrayReverseInPlace: (loc_id, source_map, _platformDef, _T) => (array) => {
240
+ if (isFrozenValue(array)) {
241
+ throw new EastError(FROZEN_MESSAGE, { location: (source_map?.resolve(loc_id) ?? []) });
242
+ }
243
+ if ((iterationLocks.get(array) || 0) > 0) {
244
+ throw new EastError("Cannot modify Array during iteration", { location: (source_map?.resolve(loc_id) ?? []) });
245
+ }
246
+ array.reverse();
247
+ return null;
248
+ },
249
+ ArraySort: (loc_id, source_map, _platformDef, T, T2) => (array, by) => {
250
+ const cmp = compareFor(T2);
251
+ const newArray = [...array];
252
+ newArray.sort((a, b) => {
253
+ const projectedA = call_function(loc_id, source_map, by, a);
254
+ const projectedB = call_function(loc_id, source_map, by, b);
255
+ return cmp(projectedA, projectedB);
256
+ });
257
+ return newArray;
258
+ },
259
+ ArrayReverse: (_loc_id, _source_map, _platformDef, _T) => (array) => {
260
+ const newArray = [...array];
261
+ newArray.reverse();
262
+ return newArray;
263
+ },
264
+ ArrayIsSorted: (loc_id, source_map, _platformDef, T, T2) => {
265
+ const cmp = compareFor(T2);
266
+ return (array, by) => {
267
+ if (array.length < 2)
268
+ return true;
269
+ lockForIteration(array);
270
+ try {
271
+ let projectedPrev = call_function(loc_id, source_map, by, array[0]);
272
+ for (let i = 1; i < array.length; i++) {
273
+ const projectedCurr = call_function(loc_id, source_map, by, array[i]);
274
+ if (cmp(projectedPrev, projectedCurr) > 0) {
275
+ return false;
276
+ }
277
+ projectedPrev = projectedCurr;
278
+ }
279
+ }
280
+ finally {
281
+ unlockForIteration(array);
282
+ }
283
+ return true;
284
+ };
285
+ },
286
+ ArrayFindSortedFirst: (loc_id, source_map, _platformDef, T, T2) => {
287
+ const cmp = compareFor(T2);
288
+ return (array, key, by) => {
289
+ let low = 0;
290
+ let high = array.length;
291
+ lockForIteration(array);
292
+ try {
293
+ while (low < high) {
294
+ const mid = Math.floor((low + high) / 2);
295
+ const projectedMid = call_function(loc_id, source_map, by, array[mid]);
296
+ if (cmp(projectedMid, key) < 0) {
297
+ low = mid + 1;
298
+ }
299
+ else {
300
+ high = mid;
301
+ }
302
+ }
303
+ }
304
+ finally {
305
+ unlockForIteration(array);
306
+ }
307
+ return BigInt(low);
308
+ };
309
+ },
310
+ ArrayFindSortedLast: (loc_id, source_map, _platformDef, T, T2) => {
311
+ const cmp = compareFor(T2);
312
+ return (array, key, by) => {
313
+ let low = 0;
314
+ let high = array.length;
315
+ lockForIteration(array);
316
+ try {
317
+ while (low < high) {
318
+ const mid = Math.floor((low + high) / 2);
319
+ const projectedMid = call_function(loc_id, source_map, by, array[mid]);
320
+ if (cmp(projectedMid, key) <= 0) {
321
+ low = mid + 1;
322
+ }
323
+ else {
324
+ high = mid;
325
+ }
326
+ }
327
+ }
328
+ finally {
329
+ unlockForIteration(array);
330
+ }
331
+ return BigInt(low);
332
+ };
333
+ },
334
+ ArrayFindSortedRange: (loc_id, source_map, _platformDef, T, T2) => {
335
+ const cmp = compareFor(T2);
336
+ return (array, key, by) => {
337
+ let lo = -1;
338
+ let hi = array.length;
339
+ lockForIteration(array);
340
+ try {
341
+ // Main search loop - find any equal element or determine the range doesn't exist
342
+ while (lo < hi - 1) {
343
+ const mid = Math.floor((lo + hi) / 2);
344
+ const projectedMid = call_function(loc_id, source_map, by, array[mid]);
345
+ const cmpResult = cmp(projectedMid, key);
346
+ if (cmpResult < 0) {
347
+ lo = mid;
348
+ }
349
+ else if (cmpResult > 0) {
350
+ hi = mid;
351
+ }
352
+ else {
353
+ // Found an equal element! Now find the first and last positions
354
+ // within the constrained range
355
+ // Find first position in range [max(lo, -1), mid]
356
+ let firstLo = Math.max(lo, -1);
357
+ let firstHi = mid + 1;
358
+ while (firstLo < firstHi - 1) {
359
+ const firstMid = Math.floor((firstLo + firstHi) / 2);
360
+ const projectedFirst = call_function(loc_id, source_map, by, array[firstMid]);
361
+ if (cmp(projectedFirst, key) < 0) {
362
+ firstLo = firstMid;
363
+ }
364
+ else {
365
+ firstHi = firstMid;
366
+ }
367
+ }
368
+ // Find last position in range [mid, min(hi, array.length)]
369
+ let lastLo = mid - 1;
370
+ let lastHi = Math.min(hi, array.length);
371
+ while (lastLo < lastHi - 1) {
372
+ const lastMid = Math.floor((lastLo + lastHi) / 2);
373
+ const projectedLast = call_function(loc_id, source_map, by, array[lastMid]);
374
+ if (cmp(projectedLast, key) <= 0) {
375
+ lastLo = lastMid;
376
+ }
377
+ else {
378
+ lastHi = lastMid;
379
+ }
380
+ }
381
+ return { start: BigInt(firstLo + 1), end: BigInt(lastLo + 1) };
382
+ }
383
+ }
384
+ }
385
+ finally {
386
+ unlockForIteration(array);
387
+ }
388
+ // No equal element found - return empty range
389
+ return { start: BigInt(lo + 1), end: BigInt(lo + 1) };
390
+ };
391
+ },
392
+ ArrayFindFirst: (loc_id, source_map, _platformDef, T, T2) => {
393
+ const cmp = compareFor(T2);
394
+ return (array, value, by) => {
395
+ lockForIteration(array);
396
+ try {
397
+ for (let i = 0; i < array.length; i++) {
398
+ const projected = call_function(loc_id, source_map, by, array[i]);
399
+ if (cmp(projected, value) === 0) {
400
+ return variant("some", BigInt(i));
401
+ }
402
+ }
403
+ return variant("none", null);
404
+ }
405
+ finally {
406
+ unlockForIteration(array);
407
+ }
408
+ };
409
+ },
410
+ ArrayConcat: (_loc_id, _source_map, _platformDef, _T) => (a1, a2) => {
411
+ return [...a1, ...a2];
412
+ },
413
+ ArraySlice: (_loc_id, _source_map, _platformDef, _T) => (array, start, end) => {
414
+ const startNum = Number(start);
415
+ const endNum = Number(end);
416
+ return array.slice(startNum, endNum);
417
+ },
418
+ ArrayGetKeys: (loc_id, source_map, _platformDef, _T) => (array, keys, onMissing) => {
419
+ return keys.map(k => {
420
+ const i = Number(k);
421
+ if (i < 0 || i >= array.length) {
422
+ return call_function(loc_id, source_map, onMissing, k);
423
+ }
424
+ else {
425
+ return array[i];
426
+ }
427
+ });
428
+ },
429
+ ArrayForEach: (loc_id, source_map, _platformDef, _T, _T2) => (array, f) => {
430
+ lockForIteration(array);
431
+ try {
432
+ array.forEach((x, i) => {
433
+ return call_function(loc_id, source_map, f, x, BigInt(i));
434
+ });
435
+ return null;
436
+ }
437
+ finally {
438
+ unlockForIteration(array);
439
+ }
440
+ },
441
+ ArrayCopy: (_loc_id, _source_map, _platformDef, _T) => (array) => {
442
+ return [...array];
443
+ },
444
+ ArrayMap: (loc_id, source_map, _platformDef, _T, _T2) => (array, f) => {
445
+ lockForIteration(array);
446
+ try {
447
+ return array.map((x, i) => {
448
+ return call_function(loc_id, source_map, f, x, BigInt(i));
449
+ });
450
+ }
451
+ finally {
452
+ unlockForIteration(array);
453
+ }
454
+ },
455
+ ArrayFilter: (loc_id, source_map, _platformDef, _T, _T2) => (array, f) => {
456
+ lockForIteration(array);
457
+ try {
458
+ return array.filter((x, i) => {
459
+ return call_function(loc_id, source_map, f, x, BigInt(i));
460
+ });
461
+ }
462
+ finally {
463
+ unlockForIteration(array);
464
+ }
465
+ },
466
+ ArrayFilterMap: (loc_id, source_map, _platformDef, _T, _T2) => (array, f) => {
467
+ lockForIteration(array);
468
+ try {
469
+ const result = [];
470
+ for (let i = 0; i < array.length; i++) {
471
+ const v = call_function(loc_id, source_map, f, array[i], BigInt(i));
472
+ if (v.type === "some") {
473
+ result.push(v.value);
474
+ }
475
+ }
476
+ return result;
477
+ }
478
+ finally {
479
+ unlockForIteration(array);
480
+ }
481
+ },
482
+ ArrayFirstMap: (loc_id, source_map, _platformDef, _T, _T2) => (array, f) => {
483
+ lockForIteration(array);
484
+ try {
485
+ for (let i = 0; i < array.length; i++) {
486
+ const v = call_function(loc_id, source_map, f, array[i], BigInt(i));
487
+ if (v.type === "some") {
488
+ return v;
489
+ }
490
+ }
491
+ return variant("none", null);
492
+ }
493
+ finally {
494
+ unlockForIteration(array);
495
+ }
496
+ },
497
+ ArrayFold: (loc_id, source_map, _platformDef, _T, _T2) => (array, init, f) => {
498
+ lockForIteration(array);
499
+ try {
500
+ return array.reduce((acc, x, i) => {
501
+ return call_function(loc_id, source_map, f, acc, x, BigInt(i));
502
+ }, init);
503
+ }
504
+ finally {
505
+ unlockForIteration(array);
506
+ }
507
+ },
508
+ ArrayScan: (loc_id, source_map, _platformDef, _T, _T2) => (array, init, f) => {
509
+ lockForIteration(array);
510
+ try {
511
+ const result = [];
512
+ let acc = init;
513
+ for (let i = 0; i < array.length; i++) {
514
+ acc = call_function(loc_id, source_map, f, acc, array[i], BigInt(i));
515
+ result.push(acc);
516
+ }
517
+ return result;
518
+ }
519
+ finally {
520
+ unlockForIteration(array);
521
+ }
522
+ },
523
+ ArrayMapReduce: (loc_id, source_map, _platformDef, _T, _T2) => (array, mapFn, reduceFn) => {
524
+ if (array.length === 0) {
525
+ throw new EastError("Cannot reduce empty array with no initial value", { location: (source_map?.resolve(loc_id) ?? []) });
526
+ }
527
+ lockForIteration(array);
528
+ try {
529
+ let acc = call_function(loc_id, source_map, mapFn, array[0], 0n);
530
+ for (let i = 1; i < array.length; i++) {
531
+ const mapped = call_function(loc_id, source_map, mapFn, array[i], BigInt(i));
532
+ acc = call_function(loc_id, source_map, reduceFn, acc, mapped);
533
+ }
534
+ return acc;
535
+ }
536
+ finally {
537
+ unlockForIteration(array);
538
+ }
539
+ },
540
+ ArrayStringJoin: (_loc_id, _source_map, _platformDef) => (x, y) => x.join(y),
541
+ ArrayToSet: (loc_id, source_map, _platformDef, _T, T2) => {
542
+ const compare = compareFor(T2);
543
+ return (array, f) => {
544
+ lockForIteration(array);
545
+ try {
546
+ const result = new SortedSet([], compare);
547
+ for (let i = 0; i < array.length; i++) {
548
+ const v = call_function(loc_id, source_map, f, array[i], BigInt(i));
549
+ result.add(v);
550
+ }
551
+ return result;
552
+ }
553
+ finally {
554
+ unlockForIteration(array);
555
+ }
556
+ };
557
+ },
558
+ ArrayToDict: (loc_id, source_map, _platformDef, _T, K2, _T2) => {
559
+ const compare = compareFor(K2);
560
+ return (array, keyFn, valueFn, onConflict) => {
561
+ const result = new SortedMap([], compare);
562
+ lockForIteration(array);
563
+ try {
564
+ for (let i = 0; i < array.length; i++) {
565
+ const v = array[i];
566
+ const k = call_function(loc_id, source_map, keyFn, v, BigInt(i));
567
+ let val = call_function(loc_id, source_map, valueFn, v, BigInt(i));
568
+ const existing = result.get(k);
569
+ if (existing === undefined) {
570
+ result.set(k, val);
571
+ }
572
+ else {
573
+ val = call_function(loc_id, source_map, onConflict, existing, val, k);
574
+ result.set(k, val);
575
+ }
576
+ }
577
+ return result;
578
+ }
579
+ finally {
580
+ unlockForIteration(array);
581
+ }
582
+ };
583
+ },
584
+ ArrayFlattenToArray: (loc_id, source_map, _platformDef, _T) => (array, fn) => {
585
+ return array.flatMap(v => {
586
+ return call_function(loc_id, source_map, fn, v);
587
+ });
588
+ },
589
+ ArrayFlattenToSet: (loc_id, source_map, _platformDef, _T, K2) => {
590
+ const compare = compareFor(K2);
591
+ return (array, fn) => {
592
+ const result = new SortedSet([], compare);
593
+ lockForIteration(array);
594
+ try {
595
+ for (const v of array) {
596
+ const subset = call_function(loc_id, source_map, fn, v);
597
+ for (const k of subset) {
598
+ result.add(k);
599
+ }
600
+ }
601
+ return result;
602
+ }
603
+ finally {
604
+ unlockForIteration(array);
605
+ }
606
+ };
607
+ },
608
+ ArrayFlattenToDict: (loc_id, source_map, _platformDef, _T, K2, _T2) => {
609
+ const compare = compareFor(K2);
610
+ return (array, fn, onConflict) => {
611
+ const result = new SortedMap([], compare);
612
+ lockForIteration(array);
613
+ try {
614
+ for (const v of array) {
615
+ const subdict = call_function(loc_id, source_map, fn, v);
616
+ for (const [k, val] of subdict.entries()) {
617
+ const existing = result.get(k);
618
+ if (existing === undefined) {
619
+ result.set(k, val);
620
+ }
621
+ else {
622
+ const new_val = call_function(loc_id, source_map, onConflict, existing, val, k);
623
+ result.set(k, new_val);
624
+ }
625
+ }
626
+ }
627
+ return result;
628
+ }
629
+ finally {
630
+ unlockForIteration(array);
631
+ }
632
+ };
633
+ },
634
+ ArrayGroupFold: (loc_id, source_map, _platformDef, _T, K2, _V2) => {
635
+ const compare = compareFor(K2);
636
+ return (array, keyFn, init, folder) => {
637
+ const result = new SortedMap([], compare);
638
+ lockForIteration(array);
639
+ try {
640
+ for (let i = 0; i < array.length; i++) {
641
+ const v = array[i];
642
+ const k = call_function(loc_id, source_map, keyFn, v, BigInt(i));
643
+ let existing = result.get(k);
644
+ if (existing === undefined) {
645
+ existing = call_function(loc_id, source_map, init, k);
646
+ }
647
+ const new_val = call_function(loc_id, source_map, folder, existing, v, BigInt(i));
648
+ result.set(k, new_val);
649
+ }
650
+ return result;
651
+ }
652
+ finally {
653
+ unlockForIteration(array);
654
+ }
655
+ };
656
+ },
657
+ ArrayToTree: (loc_id, source_map, _platformDef, _T, K, _N) => {
658
+ const compare = compareFor(K);
659
+ const print = printFor(K);
660
+ return (array, keyFn, parentFn, buildFn) => {
661
+ lockForIteration(array);
662
+ try {
663
+ const n = array.length;
664
+ const keys = [];
665
+ const index = new SortedMap([], compare);
666
+ for (let i = 0; i < n; i++) {
667
+ const k = call_function(loc_id, source_map, keyFn, array[i], BigInt(i));
668
+ if (index.has(k)) {
669
+ throw new EastError(`toTree: duplicate key ${print(k)}`, { location: (source_map?.resolve(loc_id) ?? []) });
670
+ }
671
+ index.set(k, i);
672
+ keys.push(k);
673
+ }
674
+ const parents = new Int32Array(n);
675
+ for (let i = 0; i < n; i++) {
676
+ const p = call_function(loc_id, source_map, parentFn, array[i], BigInt(i));
677
+ parents[i] = p.type === "some" ? (index.get(p.value) ?? -1) : -1;
678
+ }
679
+ const { order, childCounts, cycle } = treeOrder(parents);
680
+ if (cycle >= 0) {
681
+ throw new EastError(`toTree: cycle through key ${print(keys[cycle])}`, { location: (source_map?.resolve(loc_id) ?? []) });
682
+ }
683
+ return buildTree(order, childCounts, (i, children) => call_function(loc_id, source_map, buildFn, array[i], BigInt(i), children));
684
+ }
685
+ finally {
686
+ unlockForIteration(array);
687
+ }
688
+ };
689
+ },
690
+ };
691
+ //# sourceMappingURL=array.js.map