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,20 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const Aggregable_js_1 = require("
|
|
5
|
-
const Array_js_1 = require("
|
|
6
|
-
const Boolean_js_1 = require("
|
|
7
|
-
const Buffer_js_1 = require("
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
3
|
+
exports.functions = void 0;
|
|
4
|
+
const Aggregable_js_1 = require("../native/Aggregable.js");
|
|
5
|
+
const Array_js_1 = require("../native/Array.js");
|
|
6
|
+
const Boolean_js_1 = require("../native/Boolean.js");
|
|
7
|
+
const Buffer_js_1 = require("../native/Buffer.js");
|
|
8
|
+
const Composite_js_1 = require("../native/Composite.js");
|
|
9
|
+
const Enumerable_js_1 = require("../native/Enumerable.js");
|
|
10
|
+
const Float_js_1 = require("../native/Float.js");
|
|
11
|
+
const Integer_js_1 = require("../native/Integer.js");
|
|
12
|
+
const Iterable_js_1 = require("../native/Iterable.js");
|
|
13
|
+
const Number_js_1 = require("../native/Number.js");
|
|
14
|
+
const Object_js_1 = require("../native/Object.js");
|
|
15
|
+
const String_js_1 = require("../native/String.js");
|
|
16
|
+
const Timestamp_js_1 = require("../native/Timestamp.js");
|
|
17
|
+
const Unknown_js_1 = require("../native/Unknown.js");
|
|
18
|
+
exports.functions = [
|
|
18
19
|
// Aggregable
|
|
19
20
|
["Add", Aggregable_js_1.funcAdd],
|
|
20
21
|
// Array
|
|
@@ -30,10 +31,13 @@ exports.Functions = [
|
|
|
30
31
|
["Filter", Array_js_1.funcFilter],
|
|
31
32
|
["Reduce", Array_js_1.funcReduce],
|
|
32
33
|
["Compose", Array_js_1.funcCompose],
|
|
33
|
-
["Prepend", Array_js_1.funcPrepend],
|
|
34
|
-
["Append", Array_js_1.funcAppend],
|
|
35
34
|
// Buffer
|
|
36
|
-
["
|
|
35
|
+
["ByteAt", Buffer_js_1.funcByteAt],
|
|
36
|
+
// Composite
|
|
37
|
+
["At", Composite_js_1.funcAt],
|
|
38
|
+
["OptionalAt", Composite_js_1.funcOptionalAt],
|
|
39
|
+
["Has", Composite_js_1.funcHas],
|
|
40
|
+
["OptionalHas", Composite_js_1.funcOptionalHas],
|
|
37
41
|
// Enumerable
|
|
38
42
|
["Slice", Enumerable_js_1.funcSlice],
|
|
39
43
|
["Splice", Enumerable_js_1.funcSplice],
|
|
@@ -41,8 +45,6 @@ exports.Functions = [
|
|
|
41
45
|
// Iterable
|
|
42
46
|
["Length", Iterable_js_1.funcLength],
|
|
43
47
|
["Contains", Iterable_js_1.funcContains],
|
|
44
|
-
["At", Iterable_js_1.funcAt],
|
|
45
|
-
["Has", Iterable_js_1.funcHas],
|
|
46
48
|
// Number
|
|
47
49
|
["GreaterThan", Number_js_1.funcGreaterThan],
|
|
48
50
|
["LessThan", Number_js_1.funcLessThan],
|
|
@@ -65,11 +67,11 @@ exports.Functions = [
|
|
|
65
67
|
["Values", Object_js_1.funcValues],
|
|
66
68
|
// String
|
|
67
69
|
["Like", String_js_1.funcLike],
|
|
68
|
-
["
|
|
70
|
+
["NotLike", String_js_1.funcNotLike],
|
|
69
71
|
["StartsWith", String_js_1.funcStartsWith],
|
|
70
72
|
["EndsWith", String_js_1.funcEndsWith],
|
|
71
|
-
["
|
|
72
|
-
["
|
|
73
|
+
["CharAt", String_js_1.funcCharAt],
|
|
74
|
+
["CharCodeAt", String_js_1.funcCharCodeAt],
|
|
73
75
|
["Trim", String_js_1.funcTrim],
|
|
74
76
|
["TrimStart", String_js_1.funcTrimStart],
|
|
75
77
|
["TrimEnd", String_js_1.funcTrimEnd],
|
|
@@ -94,8 +96,8 @@ exports.Functions = [
|
|
|
94
96
|
["SecondsSince", Timestamp_js_1.funcSecondsSince],
|
|
95
97
|
// Unknown
|
|
96
98
|
["Coalesce", Unknown_js_1.funcCoalesce],
|
|
97
|
-
["
|
|
98
|
-
["
|
|
99
|
+
["Equals", Unknown_js_1.funcEquals],
|
|
100
|
+
["NotEquals", Unknown_js_1.funcNotEquals],
|
|
99
101
|
["Encode", Unknown_js_1.funcEncode],
|
|
100
102
|
["Format", Unknown_js_1.funcFormat],
|
|
101
103
|
];
|
|
@@ -20,11 +20,19 @@ const aggregate = (value1, value2) => {
|
|
|
20
20
|
exports.aggregate = aggregate;
|
|
21
21
|
const add = (value1, value2) => {
|
|
22
22
|
if (typeof value1 === "bigint" && typeof value2 === "bigint") {
|
|
23
|
-
return (0, Integer_js_1.
|
|
23
|
+
return (0, Integer_js_1.int64)(value1 + value2);
|
|
24
24
|
}
|
|
25
25
|
if ((typeof value1 === "number" || typeof value1 === "bigint") && (typeof value2 === "number" || typeof value2 === "bigint")) {
|
|
26
26
|
return Number(value1) + Number(value2);
|
|
27
27
|
}
|
|
28
28
|
return (0, exports.aggregate)(value1, value2);
|
|
29
29
|
};
|
|
30
|
-
exports.funcAdd = new Constant_js_1.Constant((value1, value2) => add(value1, value2), Type_js_1.Type.
|
|
30
|
+
exports.funcAdd = new Constant_js_1.Constant((value1, value2) => add(value1, value2), Type_js_1.Type.functionType([
|
|
31
|
+
[Type_js_1.Type.Integer, [Type_js_1.Type.Integer, Type_js_1.Type.Integer]],
|
|
32
|
+
[Type_js_1.Type.Float, [Type_js_1.Type.Float, Type_js_1.Type.Number]],
|
|
33
|
+
[Type_js_1.Type.Float, [Type_js_1.Type.Number, Type_js_1.Type.Float]],
|
|
34
|
+
[Type_js_1.Type.Number, [Type_js_1.Type.Number, Type_js_1.Type.Number]],
|
|
35
|
+
[Type_js_1.Type.Buffer, [Type_js_1.Type.Buffer, Type_js_1.Type.Buffer]],
|
|
36
|
+
[Type_js_1.Type.String, [Type_js_1.Type.String, Type_js_1.Type.String]],
|
|
37
|
+
[Type_js_1.Type.Array, [Type_js_1.Type.Array, Type_js_1.Type.Array]],
|
|
38
|
+
]));
|
|
@@ -11,6 +11,5 @@ export declare const funcDerive: Constant;
|
|
|
11
11
|
export declare const funcFilter: Constant;
|
|
12
12
|
export declare const funcReduce: Constant;
|
|
13
13
|
export declare const funcCompose: Constant;
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const constArray: any;
|
|
14
|
+
export declare const funcRange: Constant;
|
|
15
|
+
export declare const globArray: any;
|
package/dst/cjs/native/Array.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.globArray = exports.funcRange = exports.funcCompose = exports.funcReduce = exports.funcFilter = exports.funcDerive = exports.funcReverse = exports.funcFlatten = exports.funcAny = exports.funcEvery = exports.funcLastIndex = exports.funcFirstIndex = exports.funcLast = exports.funcFirst = 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 Unknown_js_1 = require("./Unknown.js");
|
|
8
|
-
const typePredicate = Type_js_1.Type.functionType(Type_js_1.Type.Boolean, [Type_js_1.Type.
|
|
9
|
-
const typeItemFinder = Type_js_1.Type.functionType(Type_js_1.Type.
|
|
10
|
-
const typeIndexFinder = Type_js_1.Type.functionType(Type_js_1.Type.OptionalInteger, [Type_js_1.Type.Array, typePredicate]);
|
|
11
|
-
const typeConditionSet = Type_js_1.Type.functionType(Type_js_1.Type.Boolean, [Type_js_1.Type.Array, typePredicate]);
|
|
12
|
-
const
|
|
13
|
-
const typeArrayOperator = Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_1.Type.Array, Type_js_1.Type.Array]);
|
|
7
|
+
const typePredicate = Type_js_1.Type.functionType([[Type_js_1.Type.Boolean, [Type_js_1.Type.Any, Type_js_1.Type.Integer, Type_js_1.Type.Array]]]);
|
|
8
|
+
const typeItemFinder = Type_js_1.Type.functionType([[Type_js_1.Type.Any, [Type_js_1.Type.Array, typePredicate]]]);
|
|
9
|
+
const typeIndexFinder = Type_js_1.Type.functionType([[Type_js_1.Type.OptionalInteger, [Type_js_1.Type.Array, typePredicate]]]);
|
|
10
|
+
const typeConditionSet = Type_js_1.Type.functionType([[Type_js_1.Type.Boolean, [Type_js_1.Type.Array, typePredicate]]]);
|
|
11
|
+
const typeArrayOperator = Type_js_1.Type.functionType([[Type_js_1.Type.Array, [Type_js_1.Type.Array, Type_js_1.Type.Array]]]);
|
|
14
12
|
exports.funcFirst = new Constant_js_1.Constant((value, predicate) => value?.find((v, i, a) => predicate(v, BigInt(i), a)), typeItemFinder);
|
|
15
13
|
exports.funcLast = new Constant_js_1.Constant((value, predicate) => {
|
|
16
14
|
if (value == null) {
|
|
@@ -28,7 +26,7 @@ exports.funcFirstIndex = new Constant_js_1.Constant((value, predicate) => {
|
|
|
28
26
|
return undefined;
|
|
29
27
|
}
|
|
30
28
|
const ix = value.findIndex((v, i, a) => predicate(v, BigInt(i), a));
|
|
31
|
-
return ix < 0 ? undefined :
|
|
29
|
+
return ix < 0 ? undefined : BigInt(ix);
|
|
32
30
|
}, typeIndexFinder);
|
|
33
31
|
exports.funcLastIndex = new Constant_js_1.Constant((value, predicate) => {
|
|
34
32
|
if (value == null) {
|
|
@@ -36,60 +34,61 @@ exports.funcLastIndex = new Constant_js_1.Constant((value, predicate) => {
|
|
|
36
34
|
}
|
|
37
35
|
for (let i = value.length - 1; i >= 0; i--) {
|
|
38
36
|
if (predicate(value[i], BigInt(i), value)) {
|
|
39
|
-
return
|
|
37
|
+
return BigInt(i);
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
return undefined;
|
|
43
41
|
}, typeIndexFinder);
|
|
44
42
|
exports.funcEvery = new Constant_js_1.Constant((value, predicate) => value?.every((v, i, a) => predicate(v, BigInt(i), a)) ?? false, typeConditionSet);
|
|
45
43
|
exports.funcAny = new Constant_js_1.Constant((value, predicate) => value?.some((v, i, a) => predicate(v, BigInt(i), a)) ?? false, typeConditionSet);
|
|
46
|
-
exports.funcFlatten = new Constant_js_1.Constant((values, depth = 1n) => values ? values?.flat(Number(depth)) : undefined, Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_1.Type.Array, Type_js_1.Type.OptionalInteger]));
|
|
47
|
-
exports.funcReverse = new Constant_js_1.Constant((value) => value ? [...value].reverse() : undefined, Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_1.Type.Array]));
|
|
48
|
-
exports.funcDerive = new Constant_js_1.Constant((value, transform) => value?.map((v, i, a) => transform(v, BigInt(i), a)), Type_js_1.Type.functionType(
|
|
49
|
-
|
|
44
|
+
exports.funcFlatten = new Constant_js_1.Constant((values, depth = 1n) => values ? values?.flat(Number(depth)) : undefined, Type_js_1.Type.functionType([[Type_js_1.Type.Array, [Type_js_1.Type.Array, Type_js_1.Type.OptionalInteger]]]));
|
|
45
|
+
exports.funcReverse = new Constant_js_1.Constant((value) => value ? [...value].reverse() : undefined, Type_js_1.Type.functionType([[Type_js_1.Type.Array, [Type_js_1.Type.Array]]]));
|
|
46
|
+
exports.funcDerive = new Constant_js_1.Constant((value, transform) => value?.map((v, i, a) => transform(v, BigInt(i), a)), Type_js_1.Type.functionType([[Type_js_1.Type.Array, [
|
|
47
|
+
Type_js_1.Type.Array,
|
|
48
|
+
Type_js_1.Type.functionType([[Type_js_1.Type.Any, [Type_js_1.Type.Any, Type_js_1.Type.Integer, Type_js_1.Type.Array]]]),
|
|
49
|
+
]]]));
|
|
50
|
+
exports.funcFilter = new Constant_js_1.Constant((value, predicate) => value?.filter((v, i, a) => predicate(v, BigInt(i), a)), Type_js_1.Type.functionType([[Type_js_1.Type.Array, [Type_js_1.Type.Array, typePredicate]]]));
|
|
50
51
|
exports.funcReduce = new Constant_js_1.Constant((value, reducer, initial) => initial != null
|
|
51
52
|
? value?.reduce((p, v, i, a) => reducer(p, v, BigInt(i), a), initial)
|
|
52
|
-
: value?.reduce((p, v, i, a) => reducer(p, v, BigInt(i), a)), Type_js_1.Type.functionType(
|
|
53
|
+
: value?.reduce((p, v, i, a) => reducer(p, v, BigInt(i), a)), Type_js_1.Type.functionType([[Type_js_1.Type.Any, [
|
|
54
|
+
Type_js_1.Type.Array,
|
|
55
|
+
Type_js_1.Type.functionType([[Type_js_1.Type.Any, [Type_js_1.Type.Any, Type_js_1.Type.Any, Type_js_1.Type.Integer, Type_js_1.Type.Array]]]),
|
|
56
|
+
Type_js_1.Type.Any,
|
|
57
|
+
]]]));
|
|
53
58
|
exports.funcCompose = new Constant_js_1.Constant((value, callback) => {
|
|
54
59
|
if (value == null) {
|
|
55
60
|
return undefined;
|
|
56
61
|
}
|
|
57
|
-
|
|
62
|
+
let obj = Object.create(null);
|
|
58
63
|
for (let i = 0; i < value.length; ++i) {
|
|
59
64
|
const key = value[i];
|
|
60
|
-
|
|
65
|
+
const item = callback(obj, key, BigInt(i), value);
|
|
66
|
+
obj = Object.assign(Object.create(null), obj, { [key]: item });
|
|
61
67
|
}
|
|
62
68
|
return obj;
|
|
63
|
-
}, Type_js_1.Type.functionType(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
exports.
|
|
69
|
-
|
|
70
|
-
return
|
|
71
|
-
},
|
|
72
|
-
const funcJoin = new Constant_js_1.Constant((values) => values.flat(Infinity), Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_1.Type.arrayType([Type_js_1.Type.Array])], true));
|
|
73
|
-
const funcRange = new Constant_js_1.Constant((value1, value2) => {
|
|
74
|
-
const v1 = (0, Integer_js_1.boundInteger)(value1);
|
|
75
|
-
const v2 = (0, Integer_js_1.boundInteger)(value2);
|
|
76
|
-
const [min, max] = v1 < v2 ? [v1, v2] : [v2, v1];
|
|
77
|
-
return [...Array(Number(max - min)).keys()].map((i) => BigInt(i) + min);
|
|
78
|
-
}, Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_1.Type.Integer, Type_js_1.Type.Integer]));
|
|
69
|
+
}, Type_js_1.Type.functionType([[Type_js_1.Type.Object, [
|
|
70
|
+
Type_js_1.Type.Array,
|
|
71
|
+
Type_js_1.Type.functionType([[Type_js_1.Type.Any, [Type_js_1.Type.Object, Type_js_1.Type.String, Type_js_1.Type.Integer, Type_js_1.Type.Array]]]),
|
|
72
|
+
]]]));
|
|
73
|
+
const funcJoin = new Constant_js_1.Constant((...values) => values.flat(), Type_js_1.Type.functionType([[Type_js_1.Type.Array, [Type_js_1.Type.arrayType(Type_js_1.Type.Array)], true]]));
|
|
74
|
+
exports.funcRange = new Constant_js_1.Constant((value1, value2) => {
|
|
75
|
+
const [min, max] = value1 < value2 ? [value1, value2] : [value2, value1];
|
|
76
|
+
return [...Array(Number(max - min) + 1).keys()].map((i) => BigInt(i) + min);
|
|
77
|
+
}, Type_js_1.Type.functionType([[Type_js_1.Type.arrayType(Type_js_1.Type.Integer), [Type_js_1.Type.Integer, Type_js_1.Type.Integer]]]));
|
|
79
78
|
const funcUnique = new Constant_js_1.Constant((value) => {
|
|
80
79
|
const result = [];
|
|
81
80
|
value?.forEach((i) => {
|
|
82
|
-
if (result.every((v) => !(0, Unknown_js_1.
|
|
81
|
+
if (result.every((v) => !(0, Unknown_js_1.equals)(v, i))) {
|
|
83
82
|
result.push(i);
|
|
84
83
|
}
|
|
85
84
|
});
|
|
86
85
|
return result;
|
|
87
|
-
}, Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_1.Type.Array]));
|
|
88
|
-
const funcIntersection = new Constant_js_1.Constant((value1, value2) => value1?.filter((i) => value2?.some((v) => (0, Unknown_js_1.
|
|
89
|
-
const funcDifference = new Constant_js_1.Constant((value1, value2) => [...value1?.filter((i) => value2?.every((v) => !(0, Unknown_js_1.
|
|
90
|
-
exports.
|
|
86
|
+
}, Type_js_1.Type.functionType([[Type_js_1.Type.Array, [Type_js_1.Type.Array]]]));
|
|
87
|
+
const funcIntersection = new Constant_js_1.Constant((value1, value2) => value1?.filter((i) => value2?.some((v) => (0, Unknown_js_1.equals)(v, i))) ?? [], typeArrayOperator);
|
|
88
|
+
const funcDifference = new Constant_js_1.Constant((value1, value2) => [...value1?.filter((i) => value2?.every((v) => !(0, Unknown_js_1.equals)(v, i))) ?? [], ...value2?.filter((i) => value1?.every((v) => !(0, Unknown_js_1.equals)(v, i))) ?? []], typeArrayOperator);
|
|
89
|
+
exports.globArray = Object.assign(Object.create(null), {
|
|
91
90
|
Join: funcJoin,
|
|
92
|
-
Range: funcRange,
|
|
91
|
+
Range: exports.funcRange,
|
|
93
92
|
Unique: funcUnique,
|
|
94
93
|
Intersection: funcIntersection,
|
|
95
94
|
Difference: funcDifference,
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.globBoolean = exports.funcBoolean = exports.funcNot = exports.funcAnd = exports.funcOr = void 0;
|
|
4
4
|
const Constant_js_1 = require("../Constant.js");
|
|
5
5
|
const Type_js_1 = require("../Type.js");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.funcNot = new Constant_js_1.Constant((value) => !value, Type_js_1.Type.functionType(Type_js_1.Type.Boolean, [Type_js_1.Type.Boolean]));
|
|
6
|
+
const typeBooleanLogic = Type_js_1.Type.functionType([[Type_js_1.Type.Boolean, [Type_js_1.Type.arrayType(Type_js_1.Type.Boolean)], true]]);
|
|
7
|
+
exports.funcOr = new Constant_js_1.Constant((...values) => values.some((v) => v), typeBooleanLogic);
|
|
8
|
+
exports.funcAnd = new Constant_js_1.Constant((...values) => values.every((v) => v), typeBooleanLogic);
|
|
9
|
+
exports.funcNot = new Constant_js_1.Constant((value) => !value, Type_js_1.Type.functionType([[Type_js_1.Type.Boolean, [Type_js_1.Type.Boolean]]]));
|
|
11
10
|
const funcDecodeBoolean = new Constant_js_1.Constant((value, byteOffset) => {
|
|
12
11
|
const offset = byteOffset == null ? 0 : Number(byteOffset);
|
|
13
12
|
return !value || offset < 0 || value.byteLength < offset + 1
|
|
14
13
|
? undefined
|
|
15
14
|
: Boolean(new Uint8Array(value)[offset]);
|
|
16
|
-
}, Type_js_1.Type.functionType(Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.OptionalBuffer, Type_js_1.Type.OptionalInteger]));
|
|
15
|
+
}, Type_js_1.Type.functionType([[Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.OptionalBuffer, Type_js_1.Type.OptionalInteger]]]));
|
|
17
16
|
const funcParseBoolean = new Constant_js_1.Constant((value) => {
|
|
18
17
|
if (value == null) {
|
|
19
18
|
return undefined;
|
|
20
19
|
}
|
|
21
20
|
const v = value.toLowerCase();
|
|
22
21
|
return v === "true" ? true : v === "false" ? false : undefined;
|
|
23
|
-
}, Type_js_1.Type.functionType(Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.OptionalString]));
|
|
24
|
-
exports.funcBoolean = new Constant_js_1.Constant((value) => typeof value === "bigint" ? value !== 0n : Boolean(Number(value)), Type_js_1.Type.
|
|
25
|
-
|
|
22
|
+
}, Type_js_1.Type.functionType([[Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.OptionalString]]]));
|
|
23
|
+
exports.funcBoolean = new Constant_js_1.Constant((value) => typeof value === "bigint" ? value !== 0n : Boolean(Number(value)), Type_js_1.Type.functionType([
|
|
24
|
+
[Type_js_1.Type.Boolean, [Type_js_1.Type.Timestamp]],
|
|
25
|
+
[Type_js_1.Type.Boolean, [Type_js_1.Type.Float]],
|
|
26
|
+
[Type_js_1.Type.Boolean, [Type_js_1.Type.Integer]],
|
|
27
|
+
]));
|
|
28
|
+
exports.globBoolean = Object.assign(Object.create(null), {
|
|
26
29
|
Or: exports.funcOr,
|
|
27
30
|
And: exports.funcAnd,
|
|
28
31
|
Not: exports.funcNot,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Constant } from "../Constant.js";
|
|
2
2
|
export type BufferFormatting = "hex" | "base64";
|
|
3
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
4
|
export declare const parseBoundedInteger: (input: string, base: 10 | 16, min: number, max: number) => number;
|
|
7
|
-
export declare const
|
|
5
|
+
export declare const equalsBuffers: (value1: ArrayBuffer, value2: ArrayBuffer) => boolean;
|
|
8
6
|
export declare const containsBuffer: (value: ArrayBuffer, search: ArrayBuffer, startPos?: number) => boolean;
|
|
9
7
|
export declare const concatBuffers: (value1: ArrayBuffer, value2: ArrayBuffer) => ArrayBuffer;
|
|
10
8
|
export declare const formatBuffer: (value: ArrayBuffer, formatting?: BufferFormatting) => string;
|
|
11
9
|
export declare const parseBuffer: (value?: string) => ArrayBuffer | undefined;
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
10
|
+
export declare const formatLiteralBuffer: (value: ArrayBuffer) => string;
|
|
11
|
+
export declare const parseLiteralBuffer: (value: string, offset?: number) => readonly [ArrayBuffer, number];
|
|
12
|
+
export declare const funcByteAt: Constant;
|
|
13
|
+
export declare const globBuffer: any;
|
package/dst/cjs/native/Buffer.js
CHANGED
|
@@ -1,41 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.globBuffer = exports.funcByteAt = exports.parseLiteralBuffer = exports.formatLiteralBuffer = exports.parseBuffer = exports.formatBuffer = exports.concatBuffers = exports.containsBuffer = exports.equalsBuffers = exports.parseBoundedInteger = exports.EmptyBuffer = void 0;
|
|
4
4
|
const Constant_js_1 = require("../Constant.js");
|
|
5
5
|
const Type_js_1 = require("../Type.js");
|
|
6
|
+
const String_js_1 = require("./String.js");
|
|
6
7
|
exports.EmptyBuffer = new ArrayBuffer(0);
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
exports.formatLiteralBuffer = formatLiteralBuffer;
|
|
12
|
-
const parseLiteralBuffer = (value, offset = 0) => {
|
|
13
|
-
const q = value.charCodeAt(offset);
|
|
14
|
-
for (let i = offset + 1, bytes = [], digits = [0, 0], ix = 0; i < value.length; ++i) {
|
|
15
|
-
const code = value.charCodeAt(i);
|
|
16
|
-
if (code === q) {
|
|
17
|
-
if (ix === 1) {
|
|
18
|
-
bytes.push(digits[0]);
|
|
19
|
-
}
|
|
20
|
-
return [new Uint8Array(bytes).buffer, i + 1];
|
|
21
|
-
}
|
|
22
|
-
if (code >= ZERO && code <= NINE) {
|
|
23
|
-
digits[ix++] = code - ZERO;
|
|
24
|
-
}
|
|
25
|
-
else if (code >= UPPER_A && code <= UPPER_F) {
|
|
26
|
-
digits[ix++] = code - UPPER_A + 10;
|
|
27
|
-
}
|
|
28
|
-
else if (code >= LOWER_A && code <= LOWER_F) {
|
|
29
|
-
digits[ix++] = code - LOWER_A + 10;
|
|
30
|
-
}
|
|
31
|
-
if (ix > 1) {
|
|
32
|
-
bytes.push(digits[0] << 4 | digits[1]);
|
|
33
|
-
ix = 0;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
throw new Error(`missing closing buffer quotation mark ${String.fromCharCode(q)}`);
|
|
37
|
-
};
|
|
38
|
-
exports.parseLiteralBuffer = parseLiteralBuffer;
|
|
8
|
+
const codeZero = "0".charCodeAt(0), codeNine = "9".charCodeAt(0);
|
|
9
|
+
const codeUpperA = "A".charCodeAt(0), codeUpperF = "F".charCodeAt(0);
|
|
10
|
+
const coderLowerA = "a".charCodeAt(0), codeLowerF = "f".charCodeAt(0);
|
|
11
|
+
const codeComment = "/".charCodeAt(0), codeNewLine = "\n".charCodeAt(0);
|
|
39
12
|
const parseBoundedInteger = (input, base, min, max) => {
|
|
40
13
|
if (input.length === 0) {
|
|
41
14
|
throw new Error(`Invalid IP component: ${input}`);
|
|
@@ -44,14 +17,14 @@ const parseBoundedInteger = (input, base, min, max) => {
|
|
|
44
17
|
for (let i = 0; i < input.length; i++) {
|
|
45
18
|
const code = input.charCodeAt(i);
|
|
46
19
|
let digit;
|
|
47
|
-
if (code >=
|
|
48
|
-
digit = code -
|
|
20
|
+
if (code >= codeZero && code <= codeNine) {
|
|
21
|
+
digit = code - codeZero;
|
|
49
22
|
}
|
|
50
|
-
else if (base === 16 && code >=
|
|
51
|
-
digit = code -
|
|
23
|
+
else if (base === 16 && code >= codeUpperA && code <= codeUpperF) {
|
|
24
|
+
digit = code - codeUpperA + 10;
|
|
52
25
|
}
|
|
53
|
-
else if (base === 16 && code >=
|
|
54
|
-
digit = code -
|
|
26
|
+
else if (base === 16 && code >= coderLowerA && code <= codeLowerF) {
|
|
27
|
+
digit = code - coderLowerA + 10;
|
|
55
28
|
}
|
|
56
29
|
else {
|
|
57
30
|
throw new Error(`Invalid character: ${input.charAt(i)}`);
|
|
@@ -64,7 +37,7 @@ const parseBoundedInteger = (input, base, min, max) => {
|
|
|
64
37
|
return value;
|
|
65
38
|
};
|
|
66
39
|
exports.parseBoundedInteger = parseBoundedInteger;
|
|
67
|
-
const
|
|
40
|
+
const equalsBuffers = (value1, value2) => {
|
|
68
41
|
if (value1.byteLength !== value2.byteLength) {
|
|
69
42
|
return false;
|
|
70
43
|
}
|
|
@@ -88,7 +61,7 @@ const equateBuffers = (value1, value2) => {
|
|
|
88
61
|
}
|
|
89
62
|
return true;
|
|
90
63
|
};
|
|
91
|
-
exports.
|
|
64
|
+
exports.equalsBuffers = equalsBuffers;
|
|
92
65
|
const containsBuffer = (value, search, startPos) => {
|
|
93
66
|
if (value.byteLength < search.byteLength) {
|
|
94
67
|
return false;
|
|
@@ -166,12 +139,63 @@ const parseBuffer = (value) => {
|
|
|
166
139
|
return bytes.buffer;
|
|
167
140
|
};
|
|
168
141
|
exports.parseBuffer = parseBuffer;
|
|
169
|
-
|
|
142
|
+
const formatLiteralBuffer = (value) => `\`${(0, exports.formatBuffer)(value)}\``;
|
|
143
|
+
exports.formatLiteralBuffer = formatLiteralBuffer;
|
|
144
|
+
const parseLiteralBuffer = (value, offset = 0) => {
|
|
145
|
+
const q = value.charCodeAt(offset);
|
|
146
|
+
for (let i = offset + 1, bytes = [], digits = [0, 0], ix = 0; i < value.length; ++i) {
|
|
147
|
+
const code = value.charCodeAt(i);
|
|
148
|
+
if (code === q) {
|
|
149
|
+
if (ix === 1) {
|
|
150
|
+
bytes.push(digits[0]);
|
|
151
|
+
}
|
|
152
|
+
return [new Uint8Array(bytes).buffer, i + 1];
|
|
153
|
+
}
|
|
154
|
+
if (code >= codeZero && code <= codeNine) {
|
|
155
|
+
digits[ix++] = code - codeZero;
|
|
156
|
+
}
|
|
157
|
+
else if (code >= codeUpperA && code <= codeUpperF) {
|
|
158
|
+
digits[ix++] = code - codeUpperA + 10;
|
|
159
|
+
}
|
|
160
|
+
else if (code >= coderLowerA && code <= codeLowerF) {
|
|
161
|
+
digits[ix++] = code - coderLowerA + 10;
|
|
162
|
+
}
|
|
163
|
+
else if (code === codeComment) {
|
|
164
|
+
if (i === value.indexOf("///", i)) {
|
|
165
|
+
i = value.indexOf("///", i + 3);
|
|
166
|
+
if (i < 0) {
|
|
167
|
+
throw new Error("missing closing comment mark");
|
|
168
|
+
}
|
|
169
|
+
i += 2;
|
|
170
|
+
}
|
|
171
|
+
else if (i === value.indexOf("//", i)) {
|
|
172
|
+
let c = value.charCodeAt(i += 2);
|
|
173
|
+
while (c !== codeNewLine && c !== q && !Number.isNaN(c)) {
|
|
174
|
+
c = value.charCodeAt(++i);
|
|
175
|
+
}
|
|
176
|
+
--i;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
throw new Error("unexpected symbol '/'");
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else if (!(0, String_js_1.isWhiteSpaceSymbol)(value.charAt(i))) {
|
|
183
|
+
throw new Error(`unexpected symbol '${value.charAt(i)}'`);
|
|
184
|
+
}
|
|
185
|
+
if (ix > 1) {
|
|
186
|
+
bytes.push(digits[0] << 4 | digits[1]);
|
|
187
|
+
ix = 0;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
throw new Error(`missing closing buffer quotation mark ${String.fromCharCode(q)}`);
|
|
191
|
+
};
|
|
192
|
+
exports.parseLiteralBuffer = parseLiteralBuffer;
|
|
193
|
+
exports.funcByteAt = new Constant_js_1.Constant((value, pos) => value == null
|
|
170
194
|
? undefined
|
|
171
|
-
: value.slice(Number(pos), Number(pos) + 1), Type_js_1.Type.functionType(Type_js_1.Type.OptionalBuffer, [Type_js_1.Type.Buffer, Type_js_1.Type.Integer]));
|
|
172
|
-
const funcRandomBuffer = new Constant_js_1.Constant((value) => value == null || value <= 0n ? new Uint8Array(0).buffer : crypto.getRandomValues(new Uint8Array(Number(value))).buffer, Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Integer]
|
|
173
|
-
const funcParseBuffer = new Constant_js_1.Constant((value) => (0, exports.parseBuffer)(value), Type_js_1.Type.functionType(Type_js_1.Type.OptionalBuffer, [Type_js_1.Type.OptionalString]));
|
|
174
|
-
exports.
|
|
195
|
+
: value.slice(Number(pos), Number(pos) + 1), Type_js_1.Type.functionType([[Type_js_1.Type.OptionalBuffer, [Type_js_1.Type.Buffer, Type_js_1.Type.Integer]]]));
|
|
196
|
+
const funcRandomBuffer = new Constant_js_1.Constant((value) => value == null || value <= 0n ? new Uint8Array(0).buffer : crypto.getRandomValues(new Uint8Array(Number(value))).buffer, Type_js_1.Type.functionType([[Type_js_1.Type.Buffer, [Type_js_1.Type.Integer]]], true));
|
|
197
|
+
const funcParseBuffer = new Constant_js_1.Constant((value) => (0, exports.parseBuffer)(value), Type_js_1.Type.functionType([[Type_js_1.Type.OptionalBuffer, [Type_js_1.Type.OptionalString]]]));
|
|
198
|
+
exports.globBuffer = Object.assign(Object.create(null), {
|
|
175
199
|
Random: funcRandomBuffer,
|
|
176
200
|
Parse: funcParseBuffer,
|
|
177
201
|
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.funcOptionalHas = exports.funcHas = exports.funcOptionalAt = exports.funcAt = void 0;
|
|
4
|
+
const Constant_js_1 = require("../Constant.js");
|
|
5
|
+
const Type_js_1 = require("../Type.js");
|
|
6
|
+
const arrayAt = (value, index) => {
|
|
7
|
+
const ix = index < 0 ? value.length + index : index;
|
|
8
|
+
return ix >= 0 && ix < value.length ? value[ix] : undefined;
|
|
9
|
+
};
|
|
10
|
+
const objectAt = (value, key) => {
|
|
11
|
+
return Object.hasOwn(value, key) ? value[key] : undefined;
|
|
12
|
+
};
|
|
13
|
+
const arrayHas = (value, index) => {
|
|
14
|
+
const ix = index < 0 ? value.length + index : index;
|
|
15
|
+
return ix >= 0 && ix < value.length;
|
|
16
|
+
};
|
|
17
|
+
const objectHas = (value, key) => {
|
|
18
|
+
return Object.hasOwn(value, key);
|
|
19
|
+
};
|
|
20
|
+
exports.funcAt = new Constant_js_1.Constant((value, index) => Array.isArray(value) ? arrayAt(value, Number(index)) : objectAt(value, String(index)), Type_js_1.Type.functionType([
|
|
21
|
+
[Type_js_1.Type.Any, [Type_js_1.Type.Array, Type_js_1.Type.Integer]],
|
|
22
|
+
[Type_js_1.Type.Any, [Type_js_1.Type.Object, Type_js_1.Type.String]],
|
|
23
|
+
]));
|
|
24
|
+
exports.funcOptionalAt = new Constant_js_1.Constant((value, index) => value == null ? undefined : Array.isArray(value) ? arrayAt(value, Number(index)) : objectAt(value, String(index)), Type_js_1.Type.functionType([
|
|
25
|
+
[Type_js_1.Type.Any, [Type_js_1.Type.OptionalArray, Type_js_1.Type.Integer]],
|
|
26
|
+
[Type_js_1.Type.Any, [Type_js_1.Type.OptionalObject, Type_js_1.Type.String]],
|
|
27
|
+
]));
|
|
28
|
+
exports.funcHas = new Constant_js_1.Constant((value, index) => Array.isArray(value) ? arrayHas(value, Number(index)) : objectHas(value, String(index)), Type_js_1.Type.functionType([
|
|
29
|
+
[Type_js_1.Type.Boolean, [Type_js_1.Type.Array, Type_js_1.Type.Integer]],
|
|
30
|
+
[Type_js_1.Type.Boolean, [Type_js_1.Type.Object, Type_js_1.Type.String]],
|
|
31
|
+
]));
|
|
32
|
+
exports.funcOptionalHas = new Constant_js_1.Constant((value, index) => value == null ? undefined : Array.isArray(value) ? arrayHas(value, Number(index)) : objectHas(value, String(index)), Type_js_1.Type.functionType([
|
|
33
|
+
[Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.OptionalArray, Type_js_1.Type.Integer]],
|
|
34
|
+
[Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.OptionalObject, Type_js_1.Type.String]],
|
|
35
|
+
]));
|
|
@@ -4,15 +4,27 @@ exports.funcInject = exports.funcSplice = exports.funcSlice = void 0;
|
|
|
4
4
|
const Constant_js_1 = require("../Constant.js");
|
|
5
5
|
const Type_js_1 = require("../Type.js");
|
|
6
6
|
const Aggregable_js_1 = require("./Aggregable.js");
|
|
7
|
-
const typeBufferArray = Type_js_1.Type.arrayType(
|
|
8
|
-
const typeStringArray = Type_js_1.Type.arrayType(
|
|
9
|
-
const typeArrayArray = Type_js_1.Type.arrayType(
|
|
7
|
+
const typeBufferArray = Type_js_1.Type.arrayType(Type_js_1.Type.Buffer);
|
|
8
|
+
const typeStringArray = Type_js_1.Type.arrayType(Type_js_1.Type.String);
|
|
9
|
+
const typeArrayArray = Type_js_1.Type.arrayType(Type_js_1.Type.Array);
|
|
10
10
|
exports.funcSlice = new Constant_js_1.Constant((value, start = 0n, end) => value == null
|
|
11
11
|
? undefined
|
|
12
|
-
: value.slice(Number(start), end == null ? undefined : Number(end)), Type_js_1.Type.
|
|
13
|
-
|
|
12
|
+
: value.slice(Number(start), end == null ? undefined : Number(end)), Type_js_1.Type.functionType([
|
|
13
|
+
[Type_js_1.Type.Buffer, [Type_js_1.Type.Buffer, Type_js_1.Type.OptionalInteger, Type_js_1.Type.OptionalInteger]],
|
|
14
|
+
[Type_js_1.Type.String, [Type_js_1.Type.String, Type_js_1.Type.OptionalInteger, Type_js_1.Type.OptionalInteger]],
|
|
15
|
+
[Type_js_1.Type.Array, [Type_js_1.Type.Array, Type_js_1.Type.OptionalInteger, Type_js_1.Type.OptionalInteger]],
|
|
16
|
+
]));
|
|
17
|
+
exports.funcSplice = new Constant_js_1.Constant((value, start, remove, ...inject) => value == null
|
|
14
18
|
? undefined
|
|
15
|
-
: (0, Aggregable_js_1.aggregate)(inject.reduce((acc, val) => (0, Aggregable_js_1.aggregate)(acc, val), value.slice(0, Number(start))), value.slice(Number(start + remove))), Type_js_1.Type.
|
|
16
|
-
|
|
19
|
+
: (0, Aggregable_js_1.aggregate)(inject.reduce((acc, val) => (0, Aggregable_js_1.aggregate)(acc, val), value.slice(0, Number(start))), value.slice(Number(start + remove))), Type_js_1.Type.functionType([
|
|
20
|
+
[Type_js_1.Type.Buffer, [Type_js_1.Type.Buffer, Type_js_1.Type.Integer, Type_js_1.Type.Integer, typeBufferArray], true],
|
|
21
|
+
[Type_js_1.Type.String, [Type_js_1.Type.String, Type_js_1.Type.Integer, Type_js_1.Type.Integer, typeStringArray], true],
|
|
22
|
+
[Type_js_1.Type.Array, [Type_js_1.Type.Array, Type_js_1.Type.Integer, Type_js_1.Type.Integer, typeArrayArray], true],
|
|
23
|
+
]));
|
|
24
|
+
exports.funcInject = new Constant_js_1.Constant((value, start, ...inject) => value == null
|
|
17
25
|
? undefined
|
|
18
|
-
: (0, Aggregable_js_1.aggregate)(inject.reduce((acc, val) => (0, Aggregable_js_1.aggregate)(acc, val), value.slice(0, Number(start))), value.slice(Number(start))), Type_js_1.Type.
|
|
26
|
+
: (0, Aggregable_js_1.aggregate)(inject.reduce((acc, val) => (0, Aggregable_js_1.aggregate)(acc, val), value.slice(0, Number(start))), value.slice(Number(start))), Type_js_1.Type.functionType([
|
|
27
|
+
[Type_js_1.Type.Buffer, [Type_js_1.Type.Buffer, Type_js_1.Type.Integer, typeBufferArray], true],
|
|
28
|
+
[Type_js_1.Type.String, [Type_js_1.Type.String, Type_js_1.Type.Integer, typeStringArray], true],
|
|
29
|
+
[Type_js_1.Type.Array, [Type_js_1.Type.Array, Type_js_1.Type.Integer, typeArrayArray], true],
|
|
30
|
+
]));
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Constant } from "../Constant.js";
|
|
2
2
|
export type FloatEncoding = "f32" | "f32le" | "f64" | "f64le";
|
|
3
3
|
export declare const encodeFloat: (value: number, encoding?: FloatEncoding) => ArrayBuffer;
|
|
4
|
+
export declare const formatFloat: (value: number, formatting?: string) => string;
|
|
5
|
+
export declare const formatLiteralFloat: (value: number) => string;
|
|
4
6
|
export declare const funcFloat: Constant;
|
|
5
|
-
export declare const
|
|
7
|
+
export declare const globFloat: any;
|