@elaraai/east 0.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/LICENSE.md +682 -0
  2. package/README.md +276 -0
  3. package/dist/src/analyze.d.ts +95 -0
  4. package/dist/src/analyze.d.ts.map +1 -0
  5. package/dist/src/analyze.js +1110 -0
  6. package/dist/src/analyze.js.map +1 -0
  7. package/dist/src/ast.d.ts +263 -0
  8. package/dist/src/ast.d.ts.map +1 -0
  9. package/dist/src/ast.js +151 -0
  10. package/dist/src/ast.js.map +1 -0
  11. package/dist/src/ast_to_ir.d.ts +24 -0
  12. package/dist/src/ast_to_ir.d.ts.map +1 -0
  13. package/dist/src/ast_to_ir.js +834 -0
  14. package/dist/src/ast_to_ir.js.map +1 -0
  15. package/dist/src/builtins.d.ts +18 -0
  16. package/dist/src/builtins.d.ts.map +1 -0
  17. package/dist/src/builtins.js +1105 -0
  18. package/dist/src/builtins.js.map +1 -0
  19. package/dist/src/comparison.d.ts +28 -0
  20. package/dist/src/comparison.d.ts.map +1 -0
  21. package/dist/src/comparison.js +1017 -0
  22. package/dist/src/comparison.js.map +1 -0
  23. package/dist/src/compile.d.ts +22 -0
  24. package/dist/src/compile.d.ts.map +1 -0
  25. package/dist/src/compile.js +3260 -0
  26. package/dist/src/compile.js.map +1 -0
  27. package/dist/src/containers/ref.d.ts +106 -0
  28. package/dist/src/containers/ref.d.ts.map +1 -0
  29. package/dist/src/containers/ref.js +100 -0
  30. package/dist/src/containers/ref.js.map +1 -0
  31. package/dist/src/containers/sortedmap.d.ts +165 -0
  32. package/dist/src/containers/sortedmap.d.ts.map +1 -0
  33. package/dist/src/containers/sortedmap.js +237 -0
  34. package/dist/src/containers/sortedmap.js.map +1 -0
  35. package/dist/src/containers/sortedset.d.ts +185 -0
  36. package/dist/src/containers/sortedset.d.ts.map +1 -0
  37. package/dist/src/containers/sortedset.js +312 -0
  38. package/dist/src/containers/sortedset.js.map +1 -0
  39. package/dist/src/containers/variant.d.ts +131 -0
  40. package/dist/src/containers/variant.d.ts.map +1 -0
  41. package/dist/src/containers/variant.js +68 -0
  42. package/dist/src/containers/variant.js.map +1 -0
  43. package/dist/src/datetime_format/parse.d.ts +50 -0
  44. package/dist/src/datetime_format/parse.d.ts.map +1 -0
  45. package/dist/src/datetime_format/parse.js +908 -0
  46. package/dist/src/datetime_format/parse.js.map +1 -0
  47. package/dist/src/datetime_format/print.d.ts +35 -0
  48. package/dist/src/datetime_format/print.d.ts.map +1 -0
  49. package/dist/src/datetime_format/print.js +157 -0
  50. package/dist/src/datetime_format/print.js.map +1 -0
  51. package/dist/src/datetime_format/tokenize.d.ts +76 -0
  52. package/dist/src/datetime_format/tokenize.d.ts.map +1 -0
  53. package/dist/src/datetime_format/tokenize.js +271 -0
  54. package/dist/src/datetime_format/tokenize.js.map +1 -0
  55. package/dist/src/datetime_format/types.d.ts +99 -0
  56. package/dist/src/datetime_format/types.d.ts.map +1 -0
  57. package/dist/src/datetime_format/types.js +103 -0
  58. package/dist/src/datetime_format/types.js.map +1 -0
  59. package/dist/src/datetime_format/validate.d.ts +51 -0
  60. package/dist/src/datetime_format/validate.d.ts.map +1 -0
  61. package/dist/src/datetime_format/validate.js +208 -0
  62. package/dist/src/datetime_format/validate.js.map +1 -0
  63. package/dist/src/default.d.ts +21 -0
  64. package/dist/src/default.d.ts.map +1 -0
  65. package/dist/src/default.js +82 -0
  66. package/dist/src/default.js.map +1 -0
  67. package/dist/src/eastir.d.ts +33 -0
  68. package/dist/src/eastir.d.ts.map +1 -0
  69. package/dist/src/eastir.js +92 -0
  70. package/dist/src/eastir.js.map +1 -0
  71. package/dist/src/error.d.ts +13 -0
  72. package/dist/src/error.d.ts.map +1 -0
  73. package/dist/src/error.js +8 -0
  74. package/dist/src/error.js.map +1 -0
  75. package/dist/src/expr/array.d.ts +1711 -0
  76. package/dist/src/expr/array.d.ts.map +1 -0
  77. package/dist/src/expr/array.js +1805 -0
  78. package/dist/src/expr/array.js.map +1 -0
  79. package/dist/src/expr/ast.d.ts +17 -0
  80. package/dist/src/expr/ast.d.ts.map +1 -0
  81. package/dist/src/expr/ast.js +302 -0
  82. package/dist/src/expr/ast.js.map +1 -0
  83. package/dist/src/expr/blob.d.ts +141 -0
  84. package/dist/src/expr/blob.d.ts.map +1 -0
  85. package/dist/src/expr/blob.js +198 -0
  86. package/dist/src/expr/blob.js.map +1 -0
  87. package/dist/src/expr/block.d.ts +201 -0
  88. package/dist/src/expr/block.d.ts.map +1 -0
  89. package/dist/src/expr/block.js +1505 -0
  90. package/dist/src/expr/block.js.map +1 -0
  91. package/dist/src/expr/boolean.d.ts +207 -0
  92. package/dist/src/expr/boolean.d.ts.map +1 -0
  93. package/dist/src/expr/boolean.js +261 -0
  94. package/dist/src/expr/boolean.js.map +1 -0
  95. package/dist/src/expr/datetime.d.ts +544 -0
  96. package/dist/src/expr/datetime.d.ts.map +1 -0
  97. package/dist/src/expr/datetime.js +980 -0
  98. package/dist/src/expr/datetime.js.map +1 -0
  99. package/dist/src/expr/dict.d.ts +1242 -0
  100. package/dist/src/expr/dict.d.ts.map +1 -0
  101. package/dist/src/expr/dict.js +1492 -0
  102. package/dist/src/expr/dict.js.map +1 -0
  103. package/dist/src/expr/expr.d.ts +95 -0
  104. package/dist/src/expr/expr.d.ts.map +1 -0
  105. package/dist/src/expr/expr.js +171 -0
  106. package/dist/src/expr/expr.js.map +1 -0
  107. package/dist/src/expr/float.d.ts +357 -0
  108. package/dist/src/expr/float.d.ts.map +1 -0
  109. package/dist/src/expr/float.js +637 -0
  110. package/dist/src/expr/float.js.map +1 -0
  111. package/dist/src/expr/function.d.ts +46 -0
  112. package/dist/src/expr/function.d.ts.map +1 -0
  113. package/dist/src/expr/function.js +58 -0
  114. package/dist/src/expr/function.js.map +1 -0
  115. package/dist/src/expr/index.d.ts +450 -0
  116. package/dist/src/expr/index.d.ts.map +1 -0
  117. package/dist/src/expr/index.js +423 -0
  118. package/dist/src/expr/index.js.map +1 -0
  119. package/dist/src/expr/integer.d.ts +256 -0
  120. package/dist/src/expr/integer.d.ts.map +1 -0
  121. package/dist/src/expr/integer.js +311 -0
  122. package/dist/src/expr/integer.js.map +1 -0
  123. package/dist/src/expr/libs/array.d.ts +106 -0
  124. package/dist/src/expr/libs/array.d.ts.map +1 -0
  125. package/dist/src/expr/libs/array.js +140 -0
  126. package/dist/src/expr/libs/array.js.map +1 -0
  127. package/dist/src/expr/libs/blob.d.ts +42 -0
  128. package/dist/src/expr/libs/blob.d.ts.map +1 -0
  129. package/dist/src/expr/libs/blob.js +70 -0
  130. package/dist/src/expr/libs/blob.js.map +1 -0
  131. package/dist/src/expr/libs/datetime.d.ts +479 -0
  132. package/dist/src/expr/libs/datetime.d.ts.map +1 -0
  133. package/dist/src/expr/libs/datetime.js +624 -0
  134. package/dist/src/expr/libs/datetime.js.map +1 -0
  135. package/dist/src/expr/libs/dict.d.ts +66 -0
  136. package/dist/src/expr/libs/dict.d.ts.map +1 -0
  137. package/dist/src/expr/libs/dict.js +77 -0
  138. package/dist/src/expr/libs/dict.js.map +1 -0
  139. package/dist/src/expr/libs/float.d.ts +299 -0
  140. package/dist/src/expr/libs/float.d.ts.map +1 -0
  141. package/dist/src/expr/libs/float.js +564 -0
  142. package/dist/src/expr/libs/float.js.map +1 -0
  143. package/dist/src/expr/libs/integer.d.ts +228 -0
  144. package/dist/src/expr/libs/integer.d.ts.map +1 -0
  145. package/dist/src/expr/libs/integer.js +398 -0
  146. package/dist/src/expr/libs/integer.js.map +1 -0
  147. package/dist/src/expr/libs/set.d.ts +59 -0
  148. package/dist/src/expr/libs/set.d.ts.map +1 -0
  149. package/dist/src/expr/libs/set.js +69 -0
  150. package/dist/src/expr/libs/set.js.map +1 -0
  151. package/dist/src/expr/libs/string.d.ts +71 -0
  152. package/dist/src/expr/libs/string.d.ts.map +1 -0
  153. package/dist/src/expr/libs/string.js +75 -0
  154. package/dist/src/expr/libs/string.js.map +1 -0
  155. package/dist/src/expr/never.d.ts +15 -0
  156. package/dist/src/expr/never.d.ts.map +1 -0
  157. package/dist/src/expr/never.js +12 -0
  158. package/dist/src/expr/never.js.map +1 -0
  159. package/dist/src/expr/null.d.ts +15 -0
  160. package/dist/src/expr/null.d.ts.map +1 -0
  161. package/dist/src/expr/null.js +12 -0
  162. package/dist/src/expr/null.js.map +1 -0
  163. package/dist/src/expr/ref.d.ts +103 -0
  164. package/dist/src/expr/ref.d.ts.map +1 -0
  165. package/dist/src/expr/ref.js +131 -0
  166. package/dist/src/expr/ref.js.map +1 -0
  167. package/dist/src/expr/regex_validation.d.ts +25 -0
  168. package/dist/src/expr/regex_validation.d.ts.map +1 -0
  169. package/dist/src/expr/regex_validation.js +130 -0
  170. package/dist/src/expr/regex_validation.js.map +1 -0
  171. package/dist/src/expr/set.d.ts +1071 -0
  172. package/dist/src/expr/set.d.ts.map +1 -0
  173. package/dist/src/expr/set.js +1137 -0
  174. package/dist/src/expr/set.js.map +1 -0
  175. package/dist/src/expr/string.d.ts +414 -0
  176. package/dist/src/expr/string.d.ts.map +1 -0
  177. package/dist/src/expr/string.js +683 -0
  178. package/dist/src/expr/string.js.map +1 -0
  179. package/dist/src/expr/struct.d.ts +48 -0
  180. package/dist/src/expr/struct.d.ts.map +1 -0
  181. package/dist/src/expr/struct.js +65 -0
  182. package/dist/src/expr/struct.js.map +1 -0
  183. package/dist/src/expr/types.d.ts +68 -0
  184. package/dist/src/expr/types.d.ts.map +1 -0
  185. package/dist/src/expr/types.js +6 -0
  186. package/dist/src/expr/types.js.map +1 -0
  187. package/dist/src/expr/variant.d.ts +137 -0
  188. package/dist/src/expr/variant.d.ts.map +1 -0
  189. package/dist/src/expr/variant.js +105 -0
  190. package/dist/src/expr/variant.js.map +1 -0
  191. package/dist/src/fuzz.d.ts +80 -0
  192. package/dist/src/fuzz.d.ts.map +1 -0
  193. package/dist/src/fuzz.js +300 -0
  194. package/dist/src/fuzz.js.map +1 -0
  195. package/dist/src/index.d.ts +21 -0
  196. package/dist/src/index.d.ts.map +1 -0
  197. package/dist/src/index.js +21 -0
  198. package/dist/src/index.js.map +1 -0
  199. package/dist/src/internal.d.ts +36 -0
  200. package/dist/src/internal.d.ts.map +1 -0
  201. package/dist/src/internal.js +11 -0
  202. package/dist/src/internal.js.map +1 -0
  203. package/dist/src/ir.d.ts +1571 -0
  204. package/dist/src/ir.d.ts.map +1 -0
  205. package/dist/src/ir.js +56 -0
  206. package/dist/src/ir.js.map +1 -0
  207. package/dist/src/location.d.ts +48 -0
  208. package/dist/src/location.d.ts.map +1 -0
  209. package/dist/src/location.js +62 -0
  210. package/dist/src/location.js.map +1 -0
  211. package/dist/src/platform.d.ts +21 -0
  212. package/dist/src/platform.d.ts.map +1 -0
  213. package/dist/src/platform.js +8 -0
  214. package/dist/src/platform.js.map +1 -0
  215. package/dist/src/serialization/beast.d.ts +39 -0
  216. package/dist/src/serialization/beast.d.ts.map +1 -0
  217. package/dist/src/serialization/beast.js +555 -0
  218. package/dist/src/serialization/beast.js.map +1 -0
  219. package/dist/src/serialization/beast2-stream.d.ts +38 -0
  220. package/dist/src/serialization/beast2-stream.d.ts.map +1 -0
  221. package/dist/src/serialization/beast2-stream.js +665 -0
  222. package/dist/src/serialization/beast2-stream.js.map +1 -0
  223. package/dist/src/serialization/beast2.d.ts +41 -0
  224. package/dist/src/serialization/beast2.d.ts.map +1 -0
  225. package/dist/src/serialization/beast2.js +489 -0
  226. package/dist/src/serialization/beast2.js.map +1 -0
  227. package/dist/src/serialization/binary-utils.d.ts +151 -0
  228. package/dist/src/serialization/binary-utils.d.ts.map +1 -0
  229. package/dist/src/serialization/binary-utils.js +929 -0
  230. package/dist/src/serialization/binary-utils.js.map +1 -0
  231. package/dist/src/serialization/east.d.ts +84 -0
  232. package/dist/src/serialization/east.d.ts.map +1 -0
  233. package/dist/src/serialization/east.js +1802 -0
  234. package/dist/src/serialization/east.js.map +1 -0
  235. package/dist/src/serialization/index.d.ts +11 -0
  236. package/dist/src/serialization/index.d.ts.map +1 -0
  237. package/dist/src/serialization/index.js +12 -0
  238. package/dist/src/serialization/index.js.map +1 -0
  239. package/dist/src/serialization/json.d.ts +36 -0
  240. package/dist/src/serialization/json.d.ts.map +1 -0
  241. package/dist/src/serialization/json.js +849 -0
  242. package/dist/src/serialization/json.js.map +1 -0
  243. package/dist/src/type_of_type.d.ts +115 -0
  244. package/dist/src/type_of_type.d.ts.map +1 -0
  245. package/dist/src/type_of_type.js +362 -0
  246. package/dist/src/type_of_type.js.map +1 -0
  247. package/dist/src/types.d.ts +648 -0
  248. package/dist/src/types.d.ts.map +1 -0
  249. package/dist/src/types.js +1631 -0
  250. package/dist/src/types.js.map +1 -0
  251. package/package.json +87 -0
