affinirum 1.5.3 → 1.5.4

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 (65) hide show
  1. package/dst/Affinirum.js +8 -7
  2. package/dst/LexicalScope.d.ts +5 -3
  3. package/dst/LexicalScope.js +9 -5
  4. package/dst/cjs/Affinirum.d.ts +88 -0
  5. package/dst/cjs/Affinirum.js +8 -7
  6. package/dst/cjs/Atom.d.ts +7 -0
  7. package/dst/cjs/CallFrame.d.ts +11 -0
  8. package/dst/cjs/Constant.d.ts +13 -0
  9. package/dst/cjs/Constants.d.ts +2 -0
  10. package/dst/cjs/Functions.d.ts +2 -0
  11. package/dst/cjs/Jump.d.ts +1 -0
  12. package/dst/cjs/JumpException.d.ts +9 -0
  13. package/dst/cjs/Keywords.d.ts +1 -0
  14. package/dst/cjs/LexicalScope.d.ts +15 -0
  15. package/dst/cjs/LexicalScope.js +9 -5
  16. package/dst/cjs/Node.d.ts +14 -0
  17. package/dst/cjs/ParserState.d.ts +60 -0
  18. package/dst/cjs/ScriptSpan.d.ts +10 -0
  19. package/dst/cjs/Type.d.ts +71 -0
  20. package/dst/cjs/Value.d.ts +5 -0
  21. package/dst/cjs/Variable.d.ts +9 -0
  22. package/dst/cjs/atom/ArrayAtom.d.ts +16 -0
  23. package/dst/cjs/atom/FunctionAtom.d.ts +22 -0
  24. package/dst/cjs/atom/ObjectAtom.d.ts +14 -0
  25. package/dst/cjs/atom/PrimitiveAtom.d.ts +12 -0
  26. package/dst/cjs/index.d.ts +3 -0
  27. package/dst/cjs/native/Aggregable.d.ts +4 -0
  28. package/dst/cjs/native/Array.d.ts +16 -0
  29. package/dst/cjs/native/Boolean.d.ts +6 -0
  30. package/dst/cjs/native/Buffer.d.ts +13 -0
  31. package/dst/cjs/native/Buffer.js +1 -1
  32. package/dst/cjs/native/Enumerable.d.ts +4 -0
  33. package/dst/cjs/native/Float.d.ts +5 -0
  34. package/dst/cjs/native/Integer.d.ts +7 -0
  35. package/dst/cjs/native/Iterable.d.ts +5 -0
  36. package/dst/cjs/native/Number.d.ts +26 -0
  37. package/dst/cjs/native/Number.js +1 -1
  38. package/dst/cjs/native/Object.d.ts +5 -0
  39. package/dst/cjs/native/String.d.ts +28 -0
  40. package/dst/cjs/native/String.js +97 -48
  41. package/dst/cjs/native/Timestamp.d.ts +22 -0
  42. package/dst/cjs/native/Unknown.d.ts +14 -0
  43. package/dst/cjs/native/Unknown.js +10 -1
  44. package/dst/cjs/native/notation/AN.d.ts +4 -0
  45. package/dst/cjs/native/notation/IP.d.ts +1 -0
  46. package/dst/cjs/native/notation/JSON.d.ts +3 -0
  47. package/dst/cjs/node/ArrayNode.d.ts +14 -0
  48. package/dst/cjs/node/BlockNode.d.ts +15 -0
  49. package/dst/cjs/node/CallNode.d.ts +15 -0
  50. package/dst/cjs/node/CastNode.d.ts +16 -0
  51. package/dst/cjs/node/ConstantNode.d.ts +17 -0
  52. package/dst/cjs/node/JumpNode.d.ts +16 -0
  53. package/dst/cjs/node/JumpNode.js +7 -3
  54. package/dst/cjs/node/LoopNode.d.ts +14 -0
  55. package/dst/cjs/node/ObjectNode.d.ts +14 -0
  56. package/dst/cjs/node/SwitchNode.d.ts +15 -0
  57. package/dst/cjs/node/VariableNode.d.ts +15 -0
  58. package/dst/cjs/node/VariadicNode.d.ts +4 -0
  59. package/dst/native/Buffer.js +1 -1
  60. package/dst/native/Number.js +1 -1
  61. package/dst/native/String.js +97 -48
  62. package/dst/native/Unknown.js +10 -1
  63. package/dst/node/JumpNode.d.ts +2 -1
  64. package/dst/node/JumpNode.js +7 -3
  65. package/package.json +1 -1
