affinirum 1.5.4 → 2.0.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 (243) hide show
  1. package/.cache/arrow-preview-vWvB5K/affinirum-arrow-functions.patch +155 -0
  2. package/.cache/function-syntax-tests.log +20 -0
  3. package/README.md +925 -355
  4. package/dst/Affinirum.d.ts +29 -19
  5. package/dst/Affinirum.js +399 -334
  6. package/dst/CallFrame.d.ts +12 -3
  7. package/dst/CallFrame.js +49 -10
  8. package/dst/Constant.d.ts +1 -3
  9. package/dst/Constant.js +3 -8
  10. package/dst/LexicalScope.d.ts +11 -9
  11. package/dst/LexicalScope.js +10 -6
  12. package/dst/ParserSpan.d.ts +11 -0
  13. package/dst/{ScriptSpan.js → ParserSpan.js} +8 -5
  14. package/dst/ParserState.d.ts +28 -49
  15. package/dst/ParserState.js +256 -489
  16. package/dst/Type.d.ts +34 -17
  17. package/dst/Type.js +211 -115
  18. package/dst/TypeParser.d.ts +9 -0
  19. package/dst/TypeParser.js +127 -0
  20. package/dst/Value.d.ts +1 -1
  21. package/dst/Value.js +21 -10
  22. package/dst/Variable.d.ts +16 -5
  23. package/dst/Variable.js +32 -7
  24. package/dst/atom/ArrayAtom.d.ts +10 -10
  25. package/dst/atom/ArrayAtom.js +62 -55
  26. package/dst/atom/Atom.d.ts +7 -0
  27. package/dst/atom/FunctionAtom.d.ts +13 -15
  28. package/dst/atom/FunctionAtom.js +53 -104
  29. package/dst/atom/FunctionSignature.d.ts +23 -0
  30. package/dst/atom/FunctionSignature.js +124 -0
  31. package/dst/atom/ObjectAtom.d.ts +11 -9
  32. package/dst/atom/ObjectAtom.js +73 -33
  33. package/dst/atom/PrimitiveAtom.d.ts +6 -7
  34. package/dst/atom/PrimitiveAtom.js +7 -10
  35. package/dst/cjs/Affinirum.d.ts +29 -19
  36. package/dst/cjs/Affinirum.js +398 -333
  37. package/dst/cjs/CallFrame.d.ts +12 -3
  38. package/dst/cjs/CallFrame.js +49 -10
  39. package/dst/cjs/Constant.d.ts +1 -3
  40. package/dst/cjs/Constant.js +3 -8
  41. package/dst/cjs/LexicalScope.d.ts +11 -9
  42. package/dst/cjs/LexicalScope.js +10 -6
  43. package/dst/cjs/ParserSpan.d.ts +11 -0
  44. package/dst/cjs/{ScriptSpan.js → ParserSpan.js} +10 -7
  45. package/dst/cjs/ParserState.d.ts +28 -49
  46. package/dst/cjs/ParserState.js +255 -488
  47. package/dst/cjs/Type.d.ts +34 -17
  48. package/dst/cjs/Type.js +211 -115
  49. package/dst/cjs/TypeParser.d.ts +9 -0
  50. package/dst/cjs/TypeParser.js +131 -0
  51. package/dst/cjs/Value.d.ts +1 -1
  52. package/dst/cjs/Value.js +21 -10
  53. package/dst/cjs/Variable.d.ts +16 -5
  54. package/dst/cjs/Variable.js +36 -9
  55. package/dst/cjs/atom/ArrayAtom.d.ts +10 -10
  56. package/dst/cjs/atom/ArrayAtom.js +62 -55
  57. package/dst/cjs/atom/Atom.d.ts +7 -0
  58. package/dst/cjs/atom/FunctionAtom.d.ts +13 -15
  59. package/dst/cjs/atom/FunctionAtom.js +54 -105
  60. package/dst/cjs/atom/FunctionSignature.d.ts +23 -0
  61. package/dst/cjs/atom/FunctionSignature.js +128 -0
  62. package/dst/cjs/atom/ObjectAtom.d.ts +11 -9
  63. package/dst/cjs/atom/ObjectAtom.js +73 -33
  64. package/dst/cjs/atom/PrimitiveAtom.d.ts +6 -7
  65. package/dst/cjs/atom/PrimitiveAtom.js +7 -10
  66. package/dst/cjs/dictionary/Constants.d.ts +2 -0
  67. package/dst/cjs/dictionary/Constants.js +27 -0
  68. package/dst/cjs/dictionary/Functions.d.ts +2 -0
  69. package/dst/cjs/{Functions.js → dictionary/Functions.js} +27 -25
  70. package/dst/cjs/native/Aggregable.js +10 -2
  71. package/dst/cjs/native/Array.d.ts +2 -3
  72. package/dst/cjs/native/Array.js +38 -39
  73. package/dst/cjs/native/Boolean.d.ts +1 -1
  74. package/dst/cjs/native/Boolean.js +13 -10
  75. package/dst/cjs/native/Buffer.d.ts +5 -5
  76. package/dst/cjs/native/Buffer.js +70 -46
  77. package/dst/cjs/native/Composite.d.ts +5 -0
  78. package/dst/cjs/native/Composite.js +35 -0
  79. package/dst/cjs/native/Enumerable.js +20 -8
  80. package/dst/cjs/native/Float.d.ts +3 -1
  81. package/dst/cjs/native/Float.js +51 -12
  82. package/dst/cjs/native/Integer.d.ts +4 -2
  83. package/dst/cjs/native/Integer.js +60 -25
  84. package/dst/cjs/native/Iterable.d.ts +0 -2
  85. package/dst/cjs/native/Iterable.js +9 -28
  86. package/dst/cjs/native/Number.d.ts +0 -2
  87. package/dst/cjs/native/Number.js +34 -48
  88. package/dst/cjs/native/Object.d.ts +1 -1
  89. package/dst/cjs/native/Object.js +5 -6
  90. package/dst/cjs/native/String.d.ts +7 -6
  91. package/dst/cjs/native/String.js +28 -27
  92. package/dst/cjs/native/Timestamp.d.ts +3 -3
  93. package/dst/cjs/native/Timestamp.js +34 -36
  94. package/dst/cjs/native/Unknown.d.ts +3 -3
  95. package/dst/cjs/native/Unknown.js +48 -17
  96. package/dst/cjs/native/notation/AN.d.ts +1 -1
  97. package/dst/cjs/native/notation/AN.js +37 -35
  98. package/dst/cjs/native/notation/IP.d.ts +1 -1
  99. package/dst/cjs/native/notation/IP.js +11 -12
  100. package/dst/cjs/native/notation/JSON.d.ts +1 -1
  101. package/dst/cjs/native/notation/JSON.js +7 -6
  102. package/dst/cjs/node/AccessNode.d.ts +24 -0
  103. package/dst/cjs/node/AccessNode.js +193 -0
  104. package/dst/cjs/node/ArrayNode.d.ts +7 -4
  105. package/dst/cjs/node/ArrayNode.js +26 -15
  106. package/dst/cjs/node/AssignableNode.d.ts +16 -0
  107. package/dst/cjs/node/AssignableNode.js +18 -0
  108. package/dst/cjs/node/AssignmentNode.d.ts +20 -0
  109. package/dst/cjs/node/AssignmentNode.js +66 -0
  110. package/dst/cjs/node/BlockNode.d.ts +5 -4
  111. package/dst/cjs/node/BlockNode.js +18 -11
  112. package/dst/cjs/node/CallNode.d.ts +7 -5
  113. package/dst/cjs/node/CallNode.js +40 -41
  114. package/dst/cjs/node/CastNode.d.ts +5 -6
  115. package/dst/cjs/node/CastNode.js +16 -17
  116. package/dst/cjs/node/ConstantNode.d.ts +4 -6
  117. package/dst/cjs/node/ConstantNode.js +9 -17
  118. package/dst/cjs/node/FinalNode.d.ts +19 -0
  119. package/dst/cjs/node/FinalNode.js +41 -0
  120. package/dst/cjs/node/FunctionNode.d.ts +17 -0
  121. package/dst/cjs/node/FunctionNode.js +51 -0
  122. package/dst/cjs/node/InvocationNode.d.ts +5 -0
  123. package/dst/cjs/node/InvocationNode.js +34 -0
  124. package/dst/cjs/node/JumpNode.d.ts +7 -9
  125. package/dst/cjs/node/JumpNode.js +12 -19
  126. package/dst/cjs/node/LoopNode.d.ts +7 -5
  127. package/dst/cjs/node/LoopNode.js +33 -22
  128. package/dst/cjs/node/MatchNode.d.ts +17 -0
  129. package/dst/cjs/node/MatchNode.js +65 -0
  130. package/dst/cjs/node/Node.d.ts +14 -0
  131. package/dst/cjs/{Node.js → node/Node.js} +17 -11
  132. package/dst/cjs/node/ObjectNode.d.ts +7 -4
  133. package/dst/cjs/node/ObjectNode.js +42 -11
  134. package/dst/cjs/node/{SwitchNode.d.ts → TernaryNode.d.ts} +6 -6
  135. package/dst/cjs/node/TernaryNode.js +45 -0
  136. package/dst/cjs/node/VariableNode.d.ts +10 -6
  137. package/dst/cjs/node/VariableNode.js +50 -16
  138. package/dst/dictionary/Constants.d.ts +2 -0
  139. package/dst/dictionary/Constants.js +24 -0
  140. package/dst/dictionary/Functions.d.ts +2 -0
  141. package/dst/{Functions.js → dictionary/Functions.js} +26 -24
  142. package/dst/native/Aggregable.js +11 -3
  143. package/dst/native/Array.d.ts +2 -3
  144. package/dst/native/Array.js +37 -38
  145. package/dst/native/Boolean.d.ts +1 -1
  146. package/dst/native/Boolean.js +12 -9
  147. package/dst/native/Buffer.d.ts +5 -5
  148. package/dst/native/Buffer.js +66 -42
  149. package/dst/native/Composite.d.ts +5 -0
  150. package/dst/native/Composite.js +32 -0
  151. package/dst/native/Enumerable.js +20 -8
  152. package/dst/native/Float.d.ts +3 -1
  153. package/dst/native/Float.js +48 -11
  154. package/dst/native/Integer.d.ts +4 -2
  155. package/dst/native/Integer.js +56 -23
  156. package/dst/native/Iterable.d.ts +0 -2
  157. package/dst/native/Iterable.js +8 -27
  158. package/dst/native/Number.d.ts +0 -2
  159. package/dst/native/Number.js +34 -46
  160. package/dst/native/Object.d.ts +1 -1
  161. package/dst/native/Object.js +4 -5
  162. package/dst/native/String.d.ts +7 -6
  163. package/dst/native/String.js +24 -24
  164. package/dst/native/Timestamp.d.ts +3 -3
  165. package/dst/native/Timestamp.js +31 -33
  166. package/dst/native/Unknown.d.ts +3 -3
  167. package/dst/native/Unknown.js +49 -18
  168. package/dst/native/notation/AN.d.ts +1 -1
  169. package/dst/native/notation/AN.js +37 -35
  170. package/dst/native/notation/IP.d.ts +1 -1
  171. package/dst/native/notation/IP.js +10 -11
  172. package/dst/native/notation/JSON.d.ts +1 -1
  173. package/dst/native/notation/JSON.js +6 -5
  174. package/dst/node/AccessNode.d.ts +24 -0
  175. package/dst/node/AccessNode.js +189 -0
  176. package/dst/node/ArrayNode.d.ts +7 -4
  177. package/dst/node/ArrayNode.js +26 -15
  178. package/dst/node/AssignableNode.d.ts +16 -0
  179. package/dst/node/AssignableNode.js +14 -0
  180. package/dst/node/AssignmentNode.d.ts +20 -0
  181. package/dst/node/AssignmentNode.js +62 -0
  182. package/dst/node/BlockNode.d.ts +5 -4
  183. package/dst/node/BlockNode.js +18 -11
  184. package/dst/node/CallNode.d.ts +7 -5
  185. package/dst/node/CallNode.js +40 -41
  186. package/dst/node/CastNode.d.ts +5 -6
  187. package/dst/node/CastNode.js +16 -17
  188. package/dst/node/ConstantNode.d.ts +4 -6
  189. package/dst/node/ConstantNode.js +9 -17
  190. package/dst/node/FinalNode.d.ts +19 -0
  191. package/dst/node/FinalNode.js +37 -0
  192. package/dst/node/FunctionNode.d.ts +17 -0
  193. package/dst/node/FunctionNode.js +47 -0
  194. package/dst/node/InvocationNode.d.ts +5 -0
  195. package/dst/node/InvocationNode.js +30 -0
  196. package/dst/node/JumpNode.d.ts +7 -9
  197. package/dst/node/JumpNode.js +12 -19
  198. package/dst/node/LoopNode.d.ts +7 -5
  199. package/dst/node/LoopNode.js +33 -22
  200. package/dst/node/MatchNode.d.ts +17 -0
  201. package/dst/node/MatchNode.js +61 -0
  202. package/dst/node/Node.d.ts +14 -0
  203. package/dst/node/Node.js +28 -0
  204. package/dst/node/ObjectNode.d.ts +7 -4
  205. package/dst/node/ObjectNode.js +42 -11
  206. package/dst/node/{SwitchNode.d.ts → TernaryNode.d.ts} +6 -6
  207. package/dst/node/TernaryNode.js +41 -0
  208. package/dst/node/VariableNode.d.ts +10 -6
  209. package/dst/node/VariableNode.js +50 -16
  210. package/package.json +4 -4
  211. package/dst/Atom.d.ts +0 -7
  212. package/dst/Constants.d.ts +0 -2
  213. package/dst/Constants.js +0 -24
  214. package/dst/Functions.d.ts +0 -2
  215. package/dst/Jump.d.ts +0 -1
  216. package/dst/Jump.js +0 -1
  217. package/dst/JumpException.d.ts +0 -9
  218. package/dst/JumpException.js +0 -14
  219. package/dst/Keywords.d.ts +0 -1
  220. package/dst/Keywords.js +0 -17
  221. package/dst/Node.d.ts +0 -14
  222. package/dst/Node.js +0 -22
  223. package/dst/ScriptSpan.d.ts +0 -10
  224. package/dst/cjs/Atom.d.ts +0 -7
  225. package/dst/cjs/Constants.d.ts +0 -2
  226. package/dst/cjs/Constants.js +0 -27
  227. package/dst/cjs/Functions.d.ts +0 -2
  228. package/dst/cjs/Jump.d.ts +0 -1
  229. package/dst/cjs/Jump.js +0 -2
  230. package/dst/cjs/JumpException.d.ts +0 -9
  231. package/dst/cjs/JumpException.js +0 -18
  232. package/dst/cjs/Keywords.d.ts +0 -1
  233. package/dst/cjs/Keywords.js +0 -20
  234. package/dst/cjs/Node.d.ts +0 -14
  235. package/dst/cjs/ScriptSpan.d.ts +0 -10
  236. package/dst/cjs/node/SwitchNode.js +0 -49
  237. package/dst/cjs/node/VariadicNode.d.ts +0 -4
  238. package/dst/cjs/node/VariadicNode.js +0 -10
  239. package/dst/node/SwitchNode.js +0 -45
  240. package/dst/node/VariadicNode.d.ts +0 -4
  241. package/dst/node/VariadicNode.js +0 -6
  242. /package/dst/{Atom.js → atom/Atom.js} +0 -0
  243. /package/dst/cjs/{Atom.js → atom/Atom.js} +0 -0
