affinirum 1.4.1 → 1.4.2
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/dst/Affinirum.js +3 -3
- package/dst/StaticScope.js +1 -1
- package/dst/Type.js +1 -1
- package/dst/atom/ObjectAtom.js +1 -1
- package/dst/cjs/Affinirum.js +3 -3
- package/dst/cjs/StaticScope.js +1 -1
- package/dst/cjs/Type.js +1 -1
- package/dst/cjs/atom/ObjectAtom.js +1 -1
- package/dst/cjs/native/Array.js +3 -3
- package/dst/cjs/native/Boolean.js +2 -2
- package/dst/cjs/native/Buffer.js +2 -2
- package/dst/cjs/native/Float.js +2 -2
- package/dst/cjs/native/Integer.js +2 -2
- package/dst/cjs/native/Iterable.js +2 -1
- package/dst/cjs/native/Object.js +3 -3
- package/dst/cjs/native/String.js +2 -2
- package/dst/cjs/native/Timestamp.js +2 -2
- package/dst/cjs/native/notation/AN.js +2 -2
- package/dst/cjs/native/notation/IP.js +2 -2
- package/dst/cjs/native/notation/JSON.js +2 -2
- package/dst/cjs/node/ObjectNode.js +1 -1
- package/dst/native/Array.d.ts +1 -7
- package/dst/native/Array.js +3 -3
- package/dst/native/Boolean.d.ts +1 -7
- package/dst/native/Boolean.js +2 -2
- package/dst/native/Buffer.d.ts +1 -4
- package/dst/native/Buffer.js +2 -2
- package/dst/native/Float.d.ts +1 -20
- package/dst/native/Float.js +2 -2
- package/dst/native/Integer.d.ts +1 -9
- package/dst/native/Integer.js +2 -2
- package/dst/native/Iterable.js +2 -1
- package/dst/native/Object.d.ts +1 -3
- package/dst/native/Object.js +3 -3
- package/dst/native/String.d.ts +1 -5
- package/dst/native/String.js +2 -2
- package/dst/native/Timestamp.d.ts +1 -6
- package/dst/native/Timestamp.js +2 -2
- package/dst/native/notation/AN.d.ts +1 -4
- package/dst/native/notation/AN.js +2 -2
- package/dst/native/notation/IP.d.ts +1 -6
- package/dst/native/notation/IP.js +2 -2
- package/dst/native/notation/JSON.d.ts +1 -5
- package/dst/native/notation/JSON.js +2 -2
- package/dst/node/ObjectNode.js +1 -1
- package/package.json +1 -1
package/dst/Affinirum.js
CHANGED
|
@@ -43,8 +43,8 @@ export class Affinirum {
|
|
|
43
43
|
this._script = script;
|
|
44
44
|
this._strict = config?.strict ?? false;
|
|
45
45
|
if (config?.variables) {
|
|
46
|
-
for (const
|
|
47
|
-
this._variables.set(
|
|
46
|
+
for (const [vname, vtype] of Object.entries(config.variables)) {
|
|
47
|
+
this._variables.set(vname, new Variable(vtype));
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
const state = new ParserState(this._script);
|
|
@@ -78,7 +78,7 @@ export class Affinirum {
|
|
|
78
78
|
@returns Record with variable names and types.
|
|
79
79
|
*/
|
|
80
80
|
variables() {
|
|
81
|
-
const types =
|
|
81
|
+
const types = Object.create(null);
|
|
82
82
|
const variables = this._scope.variables();
|
|
83
83
|
for (const name in variables) {
|
|
84
84
|
types[name] = variables[name].type;
|
package/dst/StaticScope.js
CHANGED
package/dst/Type.js
CHANGED
|
@@ -141,7 +141,7 @@ export class Type {
|
|
|
141
141
|
static arrayType(itemTypes = []) {
|
|
142
142
|
return new Type([new ArrayAtom(itemTypes)]);
|
|
143
143
|
}
|
|
144
|
-
static objectType(propTypes =
|
|
144
|
+
static objectType(propTypes = Object.create(null)) {
|
|
145
145
|
return new Type([new ObjectAtom(propTypes)]);
|
|
146
146
|
}
|
|
147
147
|
static functionType(retType = Type.Unknown, argTypes = [], isVariadic = false) {
|
package/dst/atom/ObjectAtom.js
CHANGED
package/dst/cjs/Affinirum.js
CHANGED
|
@@ -46,8 +46,8 @@ class Affinirum {
|
|
|
46
46
|
this._script = script;
|
|
47
47
|
this._strict = config?.strict ?? false;
|
|
48
48
|
if (config?.variables) {
|
|
49
|
-
for (const
|
|
50
|
-
this._variables.set(
|
|
49
|
+
for (const [vname, vtype] of Object.entries(config.variables)) {
|
|
50
|
+
this._variables.set(vname, new Variable_js_1.Variable(vtype));
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
const state = new ParserState_js_1.ParserState(this._script);
|
|
@@ -81,7 +81,7 @@ class Affinirum {
|
|
|
81
81
|
@returns Record with variable names and types.
|
|
82
82
|
*/
|
|
83
83
|
variables() {
|
|
84
|
-
const types =
|
|
84
|
+
const types = Object.create(null);
|
|
85
85
|
const variables = this._scope.variables();
|
|
86
86
|
for (const name in variables) {
|
|
87
87
|
types[name] = variables[name].type;
|
package/dst/cjs/StaticScope.js
CHANGED
package/dst/cjs/Type.js
CHANGED
|
@@ -144,7 +144,7 @@ class Type {
|
|
|
144
144
|
static arrayType(itemTypes = []) {
|
|
145
145
|
return new Type([new ArrayAtom_js_1.ArrayAtom(itemTypes)]);
|
|
146
146
|
}
|
|
147
|
-
static objectType(propTypes =
|
|
147
|
+
static objectType(propTypes = Object.create(null)) {
|
|
148
148
|
return new Type([new ObjectAtom_js_1.ObjectAtom(propTypes)]);
|
|
149
149
|
}
|
|
150
150
|
static functionType(retType = Type.Unknown, argTypes = [], isVariadic = false) {
|
package/dst/cjs/native/Array.js
CHANGED
|
@@ -53,7 +53,7 @@ exports.funcCompose = new Constant_js_1.Constant((value, callback) => {
|
|
|
53
53
|
if (value == null) {
|
|
54
54
|
return undefined;
|
|
55
55
|
}
|
|
56
|
-
const obj =
|
|
56
|
+
const obj = Object.create(null);
|
|
57
57
|
for (let i = 0; i < value.length; ++i) {
|
|
58
58
|
const key = value[i];
|
|
59
59
|
obj[key] = callback(obj, key, BigInt(i), value);
|
|
@@ -85,10 +85,10 @@ const funcUnique = new Constant_js_1.Constant((value) => {
|
|
|
85
85
|
}, Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_1.Type.Array]));
|
|
86
86
|
const funcIntersection = new Constant_js_1.Constant((value1, value2) => value1?.filter((i) => value2?.some((v) => (0, Unknown_js_1.equate)(v, i))) ?? [], typeArrayOperator);
|
|
87
87
|
const funcDifference = new Constant_js_1.Constant((value1, value2) => [...value1?.filter((i) => value2?.every((v) => !(0, Unknown_js_1.equate)(v, i))) ?? [], ...value2?.filter((i) => value1?.every((v) => !(0, Unknown_js_1.equate)(v, i))) ?? []], typeArrayOperator);
|
|
88
|
-
exports.constArray = {
|
|
88
|
+
exports.constArray = Object.assign(Object.create(null), {
|
|
89
89
|
Join: funcJoin,
|
|
90
90
|
Range: funcRange,
|
|
91
91
|
Unique: funcUnique,
|
|
92
92
|
Intersection: funcIntersection,
|
|
93
93
|
Difference: funcDifference,
|
|
94
|
-
};
|
|
94
|
+
});
|
|
@@ -19,10 +19,10 @@ const funcParseBoolean = new Constant_js_1.Constant((value) => {
|
|
|
19
19
|
const v = value.toLowerCase();
|
|
20
20
|
return v === "true" ? true : v === "false" ? false : undefined;
|
|
21
21
|
}, Type_js_1.Type.functionType(Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.OptionalString]));
|
|
22
|
-
exports.constBoolean = {
|
|
22
|
+
exports.constBoolean = Object.assign(Object.create(null), {
|
|
23
23
|
Or: exports.funcOr,
|
|
24
24
|
And: exports.funcAnd,
|
|
25
25
|
Not: exports.funcNot,
|
|
26
26
|
Decode: funcDecodeBoolean,
|
|
27
27
|
Parse: funcParseBoolean,
|
|
28
|
-
};
|
|
28
|
+
});
|
package/dst/cjs/native/Buffer.js
CHANGED
|
@@ -142,7 +142,7 @@ exports.funcByte = new Constant_js_1.Constant((value, pos) => value == null
|
|
|
142
142
|
: 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]));
|
|
143
143
|
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]), false);
|
|
144
144
|
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]));
|
|
145
|
-
exports.constBuffer = {
|
|
145
|
+
exports.constBuffer = Object.assign(Object.create(null), {
|
|
146
146
|
Random: funcRandomBuffer,
|
|
147
147
|
Parse: funcParseBuffer,
|
|
148
|
-
};
|
|
148
|
+
});
|
package/dst/cjs/native/Float.js
CHANGED
|
@@ -59,7 +59,7 @@ const funcTruncate = new Constant_js_1.Constant((value) => Math.trunc(Number(val
|
|
|
59
59
|
const funcRandomFloat = new Constant_js_1.Constant((value) => value == null ? undefined : Math.random() * Number(value), Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Float]), false);
|
|
60
60
|
const funcDecodeFloat = new Constant_js_1.Constant((value, encoding = "f64", byteOffset) => decodeFloat(value, encoding, byteOffset == null ? undefined : Number(byteOffset)), Type_js_1.Type.functionType(Type_js_1.Type.OptionalFloat, [Type_js_1.Type.OptionalBuffer, Type_js_1.Type.OptionalString, Type_js_1.Type.OptionalInteger]));
|
|
61
61
|
const funcParseFloat = new Constant_js_1.Constant((value) => value ? Number.parseFloat(value) : undefined, Type_js_1.Type.functionType(Type_js_1.Type.OptionalFloat, [Type_js_1.Type.OptionalString]));
|
|
62
|
-
exports.constFloat = {
|
|
62
|
+
exports.constFloat = Object.assign(Object.create(null), {
|
|
63
63
|
NAN: new Constant_js_1.Constant(Number.NaN),
|
|
64
64
|
PositiveInfinity: new Constant_js_1.Constant(Number.POSITIVE_INFINITY),
|
|
65
65
|
NegativeInfinity: new Constant_js_1.Constant(Number.NEGATIVE_INFINITY),
|
|
@@ -77,4 +77,4 @@ exports.constFloat = {
|
|
|
77
77
|
Random: funcRandomFloat,
|
|
78
78
|
Decode: funcDecodeFloat,
|
|
79
79
|
Parse: funcParseFloat,
|
|
80
|
-
};
|
|
80
|
+
});
|
|
@@ -97,11 +97,11 @@ const funcParseInteger = new Constant_js_1.Constant((value) => {
|
|
|
97
97
|
catch { }
|
|
98
98
|
return undefined;
|
|
99
99
|
}, Type_js_1.Type.functionType(Type_js_1.Type.OptionalInteger, [Type_js_1.Type.OptionalString]));
|
|
100
|
-
exports.constInteger = {
|
|
100
|
+
exports.constInteger = Object.assign(Object.create(null), {
|
|
101
101
|
Sum: funcSum,
|
|
102
102
|
Min: funcMin,
|
|
103
103
|
Max: funcMax,
|
|
104
104
|
Random: funcRandomInteger,
|
|
105
105
|
Decode: funcDecodeInteger,
|
|
106
106
|
Parse: funcParseInteger,
|
|
107
|
-
};
|
|
107
|
+
});
|
|
@@ -29,7 +29,8 @@ exports.funcAt = new Constant_js_1.Constant((value, index) => {
|
|
|
29
29
|
const ix = Number(index);
|
|
30
30
|
return value[ix < 0 ? value.length + ix : ix];
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
const key = String(index);
|
|
33
|
+
return Object.hasOwn(value, key) ? value[key] : undefined;
|
|
33
34
|
}, Type_js_1.Type.union(Type_js_1.Type.functionType(Type_js_1.Type.Unknown, [Type_js_1.Type.Array, Type_js_1.Type.Integer]), Type_js_1.Type.functionType(Type_js_1.Type.Unknown, [Type_js_1.Type.Object, Type_js_1.Type.String])));
|
|
34
35
|
exports.funcHas = new Constant_js_1.Constant((value, index) => {
|
|
35
36
|
if (value == null) {
|
package/dst/cjs/native/Object.js
CHANGED
|
@@ -7,7 +7,7 @@ const typeAccessor = Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_
|
|
|
7
7
|
exports.funcEntries = new Constant_js_1.Constant((value) => value ? Object.entries(value) : undefined, typeAccessor);
|
|
8
8
|
exports.funcKeys = new Constant_js_1.Constant((value) => value ? Object.keys(value) : undefined, Type_js_1.Type.functionType(Type_js_1.Type.arrayType([Type_js_1.Type.String]), [Type_js_1.Type.Object]));
|
|
9
9
|
exports.funcValues = new Constant_js_1.Constant((value) => value ? Object.values(value) : undefined, typeAccessor);
|
|
10
|
-
const funcMerge = new Constant_js_1.Constant((...values) => values.flat().reduce((acc, val) => Object.assign(acc, val),
|
|
11
|
-
exports.constObject = {
|
|
10
|
+
const funcMerge = new Constant_js_1.Constant((...values) => values.flat().reduce((acc, val) => Object.assign(acc, val), Object.create(null)), Type_js_1.Type.functionType(Type_js_1.Type.Object, [Type_js_1.Type.union(Type_js_1.Type.arrayType([Type_js_1.Type.Object]), Type_js_1.Type.Object)], true));
|
|
11
|
+
exports.constObject = Object.assign(Object.create(null), {
|
|
12
12
|
Merge: funcMerge,
|
|
13
|
-
};
|
|
13
|
+
});
|
package/dst/cjs/native/String.js
CHANGED
|
@@ -253,8 +253,8 @@ const funcRandomString = new Constant_js_1.Constant((value) => {
|
|
|
253
253
|
return str.slice(0, length);
|
|
254
254
|
}, Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Integer]), false);
|
|
255
255
|
const funcDecodeString = new Constant_js_1.Constant((value, encoding = "utf8", byteOffset, byteLength) => decodeString(value, encoding, byteOffset == null ? undefined : Number(byteOffset), byteLength == null ? undefined : Number(byteLength)), Type_js_1.Type.functionType(Type_js_1.Type.OptionalString, [Type_js_1.Type.OptionalBuffer, Type_js_1.Type.OptionalString, Type_js_1.Type.OptionalInteger, Type_js_1.Type.OptionalInteger]));
|
|
256
|
-
exports.constString = {
|
|
256
|
+
exports.constString = Object.assign(Object.create(null), {
|
|
257
257
|
Alphanum: funcAlphanum,
|
|
258
258
|
Random: funcRandomString,
|
|
259
259
|
Decode: funcDecodeString,
|
|
260
|
-
};
|
|
260
|
+
});
|
|
@@ -92,9 +92,9 @@ exports.funcSecondsSince = new Constant_js_1.Constant((value1, value2) => (value
|
|
|
92
92
|
const funcEpochTimestamp = new Constant_js_1.Constant((value, epoch = new Date(0)) => new Date(Number(value ?? 0) + epoch?.getTime()), Type_js_1.Type.functionType(Type_js_1.Type.Timestamp, [Type_js_1.Type.Number, Type_js_1.Type.OptionalTimestamp]));
|
|
93
93
|
const funcDecodeTimestamp = new Constant_js_1.Constant((value, encoding = "i64", byteOffset) => (0, exports.decodeTimestamp)(value, encoding, 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]));
|
|
94
94
|
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]));
|
|
95
|
-
exports.constTimestamp = {
|
|
95
|
+
exports.constTimestamp = Object.assign(Object.create(null), {
|
|
96
96
|
Now: funcNow,
|
|
97
97
|
Epoch: funcEpochTimestamp,
|
|
98
98
|
Decode: funcDecodeTimestamp,
|
|
99
99
|
Parse: funcParseTimestamp,
|
|
100
|
-
};
|
|
100
|
+
});
|
|
@@ -41,6 +41,6 @@ const formatAN = (value, whitespace) => {
|
|
|
41
41
|
};
|
|
42
42
|
exports.formatAN = formatAN;
|
|
43
43
|
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.Unknown, Type_js_1.Type.OptionalString]));
|
|
44
|
-
exports.constAN = {
|
|
44
|
+
exports.constAN = Object.assign(Object.create(null), {
|
|
45
45
|
Format: funcFormatAN,
|
|
46
|
-
};
|
|
46
|
+
});
|
|
@@ -232,8 +232,8 @@ const funcDecodeIP = new Constant_js_1.Constant((value) => {
|
|
|
232
232
|
return undefined;
|
|
233
233
|
}
|
|
234
234
|
}, Type_js_1.Type.functionType(Type_js_1.Type.OptionalString, [Type_js_1.Type.OptionalBuffer]));
|
|
235
|
-
exports.constIP = {
|
|
235
|
+
exports.constIP = Object.assign(Object.create(null), {
|
|
236
236
|
Match: funcMatchIP,
|
|
237
237
|
Encode: funcEncodeIP,
|
|
238
238
|
Decode: funcDecodeIP,
|
|
239
|
-
};
|
|
239
|
+
});
|
|
@@ -8,7 +8,7 @@ const formatJSON = (value, whitespace) => value == null ? "" : JSON.stringify(va
|
|
|
8
8
|
exports.formatJSON = formatJSON;
|
|
9
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
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.constJSON = {
|
|
11
|
+
exports.constJSON = Object.assign(Object.create(null), {
|
|
12
12
|
Format: funcFormatJSON,
|
|
13
13
|
Parse: funcParseJSON,
|
|
14
|
-
};
|
|
14
|
+
});
|
package/dst/native/Array.d.ts
CHANGED
|
@@ -13,10 +13,4 @@ export declare const funcReduce: Constant;
|
|
|
13
13
|
export declare const funcCompose: Constant;
|
|
14
14
|
export declare const funcPrepend: Constant;
|
|
15
15
|
export declare const funcAppend: Constant;
|
|
16
|
-
export declare const constArray:
|
|
17
|
-
Join: Constant;
|
|
18
|
-
Range: Constant;
|
|
19
|
-
Unique: Constant;
|
|
20
|
-
Intersection: Constant;
|
|
21
|
-
Difference: Constant;
|
|
22
|
-
};
|
|
16
|
+
export declare const constArray: any;
|
package/dst/native/Array.js
CHANGED
|
@@ -50,7 +50,7 @@ export const funcCompose = new Constant((value, callback) => {
|
|
|
50
50
|
if (value == null) {
|
|
51
51
|
return undefined;
|
|
52
52
|
}
|
|
53
|
-
const obj =
|
|
53
|
+
const obj = Object.create(null);
|
|
54
54
|
for (let i = 0; i < value.length; ++i) {
|
|
55
55
|
const key = value[i];
|
|
56
56
|
obj[key] = callback(obj, key, BigInt(i), value);
|
|
@@ -82,10 +82,10 @@ const funcUnique = new Constant((value) => {
|
|
|
82
82
|
}, Type.functionType(Type.Array, [Type.Array]));
|
|
83
83
|
const funcIntersection = new Constant((value1, value2) => value1?.filter((i) => value2?.some((v) => equate(v, i))) ?? [], typeArrayOperator);
|
|
84
84
|
const funcDifference = new Constant((value1, value2) => [...value1?.filter((i) => value2?.every((v) => !equate(v, i))) ?? [], ...value2?.filter((i) => value1?.every((v) => !equate(v, i))) ?? []], typeArrayOperator);
|
|
85
|
-
export const constArray = {
|
|
85
|
+
export const constArray = Object.assign(Object.create(null), {
|
|
86
86
|
Join: funcJoin,
|
|
87
87
|
Range: funcRange,
|
|
88
88
|
Unique: funcUnique,
|
|
89
89
|
Intersection: funcIntersection,
|
|
90
90
|
Difference: funcDifference,
|
|
91
|
-
};
|
|
91
|
+
});
|
package/dst/native/Boolean.d.ts
CHANGED
|
@@ -2,10 +2,4 @@ import { Constant } from "../Constant.js";
|
|
|
2
2
|
export declare const funcOr: Constant;
|
|
3
3
|
export declare const funcAnd: Constant;
|
|
4
4
|
export declare const funcNot: Constant;
|
|
5
|
-
export declare const constBoolean:
|
|
6
|
-
Or: Constant;
|
|
7
|
-
And: Constant;
|
|
8
|
-
Not: Constant;
|
|
9
|
-
Decode: Constant;
|
|
10
|
-
Parse: Constant;
|
|
11
|
-
};
|
|
5
|
+
export declare const constBoolean: any;
|
package/dst/native/Boolean.js
CHANGED
|
@@ -16,10 +16,10 @@ const funcParseBoolean = new Constant((value) => {
|
|
|
16
16
|
const v = value.toLowerCase();
|
|
17
17
|
return v === "true" ? true : v === "false" ? false : undefined;
|
|
18
18
|
}, Type.functionType(Type.OptionalBoolean, [Type.OptionalString]));
|
|
19
|
-
export const constBoolean = {
|
|
19
|
+
export const constBoolean = Object.assign(Object.create(null), {
|
|
20
20
|
Or: funcOr,
|
|
21
21
|
And: funcAnd,
|
|
22
22
|
Not: funcNot,
|
|
23
23
|
Decode: funcDecodeBoolean,
|
|
24
24
|
Parse: funcParseBoolean,
|
|
25
|
-
};
|
|
25
|
+
});
|
package/dst/native/Buffer.d.ts
CHANGED
|
@@ -8,7 +8,4 @@ export declare const concatBuffers: (value1: ArrayBuffer, value2: ArrayBuffer) =
|
|
|
8
8
|
export declare const formatBuffer: (value: ArrayBuffer, formatting?: BufferFormatting) => string;
|
|
9
9
|
export declare const parseBuffer: (value?: string) => ArrayBuffer | undefined;
|
|
10
10
|
export declare const funcByte: Constant;
|
|
11
|
-
export declare const constBuffer:
|
|
12
|
-
Random: Constant;
|
|
13
|
-
Parse: Constant;
|
|
14
|
-
};
|
|
11
|
+
export declare const constBuffer: any;
|
package/dst/native/Buffer.js
CHANGED
|
@@ -133,7 +133,7 @@ export const funcByte = new Constant((value, pos) => value == null
|
|
|
133
133
|
: value.slice(Number(pos), Number(pos) + 1), Type.functionType(Type.OptionalBuffer, [Type.Buffer, Type.Integer]));
|
|
134
134
|
const funcRandomBuffer = new Constant((value) => value == null || value <= 0n ? new Uint8Array(0).buffer : crypto.getRandomValues(new Uint8Array(Number(value))).buffer, Type.functionType(Type.Buffer, [Type.Integer]), false);
|
|
135
135
|
const funcParseBuffer = new Constant((value) => parseBuffer(value), Type.functionType(Type.OptionalBuffer, [Type.OptionalString]));
|
|
136
|
-
export const constBuffer = {
|
|
136
|
+
export const constBuffer = Object.assign(Object.create(null), {
|
|
137
137
|
Random: funcRandomBuffer,
|
|
138
138
|
Parse: funcParseBuffer,
|
|
139
|
-
};
|
|
139
|
+
});
|
package/dst/native/Float.d.ts
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
import { Constant } from "../Constant.js";
|
|
2
1
|
export type FloatEncoding = "f32" | "f32le" | "f64" | "f64le";
|
|
3
2
|
export declare const encodeFloat: (value: number, encoding?: FloatEncoding) => ArrayBuffer;
|
|
4
|
-
export declare const constFloat:
|
|
5
|
-
NAN: Constant;
|
|
6
|
-
PositiveInfinity: Constant;
|
|
7
|
-
NegativeInfinity: Constant;
|
|
8
|
-
Epsilon: Constant;
|
|
9
|
-
Sum: Constant;
|
|
10
|
-
Min: Constant;
|
|
11
|
-
Max: Constant;
|
|
12
|
-
Exponent: Constant;
|
|
13
|
-
Logarithm: Constant;
|
|
14
|
-
Abs: Constant;
|
|
15
|
-
Ceil: Constant;
|
|
16
|
-
Floor: Constant;
|
|
17
|
-
Round: Constant;
|
|
18
|
-
Truncate: Constant;
|
|
19
|
-
Random: Constant;
|
|
20
|
-
Decode: Constant;
|
|
21
|
-
Parse: Constant;
|
|
22
|
-
};
|
|
3
|
+
export declare const constFloat: any;
|
package/dst/native/Float.js
CHANGED
|
@@ -55,7 +55,7 @@ const funcTruncate = new Constant((value) => Math.trunc(Number(value)), typeTran
|
|
|
55
55
|
const funcRandomFloat = new Constant((value) => value == null ? undefined : Math.random() * Number(value), Type.functionType(Type.Float, [Type.Float]), false);
|
|
56
56
|
const funcDecodeFloat = new Constant((value, encoding = "f64", byteOffset) => decodeFloat(value, encoding, byteOffset == null ? undefined : Number(byteOffset)), Type.functionType(Type.OptionalFloat, [Type.OptionalBuffer, Type.OptionalString, Type.OptionalInteger]));
|
|
57
57
|
const funcParseFloat = new Constant((value) => value ? Number.parseFloat(value) : undefined, Type.functionType(Type.OptionalFloat, [Type.OptionalString]));
|
|
58
|
-
export const constFloat = {
|
|
58
|
+
export const constFloat = Object.assign(Object.create(null), {
|
|
59
59
|
NAN: new Constant(Number.NaN),
|
|
60
60
|
PositiveInfinity: new Constant(Number.POSITIVE_INFINITY),
|
|
61
61
|
NegativeInfinity: new Constant(Number.NEGATIVE_INFINITY),
|
|
@@ -73,4 +73,4 @@ export const constFloat = {
|
|
|
73
73
|
Random: funcRandomFloat,
|
|
74
74
|
Decode: funcDecodeFloat,
|
|
75
75
|
Parse: funcParseFloat,
|
|
76
|
-
};
|
|
76
|
+
});
|
package/dst/native/Integer.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import { Constant } from "../Constant.js";
|
|
2
1
|
export type IntegerEncoding = "i8" | "i16" | "i16le" | "i32" | "i32le" | "i64" | "i64le" | "n8" | "n16" | "n16le" | "n32" | "n32le" | "n64" | "n64le";
|
|
3
2
|
export declare const encodeInteger: (value: bigint, encoding?: IntegerEncoding) => ArrayBuffer;
|
|
4
|
-
export declare const constInteger:
|
|
5
|
-
Sum: Constant;
|
|
6
|
-
Min: Constant;
|
|
7
|
-
Max: Constant;
|
|
8
|
-
Random: Constant;
|
|
9
|
-
Decode: Constant;
|
|
10
|
-
Parse: Constant;
|
|
11
|
-
};
|
|
3
|
+
export declare const constInteger: any;
|
package/dst/native/Integer.js
CHANGED
|
@@ -93,11 +93,11 @@ const funcParseInteger = new Constant((value) => {
|
|
|
93
93
|
catch { }
|
|
94
94
|
return undefined;
|
|
95
95
|
}, Type.functionType(Type.OptionalInteger, [Type.OptionalString]));
|
|
96
|
-
export const constInteger = {
|
|
96
|
+
export const constInteger = Object.assign(Object.create(null), {
|
|
97
97
|
Sum: funcSum,
|
|
98
98
|
Min: funcMin,
|
|
99
99
|
Max: funcMax,
|
|
100
100
|
Random: funcRandomInteger,
|
|
101
101
|
Decode: funcDecodeInteger,
|
|
102
102
|
Parse: funcParseInteger,
|
|
103
|
-
};
|
|
103
|
+
});
|
package/dst/native/Iterable.js
CHANGED
|
@@ -26,7 +26,8 @@ export const funcAt = new Constant((value, index) => {
|
|
|
26
26
|
const ix = Number(index);
|
|
27
27
|
return value[ix < 0 ? value.length + ix : ix];
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
const key = String(index);
|
|
30
|
+
return Object.hasOwn(value, key) ? value[key] : undefined;
|
|
30
31
|
}, Type.union(Type.functionType(Type.Unknown, [Type.Array, Type.Integer]), Type.functionType(Type.Unknown, [Type.Object, Type.String])));
|
|
31
32
|
export const funcHas = new Constant((value, index) => {
|
|
32
33
|
if (value == null) {
|
package/dst/native/Object.d.ts
CHANGED
|
@@ -2,6 +2,4 @@ import { Constant } from "../Constant.js";
|
|
|
2
2
|
export declare const funcEntries: Constant;
|
|
3
3
|
export declare const funcKeys: Constant;
|
|
4
4
|
export declare const funcValues: Constant;
|
|
5
|
-
export declare const constObject:
|
|
6
|
-
Merge: Constant;
|
|
7
|
-
};
|
|
5
|
+
export declare const constObject: any;
|
package/dst/native/Object.js
CHANGED
|
@@ -4,7 +4,7 @@ const typeAccessor = Type.functionType(Type.Array, [Type.Object]);
|
|
|
4
4
|
export const funcEntries = new Constant((value) => value ? Object.entries(value) : undefined, typeAccessor);
|
|
5
5
|
export const funcKeys = new Constant((value) => value ? Object.keys(value) : undefined, Type.functionType(Type.arrayType([Type.String]), [Type.Object]));
|
|
6
6
|
export const funcValues = new Constant((value) => value ? Object.values(value) : undefined, typeAccessor);
|
|
7
|
-
const funcMerge = new Constant((...values) => values.flat().reduce((acc, val) => Object.assign(acc, val),
|
|
8
|
-
export const constObject = {
|
|
7
|
+
const funcMerge = new Constant((...values) => values.flat().reduce((acc, val) => Object.assign(acc, val), Object.create(null)), Type.functionType(Type.Object, [Type.union(Type.arrayType([Type.Object]), Type.Object)], true));
|
|
8
|
+
export const constObject = Object.assign(Object.create(null), {
|
|
9
9
|
Merge: funcMerge,
|
|
10
|
-
};
|
|
10
|
+
});
|
package/dst/native/String.d.ts
CHANGED
|
@@ -30,8 +30,4 @@ export declare const funcLowerCase: Constant;
|
|
|
30
30
|
export declare const funcUpperCase: Constant;
|
|
31
31
|
export declare const funcSplit: Constant;
|
|
32
32
|
export declare const funcReplaceWith: Constant;
|
|
33
|
-
export declare const constString:
|
|
34
|
-
Alphanum: Constant;
|
|
35
|
-
Random: Constant;
|
|
36
|
-
Decode: Constant;
|
|
37
|
-
};
|
|
33
|
+
export declare const constString: any;
|
package/dst/native/String.js
CHANGED
|
@@ -233,8 +233,8 @@ const funcRandomString = new Constant((value) => {
|
|
|
233
233
|
return str.slice(0, length);
|
|
234
234
|
}, Type.functionType(Type.String, [Type.Integer]), false);
|
|
235
235
|
const funcDecodeString = new Constant((value, encoding = "utf8", byteOffset, byteLength) => decodeString(value, encoding, byteOffset == null ? undefined : Number(byteOffset), byteLength == null ? undefined : Number(byteLength)), Type.functionType(Type.OptionalString, [Type.OptionalBuffer, Type.OptionalString, Type.OptionalInteger, Type.OptionalInteger]));
|
|
236
|
-
export const constString = {
|
|
236
|
+
export const constString = Object.assign(Object.create(null), {
|
|
237
237
|
Alphanum: funcAlphanum,
|
|
238
238
|
Random: funcRandomString,
|
|
239
239
|
Decode: funcDecodeString,
|
|
240
|
-
};
|
|
240
|
+
});
|
|
@@ -17,9 +17,4 @@ export declare const funcDaysSince: Constant;
|
|
|
17
17
|
export declare const funcHoursSince: Constant;
|
|
18
18
|
export declare const funcMinutesSince: Constant;
|
|
19
19
|
export declare const funcSecondsSince: Constant;
|
|
20
|
-
export declare const constTimestamp:
|
|
21
|
-
Now: Constant;
|
|
22
|
-
Epoch: Constant;
|
|
23
|
-
Decode: Constant;
|
|
24
|
-
Parse: Constant;
|
|
25
|
-
};
|
|
20
|
+
export declare const constTimestamp: any;
|
package/dst/native/Timestamp.js
CHANGED
|
@@ -86,9 +86,9 @@ export const funcSecondsSince = new Constant((value1, value2) => (value1?.getTim
|
|
|
86
86
|
const funcEpochTimestamp = new Constant((value, epoch = new Date(0)) => new Date(Number(value ?? 0) + epoch?.getTime()), Type.functionType(Type.Timestamp, [Type.Number, Type.OptionalTimestamp]));
|
|
87
87
|
const funcDecodeTimestamp = new Constant((value, encoding = "i64", byteOffset) => decodeTimestamp(value, encoding, byteOffset), Type.functionType(Type.OptionalTimestamp, [Type.OptionalBuffer, Type.OptionalString, Type.OptionalInteger]));
|
|
88
88
|
const funcParseTimestamp = new Constant((value) => parseTimestamp(value), Type.functionType(Type.OptionalTimestamp, [Type.OptionalString]));
|
|
89
|
-
export const constTimestamp = {
|
|
89
|
+
export const constTimestamp = Object.assign(Object.create(null), {
|
|
90
90
|
Now: funcNow,
|
|
91
91
|
Epoch: funcEpochTimestamp,
|
|
92
92
|
Decode: funcDecodeTimestamp,
|
|
93
93
|
Parse: funcParseTimestamp,
|
|
94
|
-
};
|
|
94
|
+
});
|
|
@@ -37,6 +37,6 @@ export const formatAN = (value, whitespace) => {
|
|
|
37
37
|
return "function";
|
|
38
38
|
};
|
|
39
39
|
const funcFormatAN = new Constant((value, whitespace) => formatAN(value, whitespace), Type.functionType(Type.String, [Type.Unknown, Type.OptionalString]));
|
|
40
|
-
export const constAN = {
|
|
40
|
+
export const constAN = Object.assign(Object.create(null), {
|
|
41
41
|
Format: funcFormatAN,
|
|
42
|
-
};
|
|
42
|
+
});
|
|
@@ -229,8 +229,8 @@ const funcDecodeIP = new Constant((value) => {
|
|
|
229
229
|
return undefined;
|
|
230
230
|
}
|
|
231
231
|
}, Type.functionType(Type.OptionalString, [Type.OptionalBuffer]));
|
|
232
|
-
export const constIP = {
|
|
232
|
+
export const constIP = Object.assign(Object.create(null), {
|
|
233
233
|
Match: funcMatchIP,
|
|
234
234
|
Encode: funcEncodeIP,
|
|
235
235
|
Decode: funcDecodeIP,
|
|
236
|
-
};
|
|
236
|
+
});
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { Constant } from "../../Constant.js";
|
|
2
1
|
import { Value } from "../../Value.js";
|
|
3
2
|
export declare const formatJSON: (value: Value, whitespace?: string) => string;
|
|
4
|
-
export declare const constJSON:
|
|
5
|
-
Format: Constant;
|
|
6
|
-
Parse: Constant;
|
|
7
|
-
};
|
|
3
|
+
export declare const constJSON: any;
|
|
@@ -4,7 +4,7 @@ const typeJson = Type.union(Type.Void, Type.Boolean, Type.Timestamp, Type.Float,
|
|
|
4
4
|
export const formatJSON = (value, whitespace) => value == null ? "" : JSON.stringify(value, (_key, value) => typeof value === "bigint" ? `"${value.toString()}"` : value, whitespace);
|
|
5
5
|
const funcFormatJSON = new Constant((value, whitespace) => formatJSON(value, whitespace), Type.functionType(Type.String, [typeJson, Type.OptionalString]));
|
|
6
6
|
const funcParseJSON = new Constant((value) => value == null ? undefined : JSON.parse(value), Type.functionType(typeJson, [Type.OptionalString]));
|
|
7
|
-
export const constJSON = {
|
|
7
|
+
export const constJSON = Object.assign(Object.create(null), {
|
|
8
8
|
Format: funcFormatJSON,
|
|
9
9
|
Parse: funcParseJSON,
|
|
10
|
-
};
|
|
10
|
+
});
|
package/dst/node/ObjectNode.js
CHANGED