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.
- package/.cache/arrow-preview-vWvB5K/affinirum-arrow-functions.patch +155 -0
- package/.cache/function-syntax-tests.log +20 -0
- package/README.md +925 -355
- package/dst/Affinirum.d.ts +29 -19
- package/dst/Affinirum.js +399 -334
- package/dst/CallFrame.d.ts +12 -3
- package/dst/CallFrame.js +49 -10
- package/dst/Constant.d.ts +1 -3
- package/dst/Constant.js +3 -8
- package/dst/LexicalScope.d.ts +11 -9
- package/dst/LexicalScope.js +10 -6
- package/dst/ParserSpan.d.ts +11 -0
- package/dst/{ScriptSpan.js → ParserSpan.js} +8 -5
- package/dst/ParserState.d.ts +28 -49
- package/dst/ParserState.js +256 -489
- package/dst/Type.d.ts +34 -17
- package/dst/Type.js +211 -115
- package/dst/TypeParser.d.ts +9 -0
- package/dst/TypeParser.js +127 -0
- package/dst/Value.d.ts +1 -1
- package/dst/Value.js +21 -10
- package/dst/Variable.d.ts +16 -5
- package/dst/Variable.js +32 -7
- package/dst/atom/ArrayAtom.d.ts +10 -10
- package/dst/atom/ArrayAtom.js +62 -55
- package/dst/atom/Atom.d.ts +7 -0
- package/dst/atom/FunctionAtom.d.ts +13 -15
- package/dst/atom/FunctionAtom.js +53 -104
- package/dst/atom/FunctionSignature.d.ts +23 -0
- package/dst/atom/FunctionSignature.js +124 -0
- package/dst/atom/ObjectAtom.d.ts +11 -9
- package/dst/atom/ObjectAtom.js +73 -33
- package/dst/atom/PrimitiveAtom.d.ts +6 -7
- package/dst/atom/PrimitiveAtom.js +7 -10
- package/dst/cjs/Affinirum.d.ts +29 -19
- package/dst/cjs/Affinirum.js +398 -333
- package/dst/cjs/CallFrame.d.ts +12 -3
- package/dst/cjs/CallFrame.js +49 -10
- package/dst/cjs/Constant.d.ts +1 -3
- package/dst/cjs/Constant.js +3 -8
- package/dst/cjs/LexicalScope.d.ts +11 -9
- package/dst/cjs/LexicalScope.js +10 -6
- package/dst/cjs/ParserSpan.d.ts +11 -0
- package/dst/cjs/{ScriptSpan.js → ParserSpan.js} +10 -7
- package/dst/cjs/ParserState.d.ts +28 -49
- package/dst/cjs/ParserState.js +255 -488
- package/dst/cjs/Type.d.ts +34 -17
- package/dst/cjs/Type.js +211 -115
- package/dst/cjs/TypeParser.d.ts +9 -0
- package/dst/cjs/TypeParser.js +131 -0
- package/dst/cjs/Value.d.ts +1 -1
- package/dst/cjs/Value.js +21 -10
- package/dst/cjs/Variable.d.ts +16 -5
- package/dst/cjs/Variable.js +36 -9
- package/dst/cjs/atom/ArrayAtom.d.ts +10 -10
- package/dst/cjs/atom/ArrayAtom.js +62 -55
- package/dst/cjs/atom/Atom.d.ts +7 -0
- package/dst/cjs/atom/FunctionAtom.d.ts +13 -15
- package/dst/cjs/atom/FunctionAtom.js +54 -105
- package/dst/cjs/atom/FunctionSignature.d.ts +23 -0
- package/dst/cjs/atom/FunctionSignature.js +128 -0
- package/dst/cjs/atom/ObjectAtom.d.ts +11 -9
- package/dst/cjs/atom/ObjectAtom.js +73 -33
- package/dst/cjs/atom/PrimitiveAtom.d.ts +6 -7
- package/dst/cjs/atom/PrimitiveAtom.js +7 -10
- package/dst/cjs/dictionary/Constants.d.ts +2 -0
- package/dst/cjs/dictionary/Constants.js +27 -0
- package/dst/cjs/dictionary/Functions.d.ts +2 -0
- package/dst/cjs/{Functions.js → dictionary/Functions.js} +27 -25
- package/dst/cjs/native/Aggregable.js +10 -2
- package/dst/cjs/native/Array.d.ts +2 -3
- package/dst/cjs/native/Array.js +38 -39
- package/dst/cjs/native/Boolean.d.ts +1 -1
- package/dst/cjs/native/Boolean.js +13 -10
- package/dst/cjs/native/Buffer.d.ts +5 -5
- package/dst/cjs/native/Buffer.js +70 -46
- package/dst/cjs/native/Composite.d.ts +5 -0
- package/dst/cjs/native/Composite.js +35 -0
- package/dst/cjs/native/Enumerable.js +20 -8
- package/dst/cjs/native/Float.d.ts +3 -1
- package/dst/cjs/native/Float.js +51 -12
- package/dst/cjs/native/Integer.d.ts +4 -2
- package/dst/cjs/native/Integer.js +60 -25
- package/dst/cjs/native/Iterable.d.ts +0 -2
- package/dst/cjs/native/Iterable.js +9 -28
- package/dst/cjs/native/Number.d.ts +0 -2
- package/dst/cjs/native/Number.js +34 -48
- package/dst/cjs/native/Object.d.ts +1 -1
- package/dst/cjs/native/Object.js +5 -6
- package/dst/cjs/native/String.d.ts +7 -6
- package/dst/cjs/native/String.js +28 -27
- package/dst/cjs/native/Timestamp.d.ts +3 -3
- package/dst/cjs/native/Timestamp.js +34 -36
- package/dst/cjs/native/Unknown.d.ts +3 -3
- package/dst/cjs/native/Unknown.js +48 -17
- package/dst/cjs/native/notation/AN.d.ts +1 -1
- package/dst/cjs/native/notation/AN.js +37 -35
- package/dst/cjs/native/notation/IP.d.ts +1 -1
- package/dst/cjs/native/notation/IP.js +11 -12
- package/dst/cjs/native/notation/JSON.d.ts +1 -1
- package/dst/cjs/native/notation/JSON.js +7 -6
- package/dst/cjs/node/AccessNode.d.ts +24 -0
- package/dst/cjs/node/AccessNode.js +193 -0
- package/dst/cjs/node/ArrayNode.d.ts +7 -4
- package/dst/cjs/node/ArrayNode.js +26 -15
- package/dst/cjs/node/AssignableNode.d.ts +16 -0
- package/dst/cjs/node/AssignableNode.js +18 -0
- package/dst/cjs/node/AssignmentNode.d.ts +20 -0
- package/dst/cjs/node/AssignmentNode.js +66 -0
- package/dst/cjs/node/BlockNode.d.ts +5 -4
- package/dst/cjs/node/BlockNode.js +18 -11
- package/dst/cjs/node/CallNode.d.ts +7 -5
- package/dst/cjs/node/CallNode.js +40 -41
- package/dst/cjs/node/CastNode.d.ts +5 -6
- package/dst/cjs/node/CastNode.js +16 -17
- package/dst/cjs/node/ConstantNode.d.ts +4 -6
- package/dst/cjs/node/ConstantNode.js +9 -17
- package/dst/cjs/node/FinalNode.d.ts +19 -0
- package/dst/cjs/node/FinalNode.js +41 -0
- package/dst/cjs/node/FunctionNode.d.ts +17 -0
- package/dst/cjs/node/FunctionNode.js +51 -0
- package/dst/cjs/node/InvocationNode.d.ts +5 -0
- package/dst/cjs/node/InvocationNode.js +34 -0
- package/dst/cjs/node/JumpNode.d.ts +7 -9
- package/dst/cjs/node/JumpNode.js +12 -19
- package/dst/cjs/node/LoopNode.d.ts +7 -5
- package/dst/cjs/node/LoopNode.js +33 -22
- package/dst/cjs/node/MatchNode.d.ts +17 -0
- package/dst/cjs/node/MatchNode.js +65 -0
- package/dst/cjs/node/Node.d.ts +14 -0
- package/dst/cjs/{Node.js → node/Node.js} +17 -11
- package/dst/cjs/node/ObjectNode.d.ts +7 -4
- package/dst/cjs/node/ObjectNode.js +42 -11
- package/dst/cjs/node/{SwitchNode.d.ts → TernaryNode.d.ts} +6 -6
- package/dst/cjs/node/TernaryNode.js +45 -0
- package/dst/cjs/node/VariableNode.d.ts +10 -6
- package/dst/cjs/node/VariableNode.js +50 -16
- package/dst/dictionary/Constants.d.ts +2 -0
- package/dst/dictionary/Constants.js +24 -0
- package/dst/dictionary/Functions.d.ts +2 -0
- package/dst/{Functions.js → dictionary/Functions.js} +26 -24
- package/dst/native/Aggregable.js +11 -3
- package/dst/native/Array.d.ts +2 -3
- package/dst/native/Array.js +37 -38
- package/dst/native/Boolean.d.ts +1 -1
- package/dst/native/Boolean.js +12 -9
- package/dst/native/Buffer.d.ts +5 -5
- package/dst/native/Buffer.js +66 -42
- package/dst/native/Composite.d.ts +5 -0
- package/dst/native/Composite.js +32 -0
- package/dst/native/Enumerable.js +20 -8
- package/dst/native/Float.d.ts +3 -1
- package/dst/native/Float.js +48 -11
- package/dst/native/Integer.d.ts +4 -2
- package/dst/native/Integer.js +56 -23
- package/dst/native/Iterable.d.ts +0 -2
- package/dst/native/Iterable.js +8 -27
- package/dst/native/Number.d.ts +0 -2
- package/dst/native/Number.js +34 -46
- package/dst/native/Object.d.ts +1 -1
- package/dst/native/Object.js +4 -5
- package/dst/native/String.d.ts +7 -6
- package/dst/native/String.js +24 -24
- package/dst/native/Timestamp.d.ts +3 -3
- package/dst/native/Timestamp.js +31 -33
- package/dst/native/Unknown.d.ts +3 -3
- package/dst/native/Unknown.js +49 -18
- package/dst/native/notation/AN.d.ts +1 -1
- package/dst/native/notation/AN.js +37 -35
- package/dst/native/notation/IP.d.ts +1 -1
- package/dst/native/notation/IP.js +10 -11
- package/dst/native/notation/JSON.d.ts +1 -1
- package/dst/native/notation/JSON.js +6 -5
- package/dst/node/AccessNode.d.ts +24 -0
- package/dst/node/AccessNode.js +189 -0
- package/dst/node/ArrayNode.d.ts +7 -4
- package/dst/node/ArrayNode.js +26 -15
- package/dst/node/AssignableNode.d.ts +16 -0
- package/dst/node/AssignableNode.js +14 -0
- package/dst/node/AssignmentNode.d.ts +20 -0
- package/dst/node/AssignmentNode.js +62 -0
- package/dst/node/BlockNode.d.ts +5 -4
- package/dst/node/BlockNode.js +18 -11
- package/dst/node/CallNode.d.ts +7 -5
- package/dst/node/CallNode.js +40 -41
- package/dst/node/CastNode.d.ts +5 -6
- package/dst/node/CastNode.js +16 -17
- package/dst/node/ConstantNode.d.ts +4 -6
- package/dst/node/ConstantNode.js +9 -17
- package/dst/node/FinalNode.d.ts +19 -0
- package/dst/node/FinalNode.js +37 -0
- package/dst/node/FunctionNode.d.ts +17 -0
- package/dst/node/FunctionNode.js +47 -0
- package/dst/node/InvocationNode.d.ts +5 -0
- package/dst/node/InvocationNode.js +30 -0
- package/dst/node/JumpNode.d.ts +7 -9
- package/dst/node/JumpNode.js +12 -19
- package/dst/node/LoopNode.d.ts +7 -5
- package/dst/node/LoopNode.js +33 -22
- package/dst/node/MatchNode.d.ts +17 -0
- package/dst/node/MatchNode.js +61 -0
- package/dst/node/Node.d.ts +14 -0
- package/dst/node/Node.js +28 -0
- package/dst/node/ObjectNode.d.ts +7 -4
- package/dst/node/ObjectNode.js +42 -11
- package/dst/node/{SwitchNode.d.ts → TernaryNode.d.ts} +6 -6
- package/dst/node/TernaryNode.js +41 -0
- package/dst/node/VariableNode.d.ts +10 -6
- package/dst/node/VariableNode.js +50 -16
- package/package.json +4 -4
- package/dst/Atom.d.ts +0 -7
- package/dst/Constants.d.ts +0 -2
- package/dst/Constants.js +0 -24
- package/dst/Functions.d.ts +0 -2
- package/dst/Jump.d.ts +0 -1
- package/dst/Jump.js +0 -1
- package/dst/JumpException.d.ts +0 -9
- package/dst/JumpException.js +0 -14
- package/dst/Keywords.d.ts +0 -1
- package/dst/Keywords.js +0 -17
- package/dst/Node.d.ts +0 -14
- package/dst/Node.js +0 -22
- package/dst/ScriptSpan.d.ts +0 -10
- package/dst/cjs/Atom.d.ts +0 -7
- package/dst/cjs/Constants.d.ts +0 -2
- package/dst/cjs/Constants.js +0 -27
- package/dst/cjs/Functions.d.ts +0 -2
- package/dst/cjs/Jump.d.ts +0 -1
- package/dst/cjs/Jump.js +0 -2
- package/dst/cjs/JumpException.d.ts +0 -9
- package/dst/cjs/JumpException.js +0 -18
- package/dst/cjs/Keywords.d.ts +0 -1
- package/dst/cjs/Keywords.js +0 -20
- package/dst/cjs/Node.d.ts +0 -14
- package/dst/cjs/ScriptSpan.d.ts +0 -10
- package/dst/cjs/node/SwitchNode.js +0 -49
- package/dst/cjs/node/VariadicNode.d.ts +0 -4
- package/dst/cjs/node/VariadicNode.js +0 -10
- package/dst/node/SwitchNode.js +0 -45
- package/dst/node/VariadicNode.d.ts +0 -4
- package/dst/node/VariadicNode.js +0 -6
- /package/dst/{Atom.js → atom/Atom.js} +0 -0
- /package/dst/cjs/{Atom.js → atom/Atom.js} +0 -0
|
@@ -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
|
|
22
|
+
export declare const globTimestamp: any;
|
|
@@ -1,44 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.globTimestamp = exports.funcSecondsSince = exports.funcMinutesSince = exports.funcHoursSince = exports.funcDaysSince = exports.funcEpochTime = exports.funcMillisecond = exports.funcSecond = exports.funcMinute = exports.funcHour = exports.funcDay = exports.funcWeekdayIndex = exports.funcMonthIndex = exports.funcMonth = exports.funcYear = exports.parseLiteralTimestamp = exports.formatLiteralTimestamp = exports.formatTimestamp = exports.decodeTimestamp = exports.encodeTimestamp = void 0;
|
|
4
4
|
const Constant_js_1 = require("../Constant.js");
|
|
5
5
|
const Type_js_1 = require("../Type.js");
|
|
6
|
-
const Integer_js_1 = require("./Integer.js");
|
|
7
6
|
const Number_js_1 = require("./Number.js");
|
|
8
7
|
const minuteMilliseconds = 60000;
|
|
9
|
-
const typeTimestampPart = Type_js_1.Type.functionType(Type_js_1.Type.Integer, [Type_js_1.Type.Timestamp, Type_js_1.Type.OptionalBoolean]);
|
|
10
|
-
const typeTimestampSince = Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Timestamp, Type_js_1.Type.Timestamp]);
|
|
8
|
+
const typeTimestampPart = Type_js_1.Type.functionType([[Type_js_1.Type.Integer, [Type_js_1.Type.Timestamp, Type_js_1.Type.OptionalBoolean]]]);
|
|
9
|
+
const typeTimestampSince = Type_js_1.Type.functionType([[Type_js_1.Type.Float, [Type_js_1.Type.Timestamp, Type_js_1.Type.Timestamp]]]);
|
|
11
10
|
const isDateSeparatorSymbol = (c) => c === "-";
|
|
12
11
|
const isTimeSeparatorSymbol = (c) => c === ":";
|
|
13
12
|
const isDateTimeSeparatorSymbol = (c) => c === "T" || c === " " || c === "@";
|
|
14
13
|
const isDateSymbol = (c) => (0, Number_js_1.isNumericSymbol)(c) || isDateSeparatorSymbol(c);
|
|
15
14
|
const isTimeSymbol = (c) => (0, Number_js_1.isNumericSymbol)(c) || isTimeSeparatorSymbol(c);
|
|
16
|
-
const formatLiteralTimestamp = (value) => `@${(0, exports.formatTimestamp)(value)}`;
|
|
17
|
-
exports.formatLiteralTimestamp = formatLiteralTimestamp;
|
|
18
|
-
const parseLiteralTimestamp = (value, offset = 0) => {
|
|
19
|
-
let i = offset + 1;
|
|
20
|
-
while (isDateSymbol(value.charAt(i))) {
|
|
21
|
-
++i;
|
|
22
|
-
}
|
|
23
|
-
if (isDateTimeSeparatorSymbol(value.charAt(i))) {
|
|
24
|
-
++i;
|
|
25
|
-
while (isTimeSymbol(value.charAt(i))) {
|
|
26
|
-
++i;
|
|
27
|
-
}
|
|
28
|
-
if (value.charAt(i) === "."
|
|
29
|
-
&& (0, Number_js_1.isNumericSymbol)(value.charAt(i + 1))) {
|
|
30
|
-
++i;
|
|
31
|
-
while ((0, Number_js_1.isNumericSymbol)(value.charAt(i))) {
|
|
32
|
-
++i;
|
|
33
|
-
}
|
|
34
|
-
if (value.charAt(i) === "Z") {
|
|
35
|
-
++i;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return [new Date(value.slice(offset + 1, i)), i];
|
|
40
|
-
};
|
|
41
|
-
exports.parseLiteralTimestamp = parseLiteralTimestamp;
|
|
42
15
|
const encodeTimestamp = (value, encoding = "i64") => {
|
|
43
16
|
const littleEndian = encoding.endsWith("le");
|
|
44
17
|
switch (encoding) {
|
|
@@ -129,7 +102,32 @@ const parseTimestamp = (value) => {
|
|
|
129
102
|
const date = new Date(value);
|
|
130
103
|
return isNaN(date.getTime()) ? undefined : date;
|
|
131
104
|
};
|
|
132
|
-
const
|
|
105
|
+
const formatLiteralTimestamp = (value) => `@${(0, exports.formatTimestamp)(value)}`;
|
|
106
|
+
exports.formatLiteralTimestamp = formatLiteralTimestamp;
|
|
107
|
+
const parseLiteralTimestamp = (value, offset = 0) => {
|
|
108
|
+
let i = offset + 1;
|
|
109
|
+
while (isDateSymbol(value.charAt(i))) {
|
|
110
|
+
++i;
|
|
111
|
+
}
|
|
112
|
+
if (isDateTimeSeparatorSymbol(value.charAt(i))) {
|
|
113
|
+
++i;
|
|
114
|
+
while (isTimeSymbol(value.charAt(i))) {
|
|
115
|
+
++i;
|
|
116
|
+
}
|
|
117
|
+
if (value.charAt(i) === "." && (0, Number_js_1.isNumericSymbol)(value.charAt(i + 1))) {
|
|
118
|
+
++i;
|
|
119
|
+
while ((0, Number_js_1.isNumericSymbol)(value.charAt(i))) {
|
|
120
|
+
++i;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (value.charAt(i) === "Z") {
|
|
124
|
+
++i;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return [new Date(value.slice(offset + 1, i)), i];
|
|
128
|
+
};
|
|
129
|
+
exports.parseLiteralTimestamp = parseLiteralTimestamp;
|
|
130
|
+
const funcNow = new Constant_js_1.Constant(() => new Date(), Type_js_1.Type.functionType([[Type_js_1.Type.Timestamp, []]], true));
|
|
133
131
|
exports.funcYear = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCFullYear() : value.getFullYear()) : undefined, typeTimestampPart);
|
|
134
132
|
exports.funcMonth = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(1 + (utc ? value.getUTCMonth() : value.getMonth())) : undefined, typeTimestampPart);
|
|
135
133
|
exports.funcMonthIndex = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCMonth() : value.getMonth()) : undefined, typeTimestampPart);
|
|
@@ -139,7 +137,7 @@ exports.funcHour = new Constant_js_1.Constant((value, utc = false) => value ? Bi
|
|
|
139
137
|
exports.funcMinute = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCMinutes() : value.getMinutes()) : undefined, typeTimestampPart);
|
|
140
138
|
exports.funcSecond = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCSeconds() : value.getSeconds()) : undefined, typeTimestampPart);
|
|
141
139
|
exports.funcMillisecond = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCMilliseconds() : value.getMilliseconds()) : undefined, typeTimestampPart);
|
|
142
|
-
exports.funcEpochTime = new Constant_js_1.Constant((value, epoch = new Date(0)) => value ?
|
|
140
|
+
exports.funcEpochTime = new Constant_js_1.Constant((value, epoch = new Date(0)) => value ? BigInt(value.getTime() - epoch.getTime()) : undefined, Type_js_1.Type.functionType([[Type_js_1.Type.Integer, [Type_js_1.Type.Timestamp, Type_js_1.Type.OptionalTimestamp]]]));
|
|
143
141
|
exports.funcDaysSince = new Constant_js_1.Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 86400000.0, typeTimestampSince);
|
|
144
142
|
exports.funcHoursSince = new Constant_js_1.Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 3600000.0, typeTimestampSince);
|
|
145
143
|
exports.funcMinutesSince = new Constant_js_1.Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 60000.0, typeTimestampSince);
|
|
@@ -147,10 +145,10 @@ exports.funcSecondsSince = new Constant_js_1.Constant((value1, value2) => (value
|
|
|
147
145
|
const funcEpochTimestamp = new Constant_js_1.Constant((value, epoch = new Date(0)) => {
|
|
148
146
|
const ts = new Date(Number(value ?? 0) + epoch?.getTime());
|
|
149
147
|
return Number.isNaN(ts.getTime()) ? undefined : ts;
|
|
150
|
-
}, Type_js_1.Type.functionType(Type_js_1.Type.Timestamp, [Type_js_1.Type.Number, Type_js_1.Type.OptionalTimestamp]));
|
|
151
|
-
const funcDecodeTimestamp = new Constant_js_1.Constant((value, encoding = "i64", byteOffset) => (0, exports.decodeTimestamp)(value, encoding, byteOffset == null ? undefined : Number(byteOffset)), Type_js_1.Type.functionType(Type_js_1.Type.OptionalTimestamp, [Type_js_1.Type.OptionalBuffer, Type_js_1.Type.OptionalString, Type_js_1.Type.OptionalInteger]));
|
|
152
|
-
const funcParseTimestamp = new Constant_js_1.Constant((value) => parseTimestamp(value), Type_js_1.Type.functionType(Type_js_1.Type.OptionalTimestamp, [Type_js_1.Type.OptionalString]));
|
|
153
|
-
exports.
|
|
148
|
+
}, Type_js_1.Type.functionType([[Type_js_1.Type.Timestamp, [Type_js_1.Type.Number, Type_js_1.Type.OptionalTimestamp]]]));
|
|
149
|
+
const funcDecodeTimestamp = new Constant_js_1.Constant((value, encoding = "i64", byteOffset) => (0, exports.decodeTimestamp)(value, encoding, byteOffset == null ? undefined : Number(byteOffset)), Type_js_1.Type.functionType([[Type_js_1.Type.OptionalTimestamp, [Type_js_1.Type.OptionalBuffer, Type_js_1.Type.OptionalString, Type_js_1.Type.OptionalInteger]]]));
|
|
150
|
+
const funcParseTimestamp = new Constant_js_1.Constant((value) => parseTimestamp(value), Type_js_1.Type.functionType([[Type_js_1.Type.OptionalTimestamp, [Type_js_1.Type.OptionalString]]]));
|
|
151
|
+
exports.globTimestamp = Object.assign(Object.create(null), {
|
|
154
152
|
Now: funcNow,
|
|
155
153
|
Epoch: funcEpochTimestamp,
|
|
156
154
|
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
|
|
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
|
|
12
|
-
export declare const
|
|
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,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.funcFormat = exports.funcEncode = exports.
|
|
3
|
+
exports.funcFormat = exports.funcEncode = exports.funcNotEquals = exports.funcEquals = exports.funcCoalesce = exports.format = exports.encode = exports.equals = void 0;
|
|
4
4
|
const Constant_js_1 = require("../Constant.js");
|
|
5
5
|
const Type_js_1 = require("../Type.js");
|
|
6
6
|
const Buffer_js_1 = require("./Buffer.js");
|
|
7
7
|
const Float_js_1 = require("./Float.js");
|
|
8
8
|
const Integer_js_1 = require("./Integer.js");
|
|
9
|
-
const Number_js_1 = require("./Number.js");
|
|
10
9
|
const String_js_1 = require("./String.js");
|
|
11
10
|
const Timestamp_js_1 = require("./Timestamp.js");
|
|
12
|
-
const
|
|
11
|
+
const equals = (value1, value2, pairs) => {
|
|
13
12
|
if (value1 == null || value2 == null) {
|
|
14
13
|
return value1 == value2;
|
|
15
14
|
}
|
|
@@ -25,7 +24,10 @@ const equate = (value1, value2) => {
|
|
|
25
24
|
if (typeof value1 === "number") {
|
|
26
25
|
return isNaN(value1) && isNaN(value2) ? true : value1 === value2;
|
|
27
26
|
}
|
|
28
|
-
if (typeof value1 === "
|
|
27
|
+
if (typeof value1 === "bigint") {
|
|
28
|
+
return value1 === value2;
|
|
29
|
+
}
|
|
30
|
+
if (typeof value1 === "boolean" || typeof value1 === "string" || typeof value1 === "function") {
|
|
29
31
|
return value1 === value2;
|
|
30
32
|
}
|
|
31
33
|
if (value1 instanceof Date && value2 instanceof Date) {
|
|
@@ -35,15 +37,25 @@ const equate = (value1, value2) => {
|
|
|
35
37
|
return false;
|
|
36
38
|
}
|
|
37
39
|
if (value1 instanceof ArrayBuffer && value2 instanceof ArrayBuffer) {
|
|
38
|
-
return (0, Buffer_js_1.
|
|
40
|
+
return (0, Buffer_js_1.equalsBuffers)(value1, value2);
|
|
39
41
|
}
|
|
40
42
|
if (value1 instanceof ArrayBuffer || value2 instanceof ArrayBuffer) {
|
|
41
43
|
return false;
|
|
42
44
|
}
|
|
45
|
+
pairs ??= new WeakMap();
|
|
46
|
+
let matches = pairs.get(value1);
|
|
47
|
+
if (matches?.has(value2)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (!matches) {
|
|
51
|
+
matches = new WeakSet();
|
|
52
|
+
pairs.set(value1, matches);
|
|
53
|
+
}
|
|
54
|
+
matches.add(value2);
|
|
43
55
|
if (Array.isArray(value1) && Array.isArray(value2)) {
|
|
44
56
|
if (value1.length === value2.length) {
|
|
45
57
|
for (let i = 0; i < value1.length; ++i) {
|
|
46
|
-
if (!(0, exports.
|
|
58
|
+
if (!(0, exports.equals)(value1[i], value2[i], pairs)) {
|
|
47
59
|
return false;
|
|
48
60
|
}
|
|
49
61
|
}
|
|
@@ -54,15 +66,15 @@ const equate = (value1, value2) => {
|
|
|
54
66
|
if (Array.isArray(value1) || Array.isArray(value2)) {
|
|
55
67
|
return false;
|
|
56
68
|
}
|
|
57
|
-
const props = new Set([...Object.
|
|
69
|
+
const props = new Set([...Object.keys(value1), ...Object.keys(value2)]);
|
|
58
70
|
for (const prop of props) {
|
|
59
|
-
if (!(0, exports.
|
|
71
|
+
if (!(0, exports.equals)(value1[prop], value2[prop], pairs)) {
|
|
60
72
|
return false;
|
|
61
73
|
}
|
|
62
74
|
}
|
|
63
75
|
return true;
|
|
64
76
|
};
|
|
65
|
-
exports.
|
|
77
|
+
exports.equals = equals;
|
|
66
78
|
const encode = (value, encoding) => value == null
|
|
67
79
|
? Buffer_js_1.EmptyBuffer
|
|
68
80
|
: typeof value === "boolean"
|
|
@@ -92,9 +104,9 @@ const format = (value, formatting) => value == null
|
|
|
92
104
|
: value instanceof Date
|
|
93
105
|
? (0, Timestamp_js_1.formatTimestamp)(value, formatting)
|
|
94
106
|
: typeof value === "number"
|
|
95
|
-
? (0,
|
|
107
|
+
? (0, Float_js_1.formatFloat)(value, formatting)
|
|
96
108
|
: typeof value === "bigint"
|
|
97
|
-
? (0,
|
|
109
|
+
? (0, Integer_js_1.formatInteger)(value, formatting)
|
|
98
110
|
: value instanceof ArrayBuffer
|
|
99
111
|
? (0, Buffer_js_1.formatBuffer)(value, formatting)
|
|
100
112
|
: typeof value === "string"
|
|
@@ -107,9 +119,28 @@ const format = (value, formatting) => value == null
|
|
|
107
119
|
.reduce((acc, val) => acc + val, "")
|
|
108
120
|
: "";
|
|
109
121
|
exports.format = format;
|
|
110
|
-
const typeEquator = Type_js_1.Type.functionType(Type_js_1.Type.Boolean, [Type_js_1.Type.
|
|
111
|
-
exports.funcCoalesce = new Constant_js_1.Constant((value, valueOtherwise) => value ?? valueOtherwise, Type_js_1.Type.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
const typeEquator = Type_js_1.Type.functionType([[Type_js_1.Type.Boolean, [Type_js_1.Type.Any, Type_js_1.Type.Any]]]);
|
|
123
|
+
exports.funcCoalesce = new Constant_js_1.Constant((value, valueOtherwise) => value ?? valueOtherwise, Type_js_1.Type.functionType([
|
|
124
|
+
[Type_js_1.Type.Any, [Type_js_1.Type.Any, Type_js_1.Type.Any]],
|
|
125
|
+
[Type_js_1.Type.OptionalFloat, [Type_js_1.Type.OptionalFloat, Type_js_1.Type.OptionalFloat]],
|
|
126
|
+
[Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.OptionalBoolean, Type_js_1.Type.OptionalBoolean]],
|
|
127
|
+
[Type_js_1.Type.OptionalTimestamp, [Type_js_1.Type.OptionalTimestamp, Type_js_1.Type.OptionalTimestamp]],
|
|
128
|
+
[Type_js_1.Type.OptionalInteger, [Type_js_1.Type.OptionalInteger, Type_js_1.Type.OptionalInteger]],
|
|
129
|
+
[Type_js_1.Type.OptionalBuffer, [Type_js_1.Type.OptionalBuffer, Type_js_1.Type.OptionalBuffer]],
|
|
130
|
+
[Type_js_1.Type.OptionalString, [Type_js_1.Type.OptionalString, Type_js_1.Type.OptionalString]],
|
|
131
|
+
[Type_js_1.Type.OptionalArray, [Type_js_1.Type.OptionalArray, Type_js_1.Type.OptionalArray]],
|
|
132
|
+
[Type_js_1.Type.OptionalObject, [Type_js_1.Type.OptionalObject, Type_js_1.Type.OptionalObject]],
|
|
133
|
+
[Type_js_1.Type.OptionalFunction, [Type_js_1.Type.OptionalFunction, Type_js_1.Type.OptionalFunction]],
|
|
134
|
+
]));
|
|
135
|
+
exports.funcEquals = new Constant_js_1.Constant((value1, value2) => (0, exports.equals)(value1, value2), typeEquator);
|
|
136
|
+
exports.funcNotEquals = new Constant_js_1.Constant((value1, value2) => !(0, exports.equals)(value1, value2), typeEquator);
|
|
137
|
+
const typeWithEncoding = Type_js_1.Type.union(Type_js_1.Type.Null, Type_js_1.Type.Timestamp, Type_js_1.Type.Number, Type_js_1.Type.String, Type_js_1.Type.Composite);
|
|
138
|
+
const typeWithFormatting = Type_js_1.Type.union(Type_js_1.Type.Null, Type_js_1.Type.Timestamp, Type_js_1.Type.Number, Type_js_1.Type.Buffer, Type_js_1.Type.Composite);
|
|
139
|
+
exports.funcEncode = new Constant_js_1.Constant((value, encoding) => (0, exports.encode)(value, encoding), Type_js_1.Type.functionType([
|
|
140
|
+
[Type_js_1.Type.Buffer, [Type_js_1.Type.Any]],
|
|
141
|
+
[Type_js_1.Type.Buffer, [typeWithEncoding, Type_js_1.Type.OptionalString]],
|
|
142
|
+
]));
|
|
143
|
+
exports.funcFormat = new Constant_js_1.Constant((value, formatting) => (0, exports.format)(value, formatting), Type_js_1.Type.functionType([
|
|
144
|
+
[Type_js_1.Type.String, [Type_js_1.Type.Any]],
|
|
145
|
+
[Type_js_1.Type.String, [typeWithFormatting, Type_js_1.Type.OptionalString]],
|
|
146
|
+
]));
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.globAN = exports.parseAN = exports.formatAN = void 0;
|
|
4
4
|
const Constant_js_1 = require("../../Constant.js");
|
|
5
5
|
const ParserState_js_1 = require("../../ParserState.js");
|
|
6
6
|
const Type_js_1 = require("../../Type.js");
|
|
7
|
-
const
|
|
7
|
+
const Float_js_1 = require("../Float.js");
|
|
8
8
|
const Integer_js_1 = require("../Integer.js");
|
|
9
|
-
const Number_js_1 = require("../Number.js");
|
|
10
9
|
const Buffer_js_1 = require("../Buffer.js");
|
|
11
10
|
const String_js_1 = require("../String.js");
|
|
12
11
|
const Timestamp_js_1 = require("../Timestamp.js");
|
|
13
|
-
const typeAN = Type_js_1.Type.union(Type_js_1.Type.
|
|
12
|
+
const typeAN = Type_js_1.Type.union(Type_js_1.Type.Null, Type_js_1.Type.Boolean, Type_js_1.Type.Timestamp, Type_js_1.Type.Float, Type_js_1.Type.Integer, Type_js_1.Type.Buffer, Type_js_1.Type.String, Type_js_1.Type.Array, Type_js_1.Type.Object);
|
|
14
13
|
const formatAN = (value, whitespace) => {
|
|
15
14
|
if (value == null) {
|
|
16
15
|
return "null";
|
|
@@ -21,8 +20,11 @@ const formatAN = (value, whitespace) => {
|
|
|
21
20
|
if (value instanceof Date) {
|
|
22
21
|
return (0, Timestamp_js_1.formatLiteralTimestamp)(value);
|
|
23
22
|
}
|
|
24
|
-
if (typeof value === "
|
|
25
|
-
return (0,
|
|
23
|
+
if (typeof value === "number") {
|
|
24
|
+
return (0, Float_js_1.formatLiteralFloat)(value);
|
|
25
|
+
}
|
|
26
|
+
if (typeof value === "bigint") {
|
|
27
|
+
return (0, Integer_js_1.formatLiteralInteger)(value);
|
|
26
28
|
}
|
|
27
29
|
if (value instanceof ArrayBuffer) {
|
|
28
30
|
return (0, Buffer_js_1.formatLiteralBuffer)(value);
|
|
@@ -45,20 +47,20 @@ const formatAN = (value, whitespace) => {
|
|
|
45
47
|
exports.formatAN = formatAN;
|
|
46
48
|
const parseArray = (state, firstValue) => {
|
|
47
49
|
const arr = [firstValue];
|
|
48
|
-
while (!state.
|
|
49
|
-
if (state.
|
|
50
|
+
while (!state.isEnded) {
|
|
51
|
+
if (state.equals("]")) {
|
|
50
52
|
state.next();
|
|
51
53
|
return arr;
|
|
52
54
|
}
|
|
53
|
-
if (!state.
|
|
55
|
+
if (!state.equals(",")) {
|
|
54
56
|
state.throwError("missing array value separator");
|
|
55
57
|
}
|
|
56
58
|
state.next();
|
|
57
|
-
if (state.
|
|
59
|
+
if (state.equals("]")) {
|
|
58
60
|
state.next();
|
|
59
61
|
return arr;
|
|
60
62
|
}
|
|
61
|
-
if (state.
|
|
63
|
+
if (state.equals(",")) {
|
|
62
64
|
arr.push(undefined);
|
|
63
65
|
continue;
|
|
64
66
|
}
|
|
@@ -69,21 +71,21 @@ const parseArray = (state, firstValue) => {
|
|
|
69
71
|
const parseObject = (state, firstKey) => {
|
|
70
72
|
const obj = Object.create(null);
|
|
71
73
|
let key = firstKey;
|
|
72
|
-
while (!state.
|
|
73
|
-
if (!state.
|
|
74
|
+
while (!state.isEnded) {
|
|
75
|
+
if (!state.equals(":")) {
|
|
74
76
|
state.throwError("missing object key separator");
|
|
75
77
|
}
|
|
76
78
|
state.next();
|
|
77
|
-
obj[key] = state.
|
|
78
|
-
if (state.
|
|
79
|
+
obj[key] = state.equals(",") || state.equals("]") ? undefined : parseLiteral(state);
|
|
80
|
+
if (state.equals("]")) {
|
|
79
81
|
state.next();
|
|
80
82
|
return obj;
|
|
81
83
|
}
|
|
82
|
-
if (!state.
|
|
84
|
+
if (!state.equals(",")) {
|
|
83
85
|
state.throwError("missing object property separator");
|
|
84
86
|
}
|
|
85
87
|
state.next();
|
|
86
|
-
if (state.
|
|
88
|
+
if (state.equals("]")) {
|
|
87
89
|
state.next();
|
|
88
90
|
return obj;
|
|
89
91
|
}
|
|
@@ -104,12 +106,12 @@ const parseLiteral = (state) => {
|
|
|
104
106
|
state.next();
|
|
105
107
|
return value;
|
|
106
108
|
}
|
|
107
|
-
if (state.isType && state.type.
|
|
109
|
+
if (state.isType && state.type.isNull) {
|
|
108
110
|
state.next();
|
|
109
111
|
return undefined;
|
|
110
112
|
}
|
|
111
|
-
if (state.
|
|
112
|
-
const token = state.
|
|
113
|
+
if (state.isIdentifier) {
|
|
114
|
+
const token = state.identifier;
|
|
113
115
|
if (token === "NaN") {
|
|
114
116
|
state.next();
|
|
115
117
|
return NaN;
|
|
@@ -120,10 +122,10 @@ const parseLiteral = (state) => {
|
|
|
120
122
|
}
|
|
121
123
|
state.throwError(`invalid value ${token}`);
|
|
122
124
|
}
|
|
123
|
-
if (state.
|
|
124
|
-
const negative = state.
|
|
125
|
+
if (state.equals("+", "-")) {
|
|
126
|
+
const negative = state.equals("-");
|
|
125
127
|
state.next();
|
|
126
|
-
if (state.
|
|
128
|
+
if (state.isIdentifier && state.identifier === "Infinity") {
|
|
127
129
|
state.next();
|
|
128
130
|
return negative ? -Infinity : Infinity;
|
|
129
131
|
}
|
|
@@ -133,28 +135,28 @@ const parseLiteral = (state) => {
|
|
|
133
135
|
const value = state.literal.value;
|
|
134
136
|
state.next();
|
|
135
137
|
return negative
|
|
136
|
-
? typeof value === "bigint" ? (0, Integer_js_1.
|
|
138
|
+
? typeof value === "bigint" ? (0, Integer_js_1.int64)(-value) : -value
|
|
137
139
|
: value;
|
|
138
140
|
}
|
|
139
|
-
if (state.
|
|
141
|
+
if (state.equals("[")) {
|
|
140
142
|
state.next();
|
|
141
|
-
if (state.
|
|
143
|
+
if (state.equals("]")) {
|
|
142
144
|
state.next();
|
|
143
145
|
return [];
|
|
144
146
|
}
|
|
145
|
-
if (state.
|
|
147
|
+
if (state.equals(":")) {
|
|
146
148
|
state.next();
|
|
147
|
-
if (!state.
|
|
149
|
+
if (!state.equals("]")) {
|
|
148
150
|
state.throwError("missing closing object bracket");
|
|
149
151
|
}
|
|
150
152
|
state.next();
|
|
151
153
|
return Object.create(null);
|
|
152
154
|
}
|
|
153
|
-
if (state.
|
|
155
|
+
if (state.equals(",")) {
|
|
154
156
|
return parseArray(state, undefined);
|
|
155
157
|
}
|
|
156
158
|
const first = parseLiteral(state);
|
|
157
|
-
if (state.
|
|
159
|
+
if (state.equals(":")) {
|
|
158
160
|
if (typeof first !== "string") {
|
|
159
161
|
state.throwError("object key must be a string");
|
|
160
162
|
}
|
|
@@ -169,19 +171,19 @@ const parseAN = (value) => {
|
|
|
169
171
|
return undefined;
|
|
170
172
|
}
|
|
171
173
|
const state = new ParserState_js_1.ParserState(value).next();
|
|
172
|
-
if (state.
|
|
174
|
+
if (state.isEnded) {
|
|
173
175
|
return undefined;
|
|
174
176
|
}
|
|
175
177
|
const result = parseLiteral(state);
|
|
176
|
-
if (!state.
|
|
178
|
+
if (!state.isEnded) {
|
|
177
179
|
state.throwError("unexpected token");
|
|
178
180
|
}
|
|
179
181
|
return result;
|
|
180
182
|
};
|
|
181
183
|
exports.parseAN = parseAN;
|
|
182
|
-
const funcFormatAN = new Constant_js_1.Constant((value, whitespace) => (0, exports.formatAN)(value, whitespace), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.
|
|
183
|
-
const funcParseAN = new Constant_js_1.Constant((value) => (0, exports.parseAN)(value), Type_js_1.Type.functionType(typeAN, [Type_js_1.Type.OptionalString]));
|
|
184
|
-
exports.
|
|
184
|
+
const funcFormatAN = new Constant_js_1.Constant((value, whitespace) => (0, exports.formatAN)(value, whitespace), Type_js_1.Type.functionType([[Type_js_1.Type.String, [Type_js_1.Type.Any, Type_js_1.Type.OptionalString]]]));
|
|
185
|
+
const funcParseAN = new Constant_js_1.Constant((value) => (0, exports.parseAN)(value), Type_js_1.Type.functionType([[typeAN, [Type_js_1.Type.OptionalString]]]));
|
|
186
|
+
exports.globAN = Object.assign(Object.create(null), {
|
|
185
187
|
Format: funcFormatAN,
|
|
186
188
|
Parse: funcParseAN,
|
|
187
189
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const globIP: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.globIP = void 0;
|
|
4
4
|
const Constant_js_1 = require("../../Constant.js");
|
|
5
5
|
const Type_js_1 = require("../../Type.js");
|
|
6
6
|
const Buffer_js_1 = require("../Buffer.js");
|
|
@@ -48,8 +48,8 @@ function encodeIP(value) {
|
|
|
48
48
|
const lastPart = zeroCompressionFlag ? endParts[endParts.length - 1] : beginParts[beginParts.length - 1];
|
|
49
49
|
const ipv4TailFlag = lastPart?.includes(".");
|
|
50
50
|
if (ipv4TailFlag) {
|
|
51
|
-
if (zeroCompressionFlag && beginParts.length + endParts.length > 6
|
|
52
|
-
|
|
51
|
+
if (zeroCompressionFlag && beginParts.length + endParts.length > 6 ||
|
|
52
|
+
!zeroCompressionFlag && beginParts.length + endParts.length !== 7) {
|
|
53
53
|
throw new Error(`Invalid IP address: ${value}`);
|
|
54
54
|
}
|
|
55
55
|
const ipv4Parts = lastPart.split(".");
|
|
@@ -62,8 +62,8 @@ function encodeIP(value) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
65
|
-
if (zeroCompressionFlag && beginParts.length + endParts.length > 7
|
|
66
|
-
|
|
65
|
+
if (zeroCompressionFlag && beginParts.length + endParts.length > 7 ||
|
|
66
|
+
!zeroCompressionFlag && beginParts.length + endParts.length !== 8) {
|
|
67
67
|
throw new Error(`Invalid IP address: ${value}`);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -195,11 +195,10 @@ class IPSet {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
const
|
|
199
|
-
const funcMatchIP = new Constant_js_1.Constant((values, search) => {
|
|
198
|
+
const funcMatchIP = new Constant_js_1.Constant((values, ...search) => {
|
|
200
199
|
try {
|
|
201
200
|
const ipset = new IPSet().add(values);
|
|
202
|
-
for (const ip of search
|
|
201
|
+
for (const ip of search) {
|
|
203
202
|
try {
|
|
204
203
|
if (ipset.has(ip)) {
|
|
205
204
|
return true;
|
|
@@ -210,7 +209,7 @@ const funcMatchIP = new Constant_js_1.Constant((values, search) => {
|
|
|
210
209
|
}
|
|
211
210
|
catch { }
|
|
212
211
|
return false;
|
|
213
|
-
}, Type_js_1.Type.functionType(Type_js_1.Type.Boolean, [Type_js_1.Type.arrayType(
|
|
212
|
+
}, Type_js_1.Type.functionType([[Type_js_1.Type.Boolean, [Type_js_1.Type.arrayType(Type_js_1.Type.String), Type_js_1.Type.arrayType(Type_js_1.Type.String)], true]]));
|
|
214
213
|
const funcEncodeIP = new Constant_js_1.Constant((value) => {
|
|
215
214
|
if (value == null) {
|
|
216
215
|
return Buffer_js_1.EmptyBuffer;
|
|
@@ -221,7 +220,7 @@ const funcEncodeIP = new Constant_js_1.Constant((value) => {
|
|
|
221
220
|
catch {
|
|
222
221
|
return Buffer_js_1.EmptyBuffer;
|
|
223
222
|
}
|
|
224
|
-
}, Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.OptionalString]));
|
|
223
|
+
}, Type_js_1.Type.functionType([[Type_js_1.Type.Buffer, [Type_js_1.Type.OptionalString]]]));
|
|
225
224
|
const funcDecodeIP = new Constant_js_1.Constant((value) => {
|
|
226
225
|
if (value == null) {
|
|
227
226
|
return undefined;
|
|
@@ -232,8 +231,8 @@ const funcDecodeIP = new Constant_js_1.Constant((value) => {
|
|
|
232
231
|
catch {
|
|
233
232
|
return undefined;
|
|
234
233
|
}
|
|
235
|
-
}, Type_js_1.Type.functionType(Type_js_1.Type.OptionalString, [Type_js_1.Type.OptionalBuffer]));
|
|
236
|
-
exports.
|
|
234
|
+
}, Type_js_1.Type.functionType([[Type_js_1.Type.OptionalString, [Type_js_1.Type.OptionalBuffer]]]));
|
|
235
|
+
exports.globIP = Object.assign(Object.create(null), {
|
|
237
236
|
Match: funcMatchIP,
|
|
238
237
|
Encode: funcEncodeIP,
|
|
239
238
|
Decode: funcDecodeIP,
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.globJSON = exports.formatJSON = void 0;
|
|
4
4
|
const Constant_js_1 = require("../../Constant.js");
|
|
5
|
+
const Value_js_1 = require("../../Value.js");
|
|
5
6
|
const Type_js_1 = require("../../Type.js");
|
|
6
|
-
const typeJson = Type_js_1.Type.union(Type_js_1.Type.
|
|
7
|
-
const formatJSON = (value, whitespace) => value == null ? "" : JSON.stringify(value, (_key, value) => typeof value === "bigint" ? value.toString() : value, whitespace);
|
|
7
|
+
const typeJson = Type_js_1.Type.union(Type_js_1.Type.Null, Type_js_1.Type.Boolean, Type_js_1.Type.Timestamp, Type_js_1.Type.Float, Type_js_1.Type.Integer, Type_js_1.Type.String, Type_js_1.Type.Array, Type_js_1.Type.Object);
|
|
8
|
+
const formatJSON = (value, whitespace) => value == null ? "null" : JSON.stringify(value, (_key, value) => typeof value === "bigint" ? value.toString() : value ?? null, whitespace);
|
|
8
9
|
exports.formatJSON = formatJSON;
|
|
9
|
-
const funcFormatJSON = new Constant_js_1.Constant((value, whitespace) => (0, exports.formatJSON)(value, whitespace), Type_js_1.Type.functionType(Type_js_1.Type.String, [typeJson, Type_js_1.Type.OptionalString]));
|
|
10
|
-
const funcParseJSON = new Constant_js_1.Constant((value) => value == null ? undefined : JSON.parse(value), Type_js_1.Type.functionType(typeJson, [Type_js_1.Type.OptionalString]));
|
|
11
|
-
exports.
|
|
10
|
+
const funcFormatJSON = new Constant_js_1.Constant((value, whitespace) => (0, exports.formatJSON)(value, whitespace), Type_js_1.Type.functionType([[Type_js_1.Type.String, [typeJson, Type_js_1.Type.OptionalString]]]));
|
|
11
|
+
const funcParseJSON = new Constant_js_1.Constant((value) => value == null ? undefined : (0, Value_js_1.normalize)(JSON.parse(value)), Type_js_1.Type.functionType([[typeJson, [Type_js_1.Type.OptionalString]]]));
|
|
12
|
+
exports.globJSON = Object.assign(Object.create(null), {
|
|
12
13
|
Format: funcFormatJSON,
|
|
13
14
|
Parse: funcParseJSON,
|
|
14
15
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AssignableNode, AssignmentResolver } from "./AssignableNode.js";
|
|
2
|
+
import { Node } from "./Node.js";
|
|
3
|
+
import { Constant } from "../Constant.js";
|
|
4
|
+
import { ParserSpan } from "../ParserSpan.js";
|
|
5
|
+
import { Value } from "../Value.js";
|
|
6
|
+
import { Type } from "../Type.js";
|
|
7
|
+
import { CallFrame } from "../CallFrame.js";
|
|
8
|
+
export declare class AccessNode extends AssignableNode {
|
|
9
|
+
protected _subnode: Node;
|
|
10
|
+
protected _inode: Node;
|
|
11
|
+
protected readonly _operator: Constant;
|
|
12
|
+
protected _type?: Type;
|
|
13
|
+
constructor(span: ParserSpan, subnode: Node, inode: Node, operator: Constant);
|
|
14
|
+
get type(): Type;
|
|
15
|
+
get assignable(): boolean;
|
|
16
|
+
get optionalAssignment(): boolean;
|
|
17
|
+
get constant(): boolean;
|
|
18
|
+
compile(type?: Type): Node;
|
|
19
|
+
compileAssignment(type: Type): AssignableNode;
|
|
20
|
+
evaluate(frame: CallFrame): Value;
|
|
21
|
+
resolver(frame: CallFrame): AssignmentResolver | undefined;
|
|
22
|
+
toString(indent?: number): string;
|
|
23
|
+
private _compileAccess;
|
|
24
|
+
}
|