@@ -0,0 +1,6 @@
1
+ import { Constant } from "../Constant.js";
2
+ export declare const funcOr: Constant;
3
+ export declare const funcAnd: Constant;
4
+ export declare const funcNot: Constant;
5
+ export declare const funcBoolean: Constant;
6
+ export declare const constBoolean: any;
@@ -0,0 +1,13 @@
1
+ import { Constant } from "../Constant.js";
2
+ export type BufferFormatting = "hex" | "base64";
3
+ export declare const EmptyBuffer: ArrayBuffer;
4
+ export declare const formatLiteralBuffer: (value: ArrayBuffer) => string;
5
+ export declare const parseLiteralBuffer: (value: string, offset?: number) => readonly [ArrayBuffer, number];
6
+ export declare const parseBoundedInteger: (input: string, base: 10 | 16, min: number, max: number) => number;
7
+ export declare const equateBuffers: (value1: ArrayBuffer, value2: ArrayBuffer) => boolean;
8
+ export declare const containsBuffer: (value: ArrayBuffer, search: ArrayBuffer, startPos?: number) => boolean;
9
+ export declare const concatBuffers: (value1: ArrayBuffer, value2: ArrayBuffer) => ArrayBuffer;
10
+ export declare const formatBuffer: (value: ArrayBuffer, formatting?: BufferFormatting) => string;
11
+ export declare const parseBuffer: (value?: string) => ArrayBuffer | undefined;
12
+ export declare const funcByte: Constant;
13
+ export declare const constBuffer: any;
@@ -97,7 +97,7 @@ const containsBuffer = (value, search, startPos) => {
97
97
  return true;
98
98
  }
99
99
  const pos = startPos == null ? 0 : startPos < 0 ? value.byteLength + startPos : startPos;
100
- if (pos > value.byteLength - search.byteLength) {
100
+ if (pos < 0 || pos > value.byteLength - search.byteLength) {
101
101
  return false;
102
102
  }
103
103
  const dvv = new DataView(value);
@@ -0,0 +1,4 @@
1
+ import { Constant } from "../Constant.js";
2
+ export declare const funcSlice: Constant;
3
+ export declare const funcSplice: Constant;
4
+ export declare const funcInject: Constant;
@@ -0,0 +1,5 @@
1
+ import { Constant } from "../Constant.js";
2
+ export type FloatEncoding = "f32" | "f32le" | "f64" | "f64le";
3
+ export declare const encodeFloat: (value: number, encoding?: FloatEncoding) => ArrayBuffer;
4
+ export declare const funcFloat: Constant;
5
+ export declare const constFloat: any;
@@ -0,0 +1,7 @@
1
+ import { Constant } from "../Constant.js";
2
+ export type IntegerEncoding = "i8" | "i16" | "i16le" | "i32" | "i32le" | "i64" | "i64le" | "n8" | "n16" | "n16le" | "n32" | "n32le";
3
+ export declare const boundInteger: (value: bigint) => bigint;
4
+ export declare const createInteger: (value?: number) => bigint | undefined;
5
+ export declare const encodeInteger: (value: bigint, encoding?: IntegerEncoding) => ArrayBuffer;
6
+ export declare const funcInteger: Constant;
7
+ export declare const constInteger: any;
@@ -0,0 +1,5 @@
1
+ import { Constant } from "../Constant.js";
2
+ export declare const funcLength: Constant;
3
+ export declare const funcContains: Constant;
4
+ export declare const funcAt: Constant;
5
+ export declare const funcHas: Constant;
@@ -0,0 +1,26 @@
1
+ import { Constant } from "../Constant.js";
2
+ export declare const isSignSymbol: (c: string) => c is "+" | "-";
3
+ export declare const isNumericSymbol: (c: string) => boolean;
4
+ export interface NumberFormatting {
5
+ min_integer_digits?: number;
6
+ min_fraction_digits?: number;
7
+ max_fraction_digits?: number;
8
+ min_significant_digits?: number;
9
+ max_significant_digits?: number;
10
+ notation?: "standard" | "scientific";
11
+ }
12
+ export declare const formatLiteralNumber: (value: bigint | number) => string;
13
+ export declare const parseLiteralNumber: (value: string, offset?: number) => readonly [number | bigint, number];
14
+ export declare const formatNumber: (value: bigint | number, formatting?: string) => string;
15
+ export declare const funcGreaterThan: Constant;
16
+ export declare const funcLessThan: Constant;
17
+ export declare const funcGreaterOrEqual: Constant;
18
+ export declare const funcLessOrEqual: Constant;
19
+ export declare const funcSubtract: Constant;
20
+ export declare const funcMultiply: Constant;
21
+ export declare const funcDivide: Constant;
22
+ export declare const funcRemainder: Constant;
23
+ export declare const funcModulo: Constant;
24
+ export declare const funcPower: Constant;
25
+ export declare const funcRoot: Constant;
26
+ export declare const funcNegate: Constant;
@@ -69,7 +69,7 @@ const formatNumber = (value, formatting) => {
69
69
  };
70
70
  exports.formatNumber = formatNumber;
71
71
  const typeComparator = Type_js_1.Type.functionType(Type_js_1.Type.Boolean, [Type_js_1.Type.Number, Type_js_1.Type.Number]);
72
- const typeOperator = Type_js_1.Type.union(Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Float, Type_js_1.Type.Integer]), Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Integer, Type_js_1.Type.Float]), Type_js_1.Type.functionType(Type_js_1.Type.Integer, [Type_js_1.Type.Integer, Type_js_1.Type.Integer]));
72
+ const typeOperator = Type_js_1.Type.union(Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Float, Type_js_1.Type.Float]), Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Float, Type_js_1.Type.Integer]), Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Integer, Type_js_1.Type.Float]), Type_js_1.Type.functionType(Type_js_1.Type.Integer, [Type_js_1.Type.Integer, Type_js_1.Type.Integer]));
73
73
  exports.funcGreaterThan = new Constant_js_1.Constant((value1, value2) => value1 > value2, typeComparator);