@@ -0,0 +1,66 @@
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 { DictType, IntegerType, type EastType, FunctionType } from "../../types.js";
6
+ import { Expr } from "../expr.js";
7
+ import type { SubtypeExprOrValue, ExprType } from "../types.js";
8
+ /** Standard library functions for dictionaries */
9
+ declare const _default: {
10
+ /**
11
+ * Generates a dictionary of a given size programmatically with functions from index to key and value.
12
+ *
13
+ * @typeParam K - The type of the dictionary keys
14
+ * @typeParam V - The type of the dictionary values
15
+ * @param size - The number of entries to generate
16
+ * @param keyType - The East type of the dictionary keys
17
+ * @param valueType - The East type of the dictionary values
18
+ * @param keyFn - A function that takes an index and returns the key at that index
19
+ * @param valueFn - A function that takes an index and returns the value at that index
20
+ * @param onConflict - Optional function `(oldValue, newValue, key) => resolvedValue` to handle duplicate keys
21
+ * @returns A dictionary expression containing the programmatically generated entries
22
+ *
23
+ * @throws East runtime error if duplicate keys are produced and no onConflict is provided
24
+ *
25
+ * @remarks
26
+ * If the generator produces duplicate keys, an error will be thrown by default.
27
+ * To handle duplicates, provide an `onConflict` function that receives the old value,
28
+ * new value, and the conflicting key, and returns the value to use.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * // Generate dict with string keys and integer values
33
+ * const makeDict = East.function([], DictType(StringType, IntegerType), ($) => {
34
+ * $.return(East.Dict.generate(
35
+ * 3n,
36
+ * StringType,
37
+ * IntegerType,
38
+ * ($, i) => Expr.str`key${i}`,
39
+ * ($, i) => i.multiply(10n)
40
+ * ));
41
+ * });
42
+ * const compiled = East.compile(makeDict.toIR(), []);
43
+ * compiled(); // { "key0": 0n, "key1": 10n, "key2": 20n }
44
+ * ```
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * // Generate dict with conflict resolution (keep larger value)
49
+ * const makeDictConflict = East.function([], DictType(IntegerType, IntegerType), ($) => {
50
+ * $.return(East.Dict.generate(
51
+ * 5n,
52
+ * IntegerType,
53
+ * IntegerType,
54
+ * ($, i) => i.remainder(3n), // Creates duplicates: 0,1,2,0,1
55
+ * ($, i) => i,
56
+ * ($, oldVal, newVal, key) => oldVal.greaterThan(newVal).ifElse(() => oldVal, () => newVal)
57
+ * ));
58
+ * });
59
+ * const compiled = East.compile(makeDictConflict.toIR(), []);
60
+ * compiled(); // { 0n: 3n, 1n: 4n, 2n: 2n }
61
+ * ```
62
+ */
63
+ generate<K extends EastType, V extends EastType>(size: Expr<IntegerType> | bigint, keyType: K, valueType: V, keyFn: SubtypeExprOrValue<FunctionType<[IntegerType], NoInfer<K>>>, valueFn: SubtypeExprOrValue<FunctionType<[IntegerType], NoInfer<V>>>, onConflict?: SubtypeExprOrValue<FunctionType<[NoInfer<V>, NoInfer<V>, NoInfer<K>], NoInfer<V>>>): ExprType<DictType<K, V>>;
64
+ };
65
+ export default _default;
66
+ //# sourceMappingURL=dict.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dict.d.ts","sourceRoot":"","sources":["../../../../src/expr/libs/dict.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAa,IAAI,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEhE,kDAAkD;;IAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;aACM,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,QAAQ,IAAI,CAAC,WAAW,CAAC,GAAG,MAAM,WAAW,CAAC,aAAa,CAAC,SAAS,kBAAkB,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,kBAAkB,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,kBAAkB,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;;AAtDnX,wBAqEC"}
@@ -0,0 +1,77 @@
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 { DictType, IntegerType, FunctionType } from "../../types.js";
6
+ import { AstSymbol, Expr } from "../expr.js";
7
+ /** Standard library functions for dictionaries */
8
+ export default {
9
+ /**
10
+ * Generates a dictionary of a given size programmatically with functions from index to key and value.
11
+ *
12
+ * @typeParam K - The type of the dictionary keys
13
+ * @typeParam V - The type of the dictionary values
14
+ * @param size - The number of entries to generate
15
+ * @param keyType - The East type of the dictionary keys
16
+ * @param valueType - The East type of the dictionary values
17
+ * @param keyFn - A function that takes an index and returns the key at that index
18
+ * @param valueFn - A function that takes an index and returns the value at that index
19
+ * @param onConflict - Optional function `(oldValue, newValue, key) => resolvedValue` to handle duplicate keys
20
+ * @returns A dictionary expression containing the programmatically generated entries
21
+ *
22
+ * @throws East runtime error if duplicate keys are produced and no onConflict is provided
23
+ *
24
+ * @remarks
25
+ * If the generator produces duplicate keys, an error will be thrown by default.
26
+ * To handle duplicates, provide an `onConflict` function that receives the old value,
27
+ * new value, and the conflicting key, and returns the value to use.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * // Generate dict with string keys and integer values
32
+ * const makeDict = East.function([], DictType(StringType, IntegerType), ($) => {
33
+ * $.return(East.Dict.generate(
34
+ * 3n,
35
+ * StringType,
36
+ * IntegerType,
37
+ * ($, i) => Expr.str`key${i}`,
38
+ * ($, i) => i.multiply(10n)
39
+ * ));
40
+ * });
41
+ * const compiled = East.compile(makeDict.toIR(), []);
42
+ * compiled(); // { "key0": 0n, "key1": 10n, "key2": 20n }
43
+ * ```
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * // Generate dict with conflict resolution (keep larger value)
48
+ * const makeDictConflict = East.function([], DictType(IntegerType, IntegerType), ($) => {
49
+ * $.return(East.Dict.generate(
50
+ * 5n,
51
+ * IntegerType,
52
+ * IntegerType,
53
+ * ($, i) => i.remainder(3n), // Creates duplicates: 0,1,2,0,1
54
+ * ($, i) => i,
55
+ * ($, oldVal, newVal, key) => oldVal.greaterThan(newVal).ifElse(() => oldVal, () => newVal)
56
+ * ));
57
+ * });
58
+ * const compiled = East.compile(makeDictConflict.toIR(), []);
59
+ * compiled(); // { 0n: 3n, 1n: 4n, 2n: 2n }
60
+ * ```
61
+ */
62
+ generate(size, keyType, valueType, keyFn, valueFn, onConflict) {
63
+ const length_expr = Expr.from(size, IntegerType);
64
+ const key_expr = Expr.from(keyFn, FunctionType([IntegerType], keyType, []));
65
+ const value_expr = Expr.from(valueFn, FunctionType([IntegerType], valueType, []));
66
+ const on_conflict_expr = onConflict ? Expr.from(onConflict, FunctionType([valueType, valueType, keyType], valueType, [])) : Expr.function([valueType, valueType, keyType], valueType, ($, _v1, _v2, key) => $.error(Expr.str `Duplicate key ${key} in dict`));
67
+ return Expr.fromAst({
68
+ ast_type: "Builtin",
69
+ type: DictType(keyType, valueType),
70
+ builtin: "DictGenerate",
71
+ type_parameters: [keyType, valueType],
72
+ arguments: [length_expr[AstSymbol], key_expr[AstSymbol], value_expr[AstSymbol], on_conflict_expr[AstSymbol]],
73
+ location: length_expr[AstSymbol].location,
74
+ });
75
+ },
76
+ };
77
+ //# sourceMappingURL=dict.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dict.js","sourceRoot":"","sources":["../../../../src/expr/libs/dict.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAiB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAG7C,kDAAkD;AAClD,eAAe;IACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;IACH,QAAQ,CAAyC,IAAgC,EAAE,OAAU,EAAE,SAAY,EAAE,KAAkE,EAAE,OAAoE,EAAE,UAA+F;QACpV,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;QAC5E,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;QAClF,MAAM,gBAAgB,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,SAAgB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAA,iBAAiB,GAAG,UAAU,CAAC,CAAC,CAAC;QAEpQ,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,QAAQ,EAAE,SAAS;YACnB,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;YAClC,OAAO,EAAE,cAAc;YACvB,eAAe,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC;YACrC,SAAS,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;YAC5G,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,QAAQ;SAC1C,CAAC,CAAC;IACL,CAAC;CACF,CAAA"}
@@ -0,0 +1,299 @@
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 { BooleanType, FloatType, IntegerType, StringType } from "../../types.js";
6
+ /** Standard library functions for floats */
7
+ declare const _default: {
8
+ /**
9
+ * Checks if two floats are approximately equal within an epsilon tolerance.
10
+ *
11
+ * @param x - The first float value
12
+ * @param y - The second float value
13
+ * @param epsilon - The maximum allowed difference between the values
14
+ * @returns `true` if the absolute difference between `x` and `y` is less than or equal to `epsilon`
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const approxEq = East.function([FloatType, FloatType, FloatType], BooleanType, ($, x, y, eps) => {
19
+ * $.return(East.Float.approxEqual(x, y, eps));
20
+ * });
21
+ * const compiled = East.compile(approxEq.toIR(), []);
22
+ * compiled(0.3, 0.1 + 0.2, 0.0001); // true (handles floating point precision)
23
+ * compiled(1.0, 1.1, 0.05); // false
24
+ * ```
25
+ */
26
+ approxEqual: import("../function.js").CallableFunctionExpr<[FloatType, FloatType, FloatType], BooleanType>;
27
+ /**
28
+ * Rounds a float down to the nearest integer (floor).
29
+ *
30
+ * @param x - The float value to round
31
+ * @returns The largest integer less than or equal to `x`
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const floor = East.function([FloatType], IntegerType, ($, x) => {
36
+ * $.return(East.Float.roundFloor(x));
37
+ * });
38
+ * const compiled = East.compile(floor.toIR(), []);
39
+ * compiled(3.7); // 3n
40
+ * compiled(-2.3); // -3n
41
+ * ```
42
+ */
43
+ roundFloor: import("../function.js").CallableFunctionExpr<[FloatType], IntegerType>;
44
+ /**
45
+ * Rounds a float up to the nearest integer (ceiling).
46
+ *
47
+ * @param x - The float value to round
48
+ * @returns The smallest integer greater than or equal to `x`
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const ceil = East.function([FloatType], IntegerType, ($, x) => {
53
+ * $.return(East.Float.roundCeil(x));
54
+ * });
55
+ * const compiled = East.compile(ceil.toIR(), []);
56
+ * compiled(3.2); // 4n
57
+ * compiled(-2.7); // -2n
58
+ * ```
59
+ */
60
+ roundCeil: import("../function.js").CallableFunctionExpr<[FloatType], IntegerType>;
61
+ /**
62
+ * Rounds a float to the nearest integer using half-away-from-zero rounding.
63
+ *
64
+ * @param x - The float value to round
65
+ * @returns The nearest integer, with ties (0.5) rounding away from zero
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const roundHalf = East.function([FloatType], IntegerType, ($, x) => {
70
+ * $.return(East.Float.roundHalf(x));
71
+ * });
72
+ * const compiled = East.compile(roundHalf.toIR(), []);
73
+ * compiled(3.5); // 4n
74
+ * compiled(3.4); // 3n
75
+ * compiled(-2.5); // -3n
76
+ * ```
77
+ */
78
+ roundHalf: import("../function.js").CallableFunctionExpr<[FloatType], IntegerType>;
79
+ /**
80
+ * Truncates a float towards zero (removes the fractional part).
81
+ *
82
+ * @param x - The float value to truncate
83
+ * @returns The integer part of `x`, discarding the fractional part
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * const trunc = East.function([FloatType], IntegerType, ($, x) => {
88
+ * $.return(East.Float.roundTrunc(x));
89
+ * });
90
+ * const compiled = East.compile(trunc.toIR(), []);
91
+ * compiled(3.7); // 3n
92
+ * compiled(-2.7); // -2n
93
+ * ```
94
+ */
95
+ roundTrunc: import("../function.js").CallableFunctionExpr<[FloatType], IntegerType>;
96
+ /**
97
+ * Rounds a float to the nearest multiple of a step value.
98
+ *
99
+ * @param x - The float value to round
100
+ * @param step - The step value to round to (uses absolute value)
101
+ * @returns The nearest multiple of `step`, with ties rounding away from zero
102
+ * @throws {Error} When `x` is NaN, Infinity, or -Infinity
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * const roundNearest = East.function([FloatType, FloatType], FloatType, ($, x, step) => {
107
+ * $.return(East.Float.roundNearest(x, step));
108
+ * });
109
+ * const compiled = East.compile(roundNearest.toIR(), []);
110
+ * compiled(17.3, 5.0); // 15.0
111
+ * compiled(17.6, 5.0); // 20.0
112
+ * compiled(3.14159, 0.01); // 3.14
113
+ * ```
114
+ */
115
+ roundNearest: import("../function.js").CallableFunctionExpr<[FloatType, FloatType], FloatType>;
116
+ /**
117
+ * Rounds a float up to the next multiple of a step value (ceiling).
118
+ *
119
+ * @param x - The float value to round
120
+ * @param step - The step value to round to (uses absolute value)
121
+ * @returns The smallest multiple of `step` greater than or equal to `x`
122
+ * @throws {Error} When `x` is NaN, Infinity, or -Infinity
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * const roundUp = East.function([FloatType, FloatType], FloatType, ($, x, step) => {
127
+ * $.return(East.Float.roundUp(x, step));
128
+ * });
129
+ * const compiled = East.compile(roundUp.toIR(), []);
130
+ * compiled(17.1, 5.0); // 20.0
131
+ * compiled(15.0, 5.0); // 15.0 (already exact)
132
+ * compiled(3.14, 0.1); // 3.2
133
+ * ```
134
+ */
135
+ roundUp: import("../function.js").CallableFunctionExpr<[FloatType, FloatType], FloatType>;
136
+ /**
137
+ * Rounds a float down to the previous multiple of a step value (floor).
138
+ *
139
+ * @param x - The float value to round
140
+ * @param step - The step value to round to (uses absolute value)
141
+ * @returns The largest multiple of `step` less than or equal to `x`
142
+ * @throws {Error} When `x` is NaN, Infinity, or -Infinity
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * const roundDown = East.function([FloatType, FloatType], FloatType, ($, x, step) => {
147
+ * $.return(East.Float.roundDown(x, step));
148
+ * });
149
+ * const compiled = East.compile(roundDown.toIR(), []);
150
+ * compiled(17.9, 5.0); // 15.0
151
+ * compiled(15.0, 5.0); // 15.0 (already exact)
152
+ * compiled(3.19, 0.1); // 3.1
153
+ * ```
154
+ */
155
+ roundDown: import("../function.js").CallableFunctionExpr<[FloatType, FloatType], FloatType>;
156
+ /**
157
+ * Rounds a float towards zero to the nearest multiple of a step value (truncate).
158
+ *
159
+ * @param x - The float value to round
160
+ * @param step - The step value to round to (uses absolute value)
161
+ * @returns The multiple of `step` closest to zero that is between zero and `x`
162
+ * @throws {Error} When `x` is NaN, Infinity, or -Infinity
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * const roundTruncate = East.function([FloatType, FloatType], FloatType, ($, x, step) => {
167
+ * $.return(East.Float.roundTruncate(x, step));
168
+ * });
169
+ * const compiled = East.compile(roundTruncate.toIR(), []);
170
+ * compiled(17.9, 5.0); // 15.0
171
+ * compiled(-17.9, 5.0); // -15.0
172
+ * ```
173
+ */
174
+ roundTruncate: import("../function.js").CallableFunctionExpr<[FloatType, FloatType], FloatType>;
175
+ /**
176
+ * Rounds a float to a specified number of decimal places.
177
+ *
178
+ * @param x - The float value to round
179
+ * @param decimals - The number of decimal places to round to
180
+ * @returns The float rounded to the specified number of decimal places
181
+ * @throws {Error} When `x` is NaN, Infinity, or -Infinity
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * const roundDecimals = East.function([FloatType, IntegerType], FloatType, ($, x, decimals) => {
186
+ * $.return(East.Float.roundToDecimals(x, decimals));
187
+ * });
188
+ * const compiled = East.compile(roundDecimals.toIR(), []);
189
+ * compiled(3.14159, 2n); // 3.14
190
+ * compiled(2.5, 0n); // 3.0
191
+ * ```
192
+ */
193
+ roundToDecimals: import("../function.js").CallableFunctionExpr<[FloatType, IntegerType], FloatType>;
194
+ /**
195
+ * Formats a float with comma separators for thousands.
196
+ *
197
+ * @param x - The float value to format
198
+ * @param decimals - The number of decimal places to display
199
+ * @returns A formatted string with comma separators (e.g., `"1,234.567"`)
200
+ * @throws {Error} When `x` is NaN, Infinity, or -Infinity
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * const formatComma = East.function([FloatType, IntegerType], StringType, ($, x, decimals) => {
205
+ * $.return(East.Float.printCommaSeperated(x, decimals));
206
+ * });
207
+ * const compiled = East.compile(formatComma.toIR(), []);
208
+ * compiled(1234.567, 2n); // "1,234.57"
209
+ * compiled(1000000, 0n); // "1,000,000"
210
+ * compiled(-5432.1, 3n); // "-5,432.100"
211
+ * ```
212
+ */
213
+ printCommaSeperated: import("../function.js").CallableFunctionExpr<[FloatType, IntegerType], StringType>;
214
+ /**
215
+ * Formats a float as currency with comma separators and 2 decimal places.
216
+ *
217
+ * @param x - The float value to format as currency
218
+ * @returns A formatted currency string (e.g., `"$1,234.56"`)
219
+ * @throws {Error} When `x` is NaN, Infinity, or -Infinity
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * const formatCurrency = East.function([FloatType], StringType, ($, x) => {
224
+ * $.return(East.Float.printCurrency(x));
225
+ * });
226
+ * const compiled = East.compile(formatCurrency.toIR(), []);
227
+ * compiled(1234.567); // "$1,234.57"
228
+ * compiled(-42.5); // "-$42.50"
229
+ * compiled(1000000); // "$1,000,000.00"
230
+ * ```
231
+ */
232
+ printCurrency: import("../function.js").CallableFunctionExpr<[FloatType], StringType>;
233
+ /**
234
+ * Formats a float with a fixed number of decimal places.
235
+ *
236
+ * @param x - The float value to format
237
+ * @param decimals - The number of decimal places to display
238
+ * @returns A formatted string with the specified decimal places (e.g., `"3.14"`)
239
+ * @throws {Error} When `x` is NaN, Infinity, or -Infinity
240
+ *
241
+ * @example
242
+ * ```ts
243
+ * const formatFixed = East.function([FloatType, IntegerType], StringType, ($, x, decimals) => {
244
+ * $.return(East.Float.printFixed(x, decimals));
245
+ * });
246
+ * const compiled = East.compile(formatFixed.toIR(), []);
247
+ * compiled(3.14159, 2n); // "3.14"
248
+ * compiled(42, 3n); // "42.000"
249
+ * compiled(-0.5, 1n); // "-0.5"
250
+ * ```
251
+ */
252
+ printFixed: import("../function.js").CallableFunctionExpr<[FloatType, IntegerType], StringType>;
253
+ /**
254
+ * Formats a float in compact form with business unit suffixes.
255
+ *
256
+ * Uses suffixes: K (thousands), M (millions), B (billions), T (trillions),
257
+ * Q (quadrillions), Qi (quintillions).
258
+ *
259
+ * @param x - The float value to format
260
+ * @returns A compact formatted string (e.g., `"21.5K"`, `"1.82M"`, `"314B"`)
261
+ * @throws {Error} When `x` is NaN, Infinity, or -Infinity
262
+ *
263
+ * @example
264
+ * ```ts
265
+ * const formatCompact = East.function([FloatType], StringType, ($, x) => {
266
+ * $.return(East.Float.printCompact(x));
267
+ * });
268
+ * const compiled = East.compile(formatCompact.toIR(), []);
269
+ * compiled(1500); // "1.5K"
270
+ * compiled(2500000); // "2.5M"
271
+ * compiled(3140000000); // "3.14B"
272
+ * ```
273
+ */
274
+ printCompact: import("../function.js").CallableFunctionExpr<[FloatType], StringType>;
275
+ /**
276
+ * Formats a float as a percentage.
277
+ *
278
+ * Multiplies the value by 100 and appends a percent sign.
279
+ *
280
+ * @param x - The float value to format (e.g., `0.452` for 45.2%)
281
+ * @param decimals - The number of decimal places to display
282
+ * @returns A formatted percentage string (e.g., `"45.2%"`)
283
+ * @throws {Error} When `x` is NaN, Infinity, or -Infinity
284
+ *
285
+ * @example
286
+ * ```ts
287
+ * const formatPercent = East.function([FloatType, IntegerType], StringType, ($, x, decimals) => {
288
+ * $.return(East.Float.printPercentage(x, decimals));
289
+ * });
290
+ * const compiled = East.compile(formatPercent.toIR(), []);
291
+ * compiled(0.452, 1n); // "45.2%"
292
+ * compiled(0.5, 0n); // "50%"
293
+ * compiled(-0.123, 2n); // "-12.30%"
294
+ * ```
295
+ */
296
+ printPercentage: import("../function.js").CallableFunctionExpr<[FloatType, IntegerType], StringType>;
297
+ };
298
+ export default _default;
299
+ //# sourceMappingURL=float.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"float.d.ts","sourceRoot":"","sources":["../../../../src/expr/libs/float.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjF,4CAA4C;;IAE1C;;;;;;;;;;;;;;;;;OAiBG;;IAMH;;;;;;;;;;;;;;;OAeG;;IAgBH;;;;;;;;;;;;;;;OAeG;;IAiBH;;;;;;;;;;;;;;;;OAgBG;;IAWH;;;;;;;;;;;;;;;OAeG;;IAMH;;;;;;;;;;;;;;;;;;OAkBG;;IA6BH;;;;;;;;;;;;;;;;;;OAkBG;;IA2BH;;;;;;;;;;;;;;;;;;OAkBG;;IA2BH;;;;;;;;;;;;;;;;;OAiBG;;IAgBH;;;;;;;;;;;;;;;;;OAiBG;;IAiCH;;;;;;;;;;;;;;;;;;OAkBG;;IA8EH;;;;;;;;;;;;;;;;;OAiBG;;IA0DH;;;;;;;;;;;;;;;;;;OAkBG;;IA8CH;;;;;;;;;;;;;;;;;;;;OAoBG;;IA2DH;;;;;;;;;;;;;;;;;;;;OAoBG;;;AAjrBL,wBA8sBC"}