@@ -1,14 +1,8 @@
1
1
  import { Constant } from "../Constant.js";
2
2
  import { Type } from "../Type.js";
3
- import { boundInteger } from "./Integer.js";
3
+ import { int64 } from "./Integer.js";
4
4
  export const isSignSymbol = (c) => c === "+" || c === "-";
5
5
  export const isNumericSymbol = (c) => c >= "0" && c <= "9";
6
- export const formatLiteralNumber = (value) => {
7
- const str = value.toString();
8
- return typeof value === "number" && Number.isInteger(value) && !str.includes("e")
9
- ? `${str}.0`
10
- : str;
11
- };
12
6
  export const parseLiteralNumber = (value, offset = 0) => {
13
7
  let i = offset;
14
8
  let integer = true;
@@ -30,8 +24,8 @@ export const parseLiteralNumber = (value, offset = 0) => {
30
24
  }
31
25
  if (value.charAt(i) === "e") {
32
26
  ++i;
33
- if (isNumericSymbol(value.charAt(i))
34
- || isSignSymbol(value.charAt(i))) {
27
+ if (isNumericSymbol(value.charAt(i)) ||
28
+ isSignSymbol(value.charAt(i))) {
35
29
  ++i;
36
30
  while (isNumericSymbol(value.charAt(i))) {
37
31
  ++i;
@@ -40,69 +34,54 @@ export const parseLiteralNumber = (value, offset = 0) => {
40
34
  integer = false;
41
35
  }
42
36
  const str = value.slice(offset, i);
43
- return [integer ? boundInteger(BigInt(str)) : parseFloat(str), i];
44
- };
45
- export const formatNumber = (value, formatting) => {
46
- if (formatting) {
47
- const nformat = JSON.parse(`{${formatting}}`);
48
- if (typeof nformat === "object") {
49
- return new Intl.NumberFormat(undefined, {
50
- minimumIntegerDigits: nformat?.min_integer_digits,
51
- minimumFractionDigits: nformat?.min_fraction_digits,
52
- maximumFractionDigits: nformat?.max_fraction_digits,
53
- minimumSignificantDigits: nformat?.min_significant_digits,
54
- maximumSignificantDigits: nformat?.max_significant_digits,
55
- notation: nformat?.notation,
56
- }).format(value);
57
- }
58
- }
59
- return typeof value === "number" && Number.isInteger(value)
60
- ? `${value.toString()}.0`
61
- : value.toString();
37
+ return [integer ? int64(BigInt(str)) : parseFloat(str), i];
62
38
  };
63
- const typeComparator = Type.functionType(Type.Boolean, [Type.Number, Type.Number]);
64
- const typeOperator = Type.union(Type.functionType(Type.Float, [Type.Float, Type.Float]), Type.functionType(Type.Float, [Type.Float, Type.Integer]), Type.functionType(Type.Float, [Type.Integer, Type.Float]), Type.functionType(Type.Integer, [Type.Integer, Type.Integer]));
39
+ const typeComparator = Type.functionType([[Type.Boolean, [Type.Number, Type.Number]]]);
40
+ const typeOperator = Type.functionType([
41
+ [Type.Integer, [Type.Integer, Type.Integer]],
42
+ [Type.Float, [Type.Float, Type.Number]],
43
+ [Type.Float, [Type.Number, Type.Float]],
44
+ [Type.Number, [Type.Number, Type.Number]],
45
+ ]);
65
46
  export const funcGreaterThan = new Constant((value1, value2) => value1 > value2, typeComparator);
66
47
  export const funcLessThan = new Constant((value1, value2) => value1 < value2, typeComparator);
67
48
  export const funcGreaterOrEqual = new Constant((value1, value2) => value1 >= value2, typeComparator);
68
49
  export const funcLessOrEqual = new Constant((value1, value2) => value1 <= value2, typeComparator);
69
50
  export const funcSubtract = new Constant((value, subtrahend) => typeof value === "bigint" && typeof subtrahend === "bigint"
70
- ? boundInteger(value - subtrahend)
51
+ ? int64(value - subtrahend)
71
52
  : Number(value) - Number(subtrahend), typeOperator);
72
53
  export const funcMultiply = new Constant((value1, value2) => typeof value1 === "bigint" && typeof value2 === "bigint"
73
- ? boundInteger(value1 * value2)
54
+ ? int64(value1 * value2)
74
55
  : Number(value1) * Number(value2), typeOperator);
75
56
  export const funcDivide = new Constant((value, divisor) => typeof value === "bigint" && typeof divisor === "bigint"
76
- ? boundInteger(value / divisor)
57
+ ? int64(value / divisor)
77
58
  : Number(value) / Number(divisor), typeOperator);
78
59
  export const funcRemainder = new Constant((value, divisor) => typeof value === "bigint" && typeof divisor === "bigint"
79
- ? boundInteger(value % divisor)
60
+ ? value % divisor
80
61
  : Number(value) % Number(divisor), typeOperator);
81
62
  export const funcModulo = new Constant((value, divisor) => typeof value === "bigint" && typeof divisor === "bigint"
82
- ? boundInteger((value % divisor + divisor) % divisor)
63
+ ? (value % divisor + divisor) % divisor
83
64
  : (Number(value) % Number(divisor) + Number(divisor)) % Number(divisor), typeOperator);
84
65
  export const funcPower = new Constant((value, exponent) => typeof value === "bigint" && typeof exponent === "bigint"
85
- ? boundInteger(value ** BigInt(exponent))
66
+ ? int64(value ** exponent)
86
67
  : Number(value) ** Number(exponent), typeOperator);
87
68
  export const funcRoot = new Constant((value, exponent) => {
88
69
  if (exponent <= 0) {
89
70
  return undefined;
90
71
  }
91
72
  if (typeof value === "bigint" && typeof exponent === "bigint") {
92
- const v = boundInteger(value);
93
- const e = boundInteger(exponent);
94
- const negative = v < 0n;
95
- if (negative && e % 2n === 0n) {
73
+ const negative = value < 0n;
74
+ if (negative && exponent % 2n === 0n) {
96
75
  return undefined;
97
76
  }
98
- const magnitude = negative ? -v : v;
99
- if (magnitude <= 1n || e === 1n) {
100
- return v;
77
+ const magnitude = negative ? -value : value;
78
+ if (magnitude <= 1n || exponent === 1n) {
79
+ return value;
101
80
  }
102
81
  let low = 0n, high = magnitude, result = 0n;
103
82
  while (low <= high) {
104
83
  const mid = low + high >> 1n;
105
- const midPow = mid ** e;
84
+ const midPow = mid ** exponent;
106
85
  if (midPow === magnitude) {
107
86
  return negative ? -mid : mid;
108
87
  }
@@ -124,5 +103,14 @@ export const funcRoot = new Constant((value, exponent) => {
124
103
  return (v < 0 || Object.is(v, -0)) && odd
125
104
  ? -Math.pow(-v, 1 / e)
126
105
  : Math.pow(v, 1 / e);
127
- }, typeOperator);
128
- export const funcNegate = new Constant((value) => value == null ? undefined : typeof value === "number" ? -value : boundInteger(-value), Type.union(Type.functionType(Type.Float, [Type.Float]), Type.functionType(Type.Integer, [Type.Integer])));
106
+ }, Type.functionType([
107
+ [Type.OptionalInteger, [Type.Integer, Type.Integer]],
108
+ [Type.OptionalFloat, [Type.Float, Type.Number]],
109
+ [Type.OptionalFloat, [Type.Number, Type.Float]],
110
+ [Type.OptionalNumber, [Type.Number, Type.Number]],
111
+ ]));
112
+ export const funcNegate = new Constant((value) => value == null ? undefined : typeof value === "number" ? -value : int64(-value), Type.functionType([
113
+ [Type.Float, [Type.Float]],
114
+ [Type.Integer, [Type.Integer]],
115
+ [Type.Number, [Type.Number]],
116
+ ]));
@@ -2,4 +2,4 @@ import { Constant } from "../Constant.js";
2
2
  export declare const funcEntries: Constant;
3
3
  export declare const funcKeys: Constant;
4
4
  export declare const funcValues: Constant;
5
- export declare const constObject: any;
5
+ export declare const globObject: any;
@@ -1,11 +1,10 @@
1
1
  import { Constant } from "../Constant.js";
2
2
  import { Type } from "../Type.js";
3
- const typeAccessor = Type.functionType(Type.Array, [Type.Object]);
4
- const typeObjectOrArray = Type.union(Type.Object, Type.arrayType([Type.Object]));
3
+ const typeAccessor = Type.functionType([[Type.Array, [Type.Object]]]);
5
4
  export const funcEntries = new Constant((value) => value ? Object.entries(value) : undefined, typeAccessor);
6
- export const funcKeys = new Constant((value) => value ? Object.keys(value) : undefined, Type.functionType(Type.arrayType([Type.String]), [Type.Object]));
5
+ export const funcKeys = new Constant((value) => value ? Object.keys(value) : undefined, Type.functionType([[Type.arrayType(Type.String), [Type.Object]]]));
7
6
  export const funcValues = new Constant((value) => value ? Object.values(value) : undefined, typeAccessor);
8
- const funcMerge = new Constant((values) => values.flat().reduce((acc, val) => Object.assign(acc, val), Object.create(null)), Type.functionType(Type.Object, [Type.arrayType([typeObjectOrArray])], true));
9
- export const constObject = Object.assign(Object.create(null), {
7
+ const funcMerge = new Constant((...values) => values.reduce((acc, val) => Object.assign(acc, val), Object.create(null)), Type.functionType([[Type.Object, [Type.arrayType(Type.Object)], true]]));
8
+ export const globObject = Object.assign(Object.create(null), {
10
9
  Merge: funcMerge,
11
10
  });
@@ -1,9 +1,10 @@
1
1
  import { Constant } from "../Constant.js";
2
2
  export type StringEncoding = "utf8" | "sbcs" | "ucs2" | "ucs2le";
3
3
  export declare const isAlphanumericSymbol: (c: string) => boolean;
4
- export declare const isTokenStartSymbol: (c: string) => boolean;
5
- export declare const isTokenSymbol: (c: string) => boolean;
4
+ export declare const isIdentifierStartSymbol: (c: string) => boolean;
5
+ export declare const isIdentifierSymbol: (c: string) => boolean;
6
6
  export declare const isHexadecimalSymbol: (c: string) => boolean;
7
+ export declare const isWhiteSpaceSymbol: (c: string) => c is "\t" | "\n" | "\r" | "\f" | "\v" | " ";
7
8
  export declare const formatLiteralString: (value: string) => string;
8
9
  export declare const parseLiteralString: (value: string, offset?: number) => readonly [string, number];
9
10
  export declare const replaceWith: (value?: string, replacement?: string, ...search: string[]) => string | undefined;
@@ -13,11 +14,11 @@ export declare const startsWithString: (value?: string, search?: string, startPo
13
14
  export declare const endsWithString: (value?: string, search?: string, endPos?: number, ignoreCaseSpaceEtc?: boolean) => boolean;
14
15
  export declare const encodeString: (value: string, encoding?: StringEncoding) => ArrayBuffer;
15
16
  export declare const funcLike: Constant;
16
- export declare const funcUnlike: Constant;
17
+ export declare const funcNotLike: Constant;
17
18
  export declare const funcStartsWith: Constant;
18
19
  export declare const funcEndsWith: Constant;
19
- export declare const funcChar: Constant;
20
- export declare const funcCharCode: Constant;
20
+ export declare const funcCharAt: Constant;
21
+ export declare const funcCharCodeAt: Constant;
21
22
  export declare const funcTrim: Constant;
22
23
  export declare const funcTrimStart: Constant;
23
24
  export declare const funcTrimEnd: Constant;
@@ -25,4 +26,4 @@ export declare const funcLowerCase: Constant;
25
26
  export declare const funcUpperCase: Constant;
26
27
  export declare const funcSplit: Constant;
27
28
  export declare const funcReplaceWith: Constant;
28
- export declare const constString: any;
29
+ export declare const globString: any;
@@ -1,10 +1,11 @@
1
1
  import { Constant } from "../Constant.js";
2
2
  import { Type } from "../Type.js";
3
3
  import { createInteger } from "./Integer.js";
4
- export const isAlphanumericSymbol = (c) => c >= "a" && c <= "z" || c >= "0" && c <= "9";
5
- export const isTokenStartSymbol = (c) => c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "_" || c === "#" || c === "$";
6
- export const isTokenSymbol = (c) => isTokenStartSymbol(c) || c >= "0" && c <= "9";
4
+ export const isAlphanumericSymbol = (c) => c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9";
5
+ export const isIdentifierStartSymbol = (c) => c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "_" || c === "$";
6
+ export const isIdentifierSymbol = (c) => isIdentifierStartSymbol(c) || c >= "0" && c <= "9";
7
7
  export const isHexadecimalSymbol = (c) => c >= "0" && c <= "9" || c >= "a" && c <= "f" || c >= "A" && c <= "F";
8
+ export const isWhiteSpaceSymbol = (c) => c === " " || c === "\t" || c === "\n" || c === "\r" || c === "\v" || c === "\f";
8
9
  export const formatLiteralString = (value) => {
9
10
  let str = "\"";
10
11
  for (let i = 0; i < value.length; ++i) {
@@ -291,36 +292,35 @@ const decodeString = (value, encoding = "utf8", byteOffset, byteLength) => {
291
292
  }
292
293
  return str;
293
294
  };
294
- const typeStringEquator = Type.functionType(Type.Boolean, [Type.String, Type.String]);
295
- const typeStringComparator = Type.functionType(Type.Boolean, [Type.String, Type.String, Type.OptionalInteger, Type.OptionalBoolean]);
296
- const typeStringMutator = Type.functionType(Type.String, [Type.String]);
297
- const typeStringOrArray = Type.union(Type.String, Type.arrayType([Type.String]));
295
+ const typeStringEquator = Type.functionType([[Type.Boolean, [Type.String, Type.String]]]);
296
+ const typeStringComparator = Type.functionType([[Type.Boolean, [Type.String, Type.String, Type.OptionalInteger, Type.OptionalBoolean]]]);
297
+ const typeStringMutator = Type.functionType([[Type.String, [Type.String]]]);
298
298
  export const funcLike = new Constant((value1, value2) => equateStrings(value1, value2, true), typeStringEquator);
299
- export const funcUnlike = new Constant((value1, value2) => !equateStrings(value1, value2, true), typeStringEquator);
299
+ export const funcNotLike = new Constant((value1, value2) => !equateStrings(value1, value2, true), typeStringEquator);
300
300
  export const funcStartsWith = new Constant((value, search, start, ignoreCaseSpaceEtc) => startsWithString(value, search, start == null ? undefined : Number(start), ignoreCaseSpaceEtc), typeStringComparator);
301
301
  export const funcEndsWith = new Constant((value, search, end, ignoreCaseSpaceEtc) => endsWithString(value, search, end == null ? undefined : Number(end), ignoreCaseSpaceEtc), typeStringComparator);
302
- export const funcChar = new Constant((value, pos) => value == null
302
+ export const funcCharAt = new Constant((value, pos) => value == null
303
303
  ? undefined
304
- : value.charAt(pos < 0 ? value.length + Number(pos) : Number(pos)), Type.functionType(Type.OptionalString, [Type.String, Type.Integer]));
305
- export const funcCharCode = new Constant((value, pos) => value == null
304
+ : value.charAt(pos < 0 ? value.length + Number(pos) : Number(pos)), Type.functionType([[Type.OptionalString, [Type.String, Type.Integer]]]));
305
+ export const funcCharCodeAt = new Constant((value, pos) => value == null
306
306
  ? undefined
307
- : createInteger(value.charCodeAt(pos < 0 ? value.length + Number(pos) : Number(pos))), Type.functionType(Type.OptionalInteger, [Type.String, Type.Integer]));
307
+ : createInteger(value.charCodeAt(pos < 0 ? value.length + Number(pos) : Number(pos))), Type.functionType([[Type.OptionalInteger, [Type.String, Type.Integer]]]));
308
308
  export const funcTrim = new Constant((value) => value?.trim(), typeStringMutator);
309
309
  export const funcTrimStart = new Constant((value) => value?.trimStart(), typeStringMutator);
310
310
  export const funcTrimEnd = new Constant((value) => value?.trimEnd(), typeStringMutator);
311
311
  export const funcLowerCase = new Constant((value) => value?.toLowerCase(), typeStringMutator);
312
312
  export const funcUpperCase = new Constant((value) => value?.toUpperCase(), typeStringMutator);
313
- export const funcSplit = new Constant((value, separator = " ") => value?.split(separator) ?? [], Type.functionType(Type.arrayType([Type.String]), [Type.String, Type.OptionalString]));
314
- export const funcReplaceWith = new Constant((value, replacement, search) => replaceWith(value, replacement, ...search.flat()), Type.functionType(Type.String, [Type.String, Type.String, Type.arrayType([typeStringOrArray])], true));
315
- const funcAlphanum = new Constant((value) => {
316
- if (!value) {
313
+ export const funcSplit = new Constant((value, separator = " ") => value?.split(separator) ?? [], Type.functionType([[Type.arrayType(Type.String), [Type.String, Type.OptionalString]]]));
314
+ export const funcReplaceWith = new Constant((value, replacement, ...search) => replaceWith(value, replacement, ...search), Type.functionType([[Type.String, [Type.String, Type.String, Type.arrayType(Type.String)], true]]));
315
+ const funcAlphanumeric = new Constant((value) => {
316
+ if (value == null) {
317
317
  return undefined;
318
318
  }
319
- const str = value.toLowerCase();
320
319
  let result = "";
321
- for (let i = 0; i < str.length; ++i) {
322
- if (isAlphanumericSymbol(str[i])) {
323
- result += value[i];
320
+ for (let i = 0; i < value.length; ++i) {
321
+ const c = value[i];
322
+ if (isAlphanumericSymbol(c)) {
323
+ result += c.toLowerCase();
324
324
  }
325
325
  }
326
326
  return result;
@@ -332,10 +332,10 @@ const funcRandomString = new Constant((value) => {
332
332
  str += Math.random().toString(36).slice(2);
333
333
  }
334
334
  return str.slice(0, length);
335
- }, Type.functionType(Type.String, [Type.Integer]), false);
336
- const funcDecodeString = new Constant((value, encoding = "utf8", byteOffset, byteLength) => decodeString(value, encoding, byteOffset == null ? undefined : Number(byteOffset), byteLength == null ? undefined : Number(byteLength)), Type.functionType(Type.OptionalString, [Type.OptionalBuffer, Type.OptionalString, Type.OptionalInteger, Type.OptionalInteger]));
337
- export const constString = Object.assign(Object.create(null), {
338
- Alphanum: funcAlphanum,
335
+ }, Type.functionType([[Type.String, [Type.Integer]]], true));
336
+ const funcDecodeString = new Constant((value, encoding = "utf8", byteOffset, byteLength) => decodeString(value, encoding, byteOffset == null ? undefined : Number(byteOffset), byteLength == null ? undefined : Number(byteLength)), Type.functionType([[Type.OptionalString, [Type.OptionalBuffer, Type.OptionalString, Type.OptionalInteger, Type.OptionalInteger]]]));
337
+ export const globString = Object.assign(Object.create(null), {
338
+ Alphanumeric: funcAlphanumeric,
339
339
  Random: funcRandomString,
340
340
  Decode: funcDecodeString,
341
341
  });
@@ -1,10 +1,10 @@
1
1
  import { Constant } from "../Constant.js";
2
2
  export type TimestampEncoding = "i32" | "i32le" | "i64" | "i64le";
3
- export declare const formatLiteralTimestamp: (value: Date) => string;
4
- export declare const parseLiteralTimestamp: (value: string, offset?: number) => readonly [Date, number];
5
3
  export declare const encodeTimestamp: (value: Date, encoding?: TimestampEncoding) => ArrayBuffer;
6
4
  export declare const decodeTimestamp: (value?: ArrayBuffer, encoding?: TimestampEncoding, byteOffset?: number) => Date | undefined;
7
5
  export declare const formatTimestamp: (value: Date, template?: string) => string;
6
+ export declare const formatLiteralTimestamp: (value: Date) => string;
7
+ export declare const parseLiteralTimestamp: (value: string, offset?: number) => readonly [Date, number];
8
8
  export declare const funcYear: Constant;
9
9
  export declare const funcMonth: Constant;
10
10
  export declare const funcMonthIndex: Constant;
@@ -19,4 +19,4 @@ export declare const funcDaysSince: Constant;
19
19
  export declare const funcHoursSince: Constant;
20
20
  export declare const funcMinutesSince: Constant;
21
21
  export declare const funcSecondsSince: Constant;
22
- export declare const constTimestamp: any;
22
+ export declare const globTimestamp: any;
@@ -1,39 +1,14 @@
1
1
  import { Constant } from "../Constant.js";
2
2
  import { Type } from "../Type.js";
3
- import { boundInteger } from "./Integer.js";
4
3
  import { isNumericSymbol } from "./Number.js";
5
4
  const minuteMilliseconds = 60000;
6
- const typeTimestampPart = Type.functionType(Type.Integer, [Type.Timestamp, Type.OptionalBoolean]);
7
- const typeTimestampSince = Type.functionType(Type.Float, [Type.Timestamp, Type.Timestamp]);
5
+ const typeTimestampPart = Type.functionType([[Type.Integer, [Type.Timestamp, Type.OptionalBoolean]]]);
6
+ const typeTimestampSince = Type.functionType([[Type.Float, [Type.Timestamp, Type.Timestamp]]]);
8
7
  const isDateSeparatorSymbol = (c) => c === "-";
9
8
  const isTimeSeparatorSymbol = (c) => c === ":";
10
9
  const isDateTimeSeparatorSymbol = (c) => c === "T" || c === " " || c === "@";
11
10
  const isDateSymbol = (c) => isNumericSymbol(c) || isDateSeparatorSymbol(c);
12
11
  const isTimeSymbol = (c) => isNumericSymbol(c) || isTimeSeparatorSymbol(c);
13
- export const formatLiteralTimestamp = (value) => `@${formatTimestamp(value)}`;
14
- export const parseLiteralTimestamp = (value, offset = 0) => {
15
- let i = offset + 1;
16
- while (isDateSymbol(value.charAt(i))) {
17
- ++i;
18
- }
19
- if (isDateTimeSeparatorSymbol(value.charAt(i))) {
20
- ++i;
21
- while (isTimeSymbol(value.charAt(i))) {
22
- ++i;
23
- }
24
- if (value.charAt(i) === "."
25
- && isNumericSymbol(value.charAt(i + 1))) {
26
- ++i;
27
- while (isNumericSymbol(value.charAt(i))) {
28
- ++i;
29
- }
30
- if (value.charAt(i) === "Z") {
31
- ++i;
32
- }
33
- }
34
- }
35
- return [new Date(value.slice(offset + 1, i)), i];
36
- };
37
12
  export const encodeTimestamp = (value, encoding = "i64") => {
38
13
  const littleEndian = encoding.endsWith("le");
39
14
  switch (encoding) {
@@ -121,7 +96,30 @@ const parseTimestamp = (value) => {
121
96
  const date = new Date(value);
122
97
  return isNaN(date.getTime()) ? undefined : date;
123
98
  };
124
- const funcNow = new Constant(() => new Date(), Type.functionType(Type.Timestamp, []), false);
99
+ export const formatLiteralTimestamp = (value) => `@${formatTimestamp(value)}`;
100
+ export const parseLiteralTimestamp = (value, offset = 0) => {
101
+ let i = offset + 1;
102
+ while (isDateSymbol(value.charAt(i))) {
103
+ ++i;
104
+ }
105
+ if (isDateTimeSeparatorSymbol(value.charAt(i))) {
106
+ ++i;
107
+ while (isTimeSymbol(value.charAt(i))) {
108
+ ++i;
109
+ }
110
+ if (value.charAt(i) === "." && isNumericSymbol(value.charAt(i + 1))) {
111
+ ++i;
112
+ while (isNumericSymbol(value.charAt(i))) {
113
+ ++i;
114
+ }
115
+ }
116
+ if (value.charAt(i) === "Z") {
117
+ ++i;
118
+ }
119
+ }
120
+ return [new Date(value.slice(offset + 1, i)), i];
121
+ };
122
+ const funcNow = new Constant(() => new Date(), Type.functionType([[Type.Timestamp, []]], true));
125
123
  export const funcYear = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCFullYear() : value.getFullYear()) : undefined, typeTimestampPart);
126
124
  export const funcMonth = new Constant((value, utc = false) => value ? BigInt(1 + (utc ? value.getUTCMonth() : value.getMonth())) : undefined, typeTimestampPart);
127
125
  export const funcMonthIndex = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCMonth() : value.getMonth()) : undefined, typeTimestampPart);
@@ -131,7 +129,7 @@ export const funcHour = new Constant((value, utc = false) => value ? BigInt(utc
131
129
  export const funcMinute = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCMinutes() : value.getMinutes()) : undefined, typeTimestampPart);
132
130
  export const funcSecond = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCSeconds() : value.getSeconds()) : undefined, typeTimestampPart);
133
131
  export const funcMillisecond = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCMilliseconds() : value.getMilliseconds()) : undefined, typeTimestampPart);
134
- export const funcEpochTime = new Constant((value, epoch = new Date(0)) => value ? boundInteger(BigInt(value.getTime() - epoch.getTime())) : undefined, Type.functionType(Type.Integer, [Type.Timestamp, Type.OptionalTimestamp]));
132
+ export const funcEpochTime = new Constant((value, epoch = new Date(0)) => value ? BigInt(value.getTime() - epoch.getTime()) : undefined, Type.functionType([[Type.Integer, [Type.Timestamp, Type.OptionalTimestamp]]]));
135
133
  export const funcDaysSince = new Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 86400000.0, typeTimestampSince);
136
134
  export const funcHoursSince = new Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 3600000.0, typeTimestampSince);
137
135
  export const funcMinutesSince = new Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 60000.0, typeTimestampSince);
@@ -139,10 +137,10 @@ export const funcSecondsSince = new Constant((value1, value2) => (value1?.getTim
139
137
  const funcEpochTimestamp = new Constant((value, epoch = new Date(0)) => {
140
138
  const ts = new Date(Number(value ?? 0) + epoch?.getTime());
141
139
  return Number.isNaN(ts.getTime()) ? undefined : ts;
142
- }, Type.functionType(Type.Timestamp, [Type.Number, Type.OptionalTimestamp]));
143
- const funcDecodeTimestamp = new Constant((value, encoding = "i64", byteOffset) => decodeTimestamp(value, encoding, byteOffset == null ? undefined : Number(byteOffset)), Type.functionType(Type.OptionalTimestamp, [Type.OptionalBuffer, Type.OptionalString, Type.OptionalInteger]));
144
- const funcParseTimestamp = new Constant((value) => parseTimestamp(value), Type.functionType(Type.OptionalTimestamp, [Type.OptionalString]));
145
- export const constTimestamp = Object.assign(Object.create(null), {
140
+ }, Type.functionType([[Type.Timestamp, [Type.Number, Type.OptionalTimestamp]]]));
141
+ const funcDecodeTimestamp = new Constant((value, encoding = "i64", byteOffset) => decodeTimestamp(value, encoding, byteOffset == null ? undefined : Number(byteOffset)), Type.functionType([[Type.OptionalTimestamp, [Type.OptionalBuffer, Type.OptionalString, Type.OptionalInteger]]]));
142
+ const funcParseTimestamp = new Constant((value) => parseTimestamp(value), Type.functionType([[Type.OptionalTimestamp, [Type.OptionalString]]]));
143
+ export const globTimestamp = Object.assign(Object.create(null), {
146
144
  Now: funcNow,
147
145
  Epoch: funcEpochTimestamp,
148
146
  Decode: funcDecodeTimestamp,
@@ -4,11 +4,11 @@ import { FloatEncoding } from "./Float.js";
4
4
  import { IntegerEncoding } from "./Integer.js";
5
5
  import { StringEncoding } from "./String.js";
6
6
  import { TimestampEncoding } from "./Timestamp.js";
7
- export declare const equate: (value1: Value, value2: Value) => boolean;
7
+ export declare const equals: (value1: Value, value2: Value, pairs?: WeakMap<object, WeakSet<object>>) => boolean;
8
8
  export declare const encode: (value: Value, encoding?: FloatEncoding | IntegerEncoding | TimestampEncoding | StringEncoding) => ArrayBuffer;
9
9
  export declare const format: (value: Value, formatting?: string) => string;
10
10
  export declare const funcCoalesce: Constant;
11
- export declare const funcEqual: Constant;
12
- export declare const funcNotEqual: Constant;
11
+ export declare const funcEquals: Constant;
12
+ export declare const funcNotEquals: Constant;
13
13
  export declare const funcEncode: Constant;
14
14
  export declare const funcFormat: Constant;
@@ -1,12 +1,11 @@
1
1
  import { Constant } from "../Constant.js";
2
2
  import { Type } from "../Type.js";
3
- import { formatBuffer, concatBuffers, equateBuffers, EmptyBuffer } from "./Buffer.js";
4
- import { encodeFloat } from "./Float.js";
5
- import { encodeInteger } from "./Integer.js";
6
- import { formatNumber } from "./Number.js";
3
+ import { formatBuffer, concatBuffers, equalsBuffers, EmptyBuffer } from "./Buffer.js";
4
+ import { encodeFloat, formatFloat } from "./Float.js";
5
+ import { encodeInteger, formatInteger } from "./Integer.js";
7
6
  import { encodeString } from "./String.js";
8
7
  import { encodeTimestamp, formatTimestamp } from "./Timestamp.js";
9
- export const equate = (value1, value2) => {
8
+ export const equals = (value1, value2, pairs) => {
10
9
  if (value1 == null || value2 == null) {
11
10
  return value1 == value2;
12
11
  }
@@ -22,7 +21,10 @@ export const equate = (value1, value2) => {
22
21
  if (typeof value1 === "number") {
23
22
  return isNaN(value1) && isNaN(value2) ? true : value1 === value2;
24
23
  }
25
- if (typeof value1 === "boolean" || typeof value1 === "bigint" || typeof value1 === "string" || typeof value1 === "function") {
24
+ if (typeof value1 === "bigint") {
25
+ return value1 === value2;
26
+ }
27
+ if (typeof value1 === "boolean" || typeof value1 === "string" || typeof value1 === "function") {
26
28
  return value1 === value2;
27
29
  }
28
30
  if (value1 instanceof Date && value2 instanceof Date) {
@@ -32,15 +34,25 @@ export const equate = (value1, value2) => {
32
34
  return false;
33
35
  }
34
36
  if (value1 instanceof ArrayBuffer && value2 instanceof ArrayBuffer) {
35
- return equateBuffers(value1, value2);
37
+ return equalsBuffers(value1, value2);
36
38
  }
37
39
  if (value1 instanceof ArrayBuffer || value2 instanceof ArrayBuffer) {
38
40
  return false;
39
41
  }
42
+ pairs ??= new WeakMap();
43
+ let matches = pairs.get(value1);
44
+ if (matches?.has(value2)) {
45
+ return true;
46
+ }
47
+ if (!matches) {
48
+ matches = new WeakSet();
49
+ pairs.set(value1, matches);
50
+ }
51
+ matches.add(value2);
40
52
  if (Array.isArray(value1) && Array.isArray(value2)) {
41
53
  if (value1.length === value2.length) {
42
54
  for (let i = 0; i < value1.length; ++i) {
43
- if (!equate(value1[i], value2[i])) {
55
+ if (!equals(value1[i], value2[i], pairs)) {
44
56
  return false;
45
57
  }
46
58
  }
@@ -51,9 +63,9 @@ export const equate = (value1, value2) => {
51
63
  if (Array.isArray(value1) || Array.isArray(value2)) {
52
64
  return false;
53
65
  }
54
- const props = new Set([...Object.getOwnPropertyNames(value1), ...Object.getOwnPropertyNames(value2)]);
66
+ const props = new Set([...Object.keys(value1), ...Object.keys(value2)]);
55
67
  for (const prop of props) {
56
- if (!equate(value1[prop], value2[prop])) {
68
+ if (!equals(value1[prop], value2[prop], pairs)) {
57
69
  return false;
58
70
  }
59
71
  }
@@ -87,9 +99,9 @@ export const format = (value, formatting) => value == null
87
99
  : value instanceof Date
88
100
  ? formatTimestamp(value, formatting)
89
101
  : typeof value === "number"
90
- ? formatNumber(value, formatting)
102
+ ? formatFloat(value, formatting)
91
103
  : typeof value === "bigint"
92
- ? formatNumber(value, formatting)
104
+ ? formatInteger(value, formatting)
93
105
  : value instanceof ArrayBuffer
94
106
  ? formatBuffer(value, formatting)
95
107
  : typeof value === "string"
@@ -101,9 +113,28 @@ export const format = (value, formatting) => value == null
101
113
  .map(([k, v]) => format(k, formatting) + format(v, formatting))
102
114
  .reduce((acc, val) => acc + val, "")
103
115
  : "";
104
- const typeEquator = Type.functionType(Type.Boolean, [Type.Unknown, Type.Unknown]);
105
- export const funcCoalesce = new Constant((value, valueOtherwise) => value ?? valueOtherwise, Type.union(Type.functionType(Type.Unknown, [Type.Unknown, Type.Unknown]), Type.functionType(Type.OptionalFloat, [Type.OptionalFloat, Type.OptionalFloat]), Type.functionType(Type.OptionalBoolean, [Type.OptionalBoolean, Type.OptionalBoolean]), Type.functionType(Type.OptionalTimestamp, [Type.OptionalTimestamp, Type.OptionalTimestamp]), Type.functionType(Type.OptionalInteger, [Type.OptionalInteger, Type.OptionalInteger]), Type.functionType(Type.OptionalBuffer, [Type.OptionalBuffer, Type.OptionalBuffer]), Type.functionType(Type.OptionalString, [Type.OptionalString, Type.OptionalString]), Type.functionType(Type.OptionalArray, [Type.OptionalArray, Type.OptionalArray]), Type.functionType(Type.OptionalObject, [Type.OptionalObject, Type.OptionalObject]), Type.functionType(Type.OptionalFunction, [Type.OptionalFunction, Type.OptionalFunction])));
106
- export const funcEqual = new Constant((value1, value2) => equate(value1, value2), typeEquator);
107
- export const funcNotEqual = new Constant((value1, value2) => !equate(value1, value2), typeEquator);
108
- export const funcEncode = new Constant((value, encoding) => encode(value, encoding), Type.union(Type.functionType(Type.Buffer, [Type.Void, Type.OptionalString]), Type.functionType(Type.Buffer, [Type.Boolean]), Type.functionType(Type.Buffer, [Type.Timestamp, Type.OptionalString]), Type.functionType(Type.Buffer, [Type.Float, Type.OptionalString]), Type.functionType(Type.Buffer, [Type.Integer, Type.OptionalString]), Type.functionType(Type.Buffer, [Type.Buffer]), Type.functionType(Type.Buffer, [Type.String, Type.OptionalString]), Type.functionType(Type.Buffer, [Type.Array, Type.OptionalString]), Type.functionType(Type.Buffer, [Type.Object, Type.OptionalString]), Type.functionType(Type.Buffer, [Type.Function])));
109
- export const funcFormat = new Constant((value, formatting) => format(value, formatting), Type.union(Type.functionType(Type.String, [Type.Void, Type.OptionalString]), Type.functionType(Type.String, [Type.Boolean]), Type.functionType(Type.String, [Type.Timestamp, Type.OptionalString]), Type.functionType(Type.String, [Type.Float, Type.OptionalString]), Type.functionType(Type.String, [Type.Integer, Type.OptionalString]), Type.functionType(Type.String, [Type.Buffer, Type.OptionalString]), Type.functionType(Type.String, [Type.String]), Type.functionType(Type.String, [Type.Array, Type.OptionalString]), Type.functionType(Type.String, [Type.Object, Type.OptionalString]), Type.functionType(Type.String, [Type.Function])));
116
+ const typeEquator = Type.functionType([[Type.Boolean, [Type.Any, Type.Any]]]);
117
+ export const funcCoalesce = new Constant((value, valueOtherwise) => value ?? valueOtherwise, Type.functionType([
118
+ [Type.Any, [Type.Any, Type.Any]],
119
+ [Type.OptionalFloat, [Type.OptionalFloat, Type.OptionalFloat]],
120
+ [Type.OptionalBoolean, [Type.OptionalBoolean, Type.OptionalBoolean]],
121
+ [Type.OptionalTimestamp, [Type.OptionalTimestamp, Type.OptionalTimestamp]],
122
+ [Type.OptionalInteger, [Type.OptionalInteger, Type.OptionalInteger]],
123
+ [Type.OptionalBuffer, [Type.OptionalBuffer, Type.OptionalBuffer]],
124
+ [Type.OptionalString, [Type.OptionalString, Type.OptionalString]],
125
+ [Type.OptionalArray, [Type.OptionalArray, Type.OptionalArray]],
126
+ [Type.OptionalObject, [Type.OptionalObject, Type.OptionalObject]],
127
+ [Type.OptionalFunction, [Type.OptionalFunction, Type.OptionalFunction]],
128
+ ]));
129
+ export const funcEquals = new Constant((value1, value2) => equals(value1, value2), typeEquator);
130
+ export const funcNotEquals = new Constant((value1, value2) => !equals(value1, value2), typeEquator);
131
+ const typeWithEncoding = Type.union(Type.Null, Type.Timestamp, Type.Number, Type.String, Type.Composite);
132
+ const typeWithFormatting = Type.union(Type.Null, Type.Timestamp, Type.Number, Type.Buffer, Type.Composite);
133
+ export const funcEncode = new Constant((value, encoding) => encode(value, encoding), Type.functionType([
134
+ [Type.Buffer, [Type.Any]],
135
+ [Type.Buffer, [typeWithEncoding, Type.OptionalString]],
136
+ ]));
137
+ export const funcFormat = new Constant((value, formatting) => format(value, formatting), Type.functionType([
138
+ [Type.String, [Type.Any]],
139
+ [Type.String, [typeWithFormatting, Type.OptionalString]],
140
+ ]));
@@ -1,4 +1,4 @@
1
1
  import { Value } from "../../Value.js";
2
2
  export declare const formatAN: (value: Value, whitespace?: string) => string;
3
3
  export declare const parseAN: (value: string | undefined) => Value;
4
- export declare const constAN: any;
4
+ export declare const globAN: any;