74
74
  exports.funcLessThan = new Constant_js_1.Constant((value1, value2) => value1 < value2, typeComparator);
75
75
  exports.funcGreaterOrEqual = new Constant_js_1.Constant((value1, value2) => value1 >= value2, typeComparator);
@@ -0,0 +1,5 @@
1
+ import { Constant } from "../Constant.js";
2
+ export declare const funcEntries: Constant;
3
+ export declare const funcKeys: Constant;
4
+ export declare const funcValues: Constant;
5
+ export declare const constObject: any;
@@ -0,0 +1,28 @@
1
+ import { Constant } from "../Constant.js";
2
+ export type StringEncoding = "utf8" | "sbcs" | "ucs2" | "ucs2le";
3
+ export declare const isAlphanumericSymbol: (c: string) => boolean;
4
+ export declare const isTokenStartSymbol: (c: string) => boolean;
5
+ export declare const isTokenSymbol: (c: string) => boolean;
6
+ export declare const isHexadecimalSymbol: (c: string) => boolean;
7
+ export declare const formatLiteralString: (value: string) => string;
8
+ export declare const parseLiteralString: (value: string, offset?: number) => readonly [string, number];
9
+ export declare const replaceWith: (value?: string, replacement?: string, ...search: string[]) => string | undefined;
10
+ export declare const equateStrings: (value1?: string, value2?: string, ignoreCaseSpaceEtc?: boolean) => boolean;
11
+ export declare const containsString: (value?: string, search?: string, startPos?: number, ignoreCaseSpaceEtc?: boolean) => boolean;
12
+ export declare const startsWithString: (value?: string, search?: string, startPos?: number, ignoreCaseSpaceEtc?: boolean) => boolean;
13
+ export declare const endsWithString: (value?: string, search?: string, endPos?: number, ignoreCaseSpaceEtc?: boolean) => boolean;
14
+ export declare const encodeString: (value: string, encoding?: StringEncoding) => ArrayBuffer;
15
+ export declare const funcLike: Constant;
16
+ export declare const funcUnlike: Constant;
17
+ export declare const funcStartsWith: Constant;
18
+ export declare const funcEndsWith: Constant;
19
+ export declare const funcChar: Constant;
20
+ export declare const funcCharCode: Constant;
21
+ export declare const funcTrim: Constant;
22
+ export declare const funcTrimStart: Constant;
23
+ export declare const funcTrimEnd: Constant;
24
+ export declare const funcLowerCase: Constant;
25
+ export declare const funcUpperCase: Constant;
26
+ export declare const funcSplit: Constant;
27
+ export declare const funcReplaceWith: Constant;
28
+ export declare const constString: any;
@@ -85,25 +85,49 @@ const equateStrings = (value1, value2, ignoreCaseSpaceEtc) => {
85
85
  if (value1 == null || value2 == null) {
86
86
  return false;
87
87
  }
88
+ if (value1 === value2) {
89
+ return true;
90
+ }
88
91
  if (!ignoreCaseSpaceEtc) {
89
- return value1 === value2;
92
+ return false;
90
93
  }
91
- const str1 = value1.toLowerCase();
92
- const str2 = value2.toLowerCase();
93
- for (let i1 = 0, i2 = 0; i1 < str1.length && i2 < str2.length; ++i1, ++i2) {
94
- while (!(0, exports.isAlphanumericSymbol)(str1[i1]) && i1 < str1.length) {
95
- ++i1;
94
+ for (let i1 = 0, i2 = 0; i1 < value1.length || i2 < value2.length;) {
95
+ let code1 = 0, code2 = 0;
96
+ while (i1 < value1.length && !code1) {
97
+ code1 = alphanumericCode(value1, i1++);
96
98
  }
97
- while (!(0, exports.isAlphanumericSymbol)(str2[i2]) && i2 < str2.length) {
98
- ++i2;
99
+ while (i2 < value2.length && !code2) {
100
+ code2 = alphanumericCode(value2, i2++);
99
101
  }
100
- if (str1[i1] != str2[i2]) {
102
+ if (code1 !== code2) {
101
103
  return false;
102
104
  }
103
105
  }
104
106
  return true;
105
107
  };
106
108
  exports.equateStrings = equateStrings;
109
+ const alphanumericCode = (value, index) => {
110
+ let code = value.charCodeAt(index);
111
+ if (code > 0x7f) {
112
+ // Preserve Unicode lowercase mappings to ASCII, such as İ and K.
113
+ code = value.charAt(index).toLowerCase().charCodeAt(0);
114
+ }
115
+ code |= 0x20;
116
+ return code >= 0x61 && code <= 0x7a || code >= 0x30 && code <= 0x39 ? code : 0;
117
+ };
118
+ const createSearchPrefixes = (pattern) => {
119
+ const prefixes = new Uint32Array(pattern.length);
120
+ for (let i = 1, matched = 0; i < pattern.length; ++i) {
121
+ while (matched > 0 && pattern[i] !== pattern[matched]) {
122
+ matched = prefixes[matched - 1];
123
+ }
124
+ if (pattern[i] === pattern[matched]) {
125
+ ++matched;
126
+ }
127
+ prefixes[i] = matched;
128
+ }
129
+ return prefixes;
130
+ };
107
131
  const containsString = (value, search, startPos, ignoreCaseSpaceEtc) => {
108
132
  if (value == null) {
109
133
  return false;
@@ -114,33 +138,62 @@ const containsString = (value, search, startPos, ignoreCaseSpaceEtc) => {
114
138
  if (!ignoreCaseSpaceEtc) {
115
139
  return value.includes(search, startPos);
116
140
  }
117
- const valueStr = value.toLowerCase();
118
- const searchStr = search.toLowerCase();
119
- if (valueStr.length < searchStr.length) {
120
- return false;
141
+ const pattern = [];
142
+ for (let i = 0; i < search.length; ++i) {
143
+ const code = alphanumericCode(search, i);
144
+ if (code) {
145
+ pattern.push(code);
146
+ }
121
147
  }
122
- if (searchStr.length === 0) {
148
+ if (pattern.length === 0) {
123
149
  return true;
124
150
  }
125
151
  const pos = startPos == null ? 0 : startPos < 0 ? value.length + startPos : startPos;
126
- if (pos > value.length - search.length) {
152
+ const start = Math.max(0, Math.trunc(pos) || 0);
153
+ if (pattern.length > value.length - start) {
127
154
  return false;
128
155
  }
129
- for (let i1 = pos, i2 = 0; i1 < valueStr.length && i2 < searchStr.length; ++i1, ++i2) {
130
- while (!(0, exports.isAlphanumericSymbol)(valueStr[i1]) && i1 < valueStr.length) {
131
- ++i1;
156
+ // Build KMP fallback lengths only when a partial match first fails.
157
+ let prefixes;
158
+ const first = pattern[0];
159
+ for (let i = start, matched = 0; i < value.length; ++i) {
160
+ if (matched === 0) {
161
+ while (i < value.length) {
162
+ const code = value.charCodeAt(i) | 0x20;
163
+ if (code === first || code > 0x7f && alphanumericCode(value, i) === first) {
164
+ break;
165
+ }
166
+ ++i;
167
+ }
168
+ if (i === value.length) {
169
+ return false;
170
+ }
171
+ if (pattern.length === 1) {
172
+ return true;
173
+ }
174
+ matched = 1;
175
+ continue;
132
176
  }
133
- while (!(0, exports.isAlphanumericSymbol)(searchStr[i2]) && i2 < searchStr.length) {
134
- ++i2;
177
+ let code = value.charCodeAt(i) | 0x20;
178
+ if (code > 0x7f) {
179
+ code = alphanumericCode(value, i);
135
180
  }
136
- while (valueStr[i1] != searchStr[i2] && i1 < valueStr.length) {
137
- ++i1;
181
+ if (code === pattern[matched]) {
182
+ if (++matched === pattern.length) {
183
+ return true;
184
+ }
138
185
  }
139
- if (valueStr[i1] != searchStr[i2] && i2 < searchStr.length) {
140
- return false;
186
+ else if (matched > 0 && (code >= 0x61 && code <= 0x7a || code >= 0x30 && code <= 0x39)) {
187
+ prefixes ??= createSearchPrefixes(pattern);
188
+ do {
189
+ matched = prefixes[matched - 1];
190
+ } while (matched > 0 && code !== pattern[matched]);
191
+ if (code === pattern[matched]) {
192
+ ++matched;
193
+ }
141
194
  }
142
195
  }
143
- return true;
196
+ return false;
144
197
  };
145
198
  exports.containsString = containsString;
146
199
  const startsWithString = (value, search, startPos, ignoreCaseSpaceEtc) => {
@@ -153,20 +206,18 @@ const startsWithString = (value, search, startPos, ignoreCaseSpaceEtc) => {
153
206
  if (!ignoreCaseSpaceEtc) {
154
207
  return value.startsWith(search, startPos);
155
208
  }
156
- const valueStr = value.toLowerCase();
157
- const searchStr = search.toLowerCase();
158
- if (valueStr.length < searchStr.length) {
159
- return false;
160
- }
161
209
  const pos = startPos == null ? 0 : startPos < 0 ? value.length + startPos : startPos;
162
- for (let i1 = pos, i2 = 0; i1 < valueStr.length && i2 < searchStr.length; ++i1, ++i2) {
163
- while (!(0, exports.isAlphanumericSymbol)(valueStr[i1]) && i1 < valueStr.length) {
164
- ++i1;
210
+ let valueIndex = Math.max(0, Math.trunc(pos) || 0);
211
+ for (let i = 0; i < search.length; ++i) {
212
+ const searchCode = alphanumericCode(search, i);
213
+ if (!searchCode) {
214
+ continue;
165
215
  }
166
- while (!(0, exports.isAlphanumericSymbol)(searchStr[i2]) && i2 < searchStr.length) {
167
- ++i2;
216
+ let valueCode = 0;
217
+ while (valueIndex < value.length && !valueCode) {
218
+ valueCode = alphanumericCode(value, valueIndex++);
168
219
  }
169
- if (valueStr[i1] != searchStr[i2] && i2 < searchStr.length) {
220
+ if (valueCode !== searchCode) {
170
221
  return false;
171
222
  }
172
223
  }
@@ -183,20 +234,18 @@ const endsWithString = (value, search, endPos, ignoreCaseSpaceEtc) => {
183
234
  if (!ignoreCaseSpaceEtc) {
184
235
  return value.endsWith(search, endPos);
185
236
  }
186
- const valueStr = value.toLowerCase();
187
- const searchStr = search.toLowerCase();
188
- if (valueStr.length < searchStr.length) {
189
- return false;
190
- }
191
- const pos = endPos == null ? valueStr.length : endPos < 0 ? value.length + endPos : endPos;
192
- for (let i1 = pos - 1, i2 = searchStr.length - 1; i1 > -1 && i2 > -1; --i1, --i2) {
193
- while (!(0, exports.isAlphanumericSymbol)(valueStr[i1]) && i1 > -1) {
194
- --i1;
237
+ const pos = endPos == null ? value.length : endPos < 0 ? value.length + endPos : endPos;
238
+ let valueIndex = Math.min(value.length, Math.max(0, Math.trunc(pos) || 0)) - 1;
239
+ for (let i = search.length - 1; i >= 0; --i) {
240
+ const searchCode = alphanumericCode(search, i);
241
+ if (!searchCode) {
242
+ continue;
195
243
  }
196
- while (!(0, exports.isAlphanumericSymbol)(searchStr[i2]) && i2 > -1) {
197
- --i2;
244
+ let valueCode = 0;
245
+ while (valueIndex >= 0 && !valueCode) {
246
+ valueCode = alphanumericCode(value, valueIndex--);
198
247
  }
199
- if (valueStr[i1] != searchStr[i2] && i2 > -1) {
248
+ if (valueCode !== searchCode) {
200
249
  return false;
201
250
  }
202
251
  }
@@ -0,0 +1,22 @@
1
+ import { Constant } from "../Constant.js";
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
+ export declare const encodeTimestamp: (value: Date, encoding?: TimestampEncoding) => ArrayBuffer;
6
+ export declare const decodeTimestamp: (value?: ArrayBuffer, encoding?: TimestampEncoding, byteOffset?: number) => Date | undefined;
7
+ export declare const formatTimestamp: (value: Date, template?: string) => string;
8
+ export declare const funcYear: Constant;
9
+ export declare const funcMonth: Constant;
10
+ export declare const funcMonthIndex: Constant;
11
+ export declare const funcWeekdayIndex: Constant;
12
+ export declare const funcDay: Constant;
13
+ export declare const funcHour: Constant;
14
+ export declare const funcMinute: Constant;
15
+ export declare const funcSecond: Constant;
16
+ export declare const funcMillisecond: Constant;
17
+ export declare const funcEpochTime: Constant;
18
+ export declare const funcDaysSince: Constant;
19
+ export declare const funcHoursSince: Constant;
20
+ export declare const funcMinutesSince: Constant;
21
+ export declare const funcSecondsSince: Constant;
22
+ export declare const constTimestamp: any;
@@ -0,0 +1,14 @@
1
+ import { Constant } from "../Constant.js";
2
+ import { Value } from "../Value.js";
3
+ import { FloatEncoding } from "./Float.js";
4
+ import { IntegerEncoding } from "./Integer.js";
5
+ import { StringEncoding } from "./String.js";
6
+ import { TimestampEncoding } from "./Timestamp.js";
7
+ export declare const equate: (value1: Value, value2: Value) => boolean;
8
+ export declare const encode: (value: Value, encoding?: FloatEncoding | IntegerEncoding | TimestampEncoding | StringEncoding) => ArrayBuffer;
9
+ export declare const format: (value: Value, formatting?: string) => string;
10
+ export declare const funcCoalesce: Constant;
11
+ export declare const funcEqual: Constant;
12
+ export declare const funcNotEqual: Constant;
13
+ export declare const funcEncode: Constant;
14
+ export declare const funcFormat: Constant;
@@ -15,7 +15,7 @@ const equate = (value1, value2) => {
15
15
  }
16
16
  if (typeof value1 !== typeof value2) {
17
17
  if (typeof value1 === "number" && typeof value2 === "bigint") {
18
- return value1 === Number(value2);
18
+ return Number.isInteger(value1) && BigInt(value1) === value2;
19
19
  }
20
20
  if (typeof value1 === "bigint" && typeof value2 === "number") {
21
21
  return Number.isInteger(value2) && value1 === BigInt(value2);
@@ -31,9 +31,15 @@ const equate = (value1, value2) => {
31
31
  if (value1 instanceof Date && value2 instanceof Date) {
32
32
  return value1.getTime() === value2.getTime();
33
33
  }
34
+ if (value1 instanceof Date || value2 instanceof Date) {
35
+ return false;
36
+ }
34
37
  if (value1 instanceof ArrayBuffer && value2 instanceof ArrayBuffer) {
35
38
  return (0, Buffer_js_1.equateBuffers)(value1, value2);
36
39
  }
40
+ if (value1 instanceof ArrayBuffer || value2 instanceof ArrayBuffer) {
41
+ return false;
42
+ }
37
43
  if (Array.isArray(value1) && Array.isArray(value2)) {
38
44
  if (value1.length === value2.length) {
39
45
  for (let i = 0; i < value1.length; ++i) {
@@ -45,6 +51,9 @@ const equate = (value1, value2) => {
45
51
  }
46
52
  return false;
47
53
  }
54
+ if (Array.isArray(value1) || Array.isArray(value2)) {
55
+ return false;
56
+ }
48
57
  const props = new Set([...Object.getOwnPropertyNames(value1), ...Object.getOwnPropertyNames(value2)]);
49
58
  for (const prop of props) {
50
59
  if (!(0, exports.equate)(value1[prop], value2[prop])) {
@@ -0,0 +1,4 @@
1
+ import { Value } from "../../Value.js";
2
+ export declare const formatAN: (value: Value, whitespace?: string) => string;
3
+ export declare const parseAN: (value: string | undefined) => Value;
4
+ export declare const constAN: any;
@@ -0,0 +1 @@
1
+ export declare const constIP: any;
@@ -0,0 +1,3 @@
1
+ import { Value } from "../../Value.js";
2
+ export declare const formatJSON: (value: Value, whitespace?: string) => string;
3
+ export declare const constJSON: any;
@@ -0,0 +1,14 @@
1
+ import { Node } from "../Node.js";
2
+ import { ScriptSpan } from "../ScriptSpan.js";
3
+ import { Value } from "../Value.js";
4
+ import { Type } from "../Type.js";
5
+ import { CallFrame } from "../CallFrame.js";
6
+ export declare class ArrayNode extends Node {
7
+ protected _subnodes: Node[];
8
+ protected _type: Type;
9
+ constructor(span: ScriptSpan, _subnodes: Node[]);
10
+ get type(): Type;
11
+ compile(type: Type): Node;
12
+ evaluate(frame: CallFrame): Value;
13
+ toString(ident?: number): string;
14
+ }
@@ -0,0 +1,15 @@
1
+ import { Node } from "../Node.js";
2
+ import { ScriptSpan } from "../ScriptSpan.js";
3
+ import { Value } from "../Value.js";
4
+ import { Type } from "../Type.js";
5
+ import { CallFrame } from "../CallFrame.js";
6
+ import { Variable } from "../Variable.js";
7
+ export declare class BlockNode extends Node {
8
+ protected _subnodes: Node[];
9
+ protected readonly _variables: Variable[];
10
+ constructor(span: ScriptSpan, _subnodes: Node[], _variables?: Variable[]);
11
+ get type(): Type;
12
+ compile(type: Type): Node;
13
+ evaluate(frame: CallFrame): Value;
14
+ toString(ident?: number): string;
15
+ }
@@ -0,0 +1,15 @@
1
+ import { Node } from "../Node.js";
2
+ import { ScriptSpan } from "../ScriptSpan.js";
3
+ import { Value } from "../Value.js";
4
+ import { Type } from "../Type.js";
5
+ import { CallFrame } from "../CallFrame.js";
6
+ export declare class CallNode extends Node {
7
+ protected _fnode: Node;
8
+ protected _subnodes: Node[];
9
+ protected _type: Type;
10
+ constructor(span: ScriptSpan, _fnode: Node, _subnodes: Node[]);
11
+ get type(): Type;
12
+ compile(type: Type): Node;
13
+ evaluate(frame: CallFrame): Value;
14
+ toString(ident?: number): string;
15
+ }
@@ -0,0 +1,16 @@
1
+ import { Node } from "../Node.js";
2
+ import { ScriptSpan } from "../ScriptSpan.js";
3
+ import { Type } from "../Type.js";
4
+ import { Value } from "../Value.js";
5
+ import { CallFrame } from "../CallFrame.js";
6
+ export declare class CastNode extends Node {
7
+ protected _subnode: Node;
8
+ protected readonly _target: Type;
9
+ protected _type: Type;
10
+ constructor(span: ScriptSpan, _subnode: Node, _target: Type);
11
+ get type(): Type;
12
+ compile(type: Type): Node;
13
+ evaluate(frame: CallFrame): Value;
14
+ get constant(): boolean;
15
+ toString(ident?: number): string;
16
+ }
@@ -0,0 +1,17 @@
1
+ import { Node } from "../Node.js";
2
+ import { ScriptSpan } from "../ScriptSpan.js";
3
+ import { Constant } from "../Constant.js";
4
+ import { Value } from "../Value.js";
5
+ import { Type } from "../Type.js";
6
+ import { CallFrame } from "../CallFrame.js";
7
+ export declare class ConstantNode extends Node {
8
+ protected readonly _constant: Constant;
9
+ protected _subnode?: Node | undefined;
10
+ protected readonly _factory?: ((frame: CallFrame) => Value) | undefined;
11
+ constructor(span: ScriptSpan, _constant: Constant, _subnode?: Node | undefined, _factory?: ((frame: CallFrame) => Value) | undefined);
12
+ get type(): Type;
13
+ compile(type: Type): Node;
14
+ evaluate(frame: CallFrame): Value;
15
+ get constant(): boolean;
16
+ toString(ident?: number): string;
17
+ }
@@ -0,0 +1,16 @@
1
+ import { Node } from "../Node.js";
2
+ import { ScriptSpan } from "../ScriptSpan.js";
3
+ import { Value } from "../Value.js";
4
+ import { Type } from "../Type.js";
5
+ import { Jump } from "../Jump.js";
6
+ import { CallFrame } from "../CallFrame.js";
7
+ export declare class JumpNode extends Node {
8
+ protected _jump: Jump;
9
+ protected _subnode?: Node | undefined;
10
+ protected _type?: Type | undefined;
11
+ constructor(span: ScriptSpan, _jump: Jump, _subnode?: Node | undefined, _type?: Type | undefined);
12
+ get type(): Type;
13
+ compile(type: Type): Node;
14
+ evaluate(frame: CallFrame): Value;
15
+ toString(ident?: number): string;
16
+ }
@@ -7,16 +7,20 @@ const JumpException_js_1 = require("../JumpException.js");
7
7
  class JumpNode extends Node_js_1.Node {
8
8
  _jump;
9
9
  _subnode;
10
- constructor(span, _jump, _subnode) {
10
+ _type;
11
+ constructor(span, _jump, _subnode, _type) {
11
12
  super(span);
12
13
  this._jump = _jump;
13
14
  this._subnode = _subnode;
15
+ this._type = _type;
14
16
  }
15
17
  get type() {
16
- return this._subnode?.type ?? Type_js_1.Type.Void;
18
+ return this._type ?? this._subnode?.type ?? Type_js_1.Type.Void;
17
19
  }
18
20
  compile(type) {
19
- this._subnode = this._subnode?.compile(type);
21
+ this._subnode = this._subnode?.compile(this._jump === "exit" || this._jump === "return"
22
+ ? this._type ?? Type_js_1.Type.Unknown
23
+ : type);
20
24
  return this;
21
25
  }
22
26
  evaluate(frame) {
@@ -0,0 +1,14 @@
1
+ import { Node } from "../Node.js";
2
+ import { ScriptSpan } from "../ScriptSpan.js";
3
+ import { Value } from "../Value.js";
4
+ import { Type } from "../Type.js";
5
+ import { CallFrame } from "../CallFrame.js";
6
+ export declare class LoopNode extends Node {
7
+ protected _cnode: Node;
8
+ protected _subnode: Node;
9
+ constructor(span: ScriptSpan, _cnode: Node, _subnode: Node);
10
+ get type(): Type;
11
+ compile(type: Type): Node;
12
+ evaluate(frame: CallFrame): Value;
13
+ toString(ident?: number): string;
14
+ }
@@ -0,0 +1,14 @@
1
+ import { Node } from "../Node.js";
2
+ import { ScriptSpan } from "../ScriptSpan.js";
3
+ import { Value } from "../Value.js";
4
+ import { Type } from "../Type.js";
5
+ import { CallFrame } from "../CallFrame.js";
6
+ export declare class ObjectNode extends Node {
7
+ protected _subnodes: [Node, Node][];
8
+ protected _type: Type;
9
+ constructor(span: ScriptSpan, _subnodes: [Node, Node][]);
10
+ get type(): Type;
11
+ compile(type: Type): Node;
12
+ evaluate(frame: CallFrame): Value;
13
+ toString(ident?: number): string;
14
+ }
@@ -0,0 +1,15 @@
1
+ import { Node } from "../Node.js";
2
+ import { ScriptSpan } from "../ScriptSpan.js";
3
+ import { Value } from "../Value.js";
4
+ import { Type } from "../Type.js";
5
+ import { CallFrame } from "../CallFrame.js";
6
+ export declare class SwitchNode extends Node {
7
+ protected _cnode: Node;
8
+ protected _subnodes: Node[];
9
+ protected _type: Type;
10
+ constructor(span: ScriptSpan, _cnode: Node, _subnodes: Node[]);
11
+ get type(): Type;
12
+ compile(type: Type): Node;
13
+ evaluate(frame: CallFrame): Value;
14
+ toString(ident?: number): string;
15
+ }
@@ -0,0 +1,15 @@
1
+ import { Node } from "../Node.js";
2
+ import { ScriptSpan } from "../ScriptSpan.js";
3
+ import { Variable } from "../Variable.js";
4
+ import { Value } from "../Value.js";
5
+ import { Type } from "../Type.js";
6
+ import { CallFrame } from "../CallFrame.js";
7
+ export declare class VariableNode extends Node {
8
+ protected readonly _variable: Variable;
9
+ protected _subnode?: Node | undefined;
10
+ constructor(span: ScriptSpan, _variable: Variable, _subnode?: Node | undefined);
11
+ get type(): Type;
12
+ compile(type: Type): Node;
13
+ evaluate(frame: CallFrame): Value;
14
+ toString(ident?: number): string;
15
+ }
@@ -0,0 +1,4 @@
1
+ import { ArrayNode } from "./ArrayNode.js";
2
+ export declare class VariadicNode extends ArrayNode {
3
+ get constant(): boolean;
4
+ }
@@ -90,7 +90,7 @@ export const containsBuffer = (value, search, startPos) => {
90
90
  return true;
91
91
  }
92
92
  const pos = startPos == null ? 0 : startPos < 0 ? value.byteLength + startPos : startPos;
93
- if (pos > value.byteLength - search.byteLength) {
93
+ if (pos < 0 || pos > value.byteLength - search.byteLength) {
94
94
  return false;
95
95
  }
96
96
  const dvv = new DataView(value);
@@ -61,7 +61,7 @@ export const formatNumber = (value, formatting) => {
61
61
  : value.toString();
62
62
  };
63
63
  const typeComparator = Type.functionType(Type.Boolean, [Type.Number, Type.Number]);
64
- const typeOperator = Type.union(Type.functionType(Type.Float, [Type.Float, Type.Integer]), Type.functionType(Type.Float, [Type.Integer, Type.Float]), Type.functionType(Type.Integer, [Type.Integer, Type.Integer]));
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]));
65
65
  export const funcGreaterThan = new Constant((value1, value2) => value1 > value2, typeComparator);
66
66
  export const funcLessThan = new Constant((value1, value2) => value1 < value2, typeComparator);
67
67
  export const funcGreaterOrEqual = new Constant((value1, value2) => value1 >= value2, typeComparator);