@elaraai/east 1.0.78 → 1.0.80

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