affinirum 1.1.0 → 1.1.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.d.ts +1 -1
- package/dst/Affinirum.js +10 -10
- package/dst/cjs/Affinirum.js +10 -10
- package/dst/cjs/constant/Array.js +11 -10
- package/dst/cjs/constant/Boolean.js +1 -1
- package/dst/cjs/constant/Buffer.js +1 -1
- package/dst/cjs/constant/Enumerable.js +1 -1
- package/dst/cjs/constant/Float.js +11 -11
- package/dst/cjs/constant/Iterable.js +2 -2
- package/dst/cjs/constant/Number.js +2 -2
- package/dst/cjs/constant/String.js +39 -8
- package/dst/cjs/constant/Timestamp.js +20 -17
- package/dst/constant/Array.js +11 -10
- package/dst/constant/Boolean.js +1 -1
- package/dst/constant/Buffer.js +1 -1
- package/dst/constant/Enumerable.js +1 -1
- package/dst/constant/Float.d.ts +1 -1
- package/dst/constant/Float.js +11 -11
- package/dst/constant/Integer.d.ts +1 -1
- package/dst/constant/Iterable.js +2 -2
- package/dst/constant/Number.js +2 -2
- package/dst/constant/String.d.ts +6 -6
- package/dst/constant/String.js +39 -8
- package/dst/constant/Timestamp.d.ts +3 -3
- package/dst/constant/Timestamp.js +20 -17
- package/package.json +3 -3
package/dst/Affinirum.d.ts
CHANGED
|
@@ -56,13 +56,13 @@ export declare class Affinirum {
|
|
|
56
56
|
evaluate(values?: Record<string, Value>): Value;
|
|
57
57
|
protected _block(state: ParserState, scope: StaticScope): Node;
|
|
58
58
|
protected _unit(state: ParserState, scope: StaticScope): Node;
|
|
59
|
+
protected _coalescence(state: ParserState, scope: StaticScope): Node;
|
|
59
60
|
protected _disjunction(state: ParserState, scope: StaticScope): Node;
|
|
60
61
|
protected _conjunction(state: ParserState, scope: StaticScope): Node;
|
|
61
62
|
protected _comparison(state: ParserState, scope: StaticScope): Node;
|
|
62
63
|
protected _aggregate(state: ParserState, scope: StaticScope): Node;
|
|
63
64
|
protected _product(state: ParserState, scope: StaticScope): Node;
|
|
64
65
|
protected _factor(state: ParserState, scope: StaticScope): Node;
|
|
65
|
-
protected _coalescence(state: ParserState, scope: StaticScope): Node;
|
|
66
66
|
protected _accessor(state: ParserState, scope: StaticScope): Node;
|
|
67
67
|
protected _term(state: ParserState, scope: StaticScope): Node;
|
|
68
68
|
protected _function(state: ParserState, scope: StaticScope): Node;
|
package/dst/Affinirum.js
CHANGED
|
@@ -111,7 +111,14 @@ export class Affinirum {
|
|
|
111
111
|
return new BlockNode(frame.ends(state), nodes);
|
|
112
112
|
}
|
|
113
113
|
_unit(state, scope) {
|
|
114
|
-
return this.
|
|
114
|
+
return this._coalescence(state, scope);
|
|
115
|
+
}
|
|
116
|
+
_coalescence(state, scope) {
|
|
117
|
+
let node = this._disjunction(state, scope);
|
|
118
|
+
while (state.operator === funcCoalesce) {
|
|
119
|
+
node = this._call(state.starts(), state.operator, [node, this._disjunction(state.next(), scope)]);
|
|
120
|
+
}
|
|
121
|
+
return node;
|
|
115
122
|
}
|
|
116
123
|
_disjunction(state, scope) {
|
|
117
124
|
let node = this._conjunction(state, scope);
|
|
@@ -168,22 +175,15 @@ export class Affinirum {
|
|
|
168
175
|
frame.starts(state);
|
|
169
176
|
state.next();
|
|
170
177
|
}
|
|
171
|
-
let node = this.
|
|
178
|
+
let node = this._accessor(state, scope);
|
|
172
179
|
while (state.operator === funcPower) {
|
|
173
|
-
node = this._call(state.starts(), state.operator, [node, this.
|
|
180
|
+
node = this._call(state.starts(), state.operator, [node, this._accessor(state.next(), scope)]);
|
|
174
181
|
}
|
|
175
182
|
if (neg) {
|
|
176
183
|
node = this._call(frame.ends(state), funcNegate, [node]);
|
|
177
184
|
}
|
|
178
185
|
return node;
|
|
179
186
|
}
|
|
180
|
-
_coalescence(state, scope) {
|
|
181
|
-
let node = this._accessor(state, scope);
|
|
182
|
-
while (state.operator === funcCoalesce) {
|
|
183
|
-
node = this._call(state.starts(), state.operator, [node, this._accessor(state.next(), scope)]);
|
|
184
|
-
}
|
|
185
|
-
return node;
|
|
186
|
-
}
|
|
187
187
|
_accessor(state, scope) {
|
|
188
188
|
let node = this._term(state, scope);
|
|
189
189
|
while (state.isDotMark || state.isQuestionMark || state.isParenthesesOpen || state.isBracketsOpen) {
|
package/dst/cjs/Affinirum.js
CHANGED
|
@@ -114,7 +114,14 @@ class Affinirum {
|
|
|
114
114
|
return new BlockNode_js_1.BlockNode(frame.ends(state), nodes);
|
|
115
115
|
}
|
|
116
116
|
_unit(state, scope) {
|
|
117
|
-
return this.
|
|
117
|
+
return this._coalescence(state, scope);
|
|
118
|
+
}
|
|
119
|
+
_coalescence(state, scope) {
|
|
120
|
+
let node = this._disjunction(state, scope);
|
|
121
|
+
while (state.operator === Unknown_js_1.funcCoalesce) {
|
|
122
|
+
node = this._call(state.starts(), state.operator, [node, this._disjunction(state.next(), scope)]);
|
|
123
|
+
}
|
|
124
|
+
return node;
|
|
118
125
|
}
|
|
119
126
|
_disjunction(state, scope) {
|
|
120
127
|
let node = this._conjunction(state, scope);
|
|
@@ -171,22 +178,15 @@ class Affinirum {
|
|
|
171
178
|
frame.starts(state);
|
|
172
179
|
state.next();
|
|
173
180
|
}
|
|
174
|
-
let node = this.
|
|
181
|
+
let node = this._accessor(state, scope);
|
|
175
182
|
while (state.operator === Number_js_1.funcPower) {
|
|
176
|
-
node = this._call(state.starts(), state.operator, [node, this.
|
|
183
|
+
node = this._call(state.starts(), state.operator, [node, this._accessor(state.next(), scope)]);
|
|
177
184
|
}
|
|
178
185
|
if (neg) {
|
|
179
186
|
node = this._call(frame.ends(state), Number_js_1.funcNegate, [node]);
|
|
180
187
|
}
|
|
181
188
|
return node;
|
|
182
189
|
}
|
|
183
|
-
_coalescence(state, scope) {
|
|
184
|
-
let node = this._accessor(state, scope);
|
|
185
|
-
while (state.operator === Unknown_js_1.funcCoalesce) {
|
|
186
|
-
node = this._call(state.starts(), state.operator, [node, this._accessor(state.next(), scope)]);
|
|
187
|
-
}
|
|
188
|
-
return node;
|
|
189
|
-
}
|
|
190
190
|
_accessor(state, scope) {
|
|
191
191
|
let node = this._term(state, scope);
|
|
192
192
|
while (state.isDotMark || state.isQuestionMark || state.isParenthesesOpen || state.isBracketsOpen) {
|
|
@@ -40,14 +40,15 @@ exports.funcLastIndex = new Constant_js_1.Constant((value, predicate) => {
|
|
|
40
40
|
}
|
|
41
41
|
return undefined;
|
|
42
42
|
}, typeIndexFinder);
|
|
43
|
-
exports.funcEvery = new Constant_js_1.Constant((value, predicate) => value?.every((v, i, a) => predicate(v, BigInt(i), a)), typeConditionSet);
|
|
44
|
-
exports.funcAny = new Constant_js_1.Constant((value, predicate) => value?.some((v, i, a) => predicate(v, BigInt(i), a)), typeConditionSet);
|
|
45
|
-
exports.funcFlatten = new Constant_js_1.Constant((values, depth = 1n) => values?.flat(Number(depth)), Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_1.Type.Array, Type_js_1.Type.OptionalInteger]));
|
|
46
|
-
exports.funcReverse = new Constant_js_1.Constant((value) => [...value].reverse(), Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_1.Type.Array]));
|
|
43
|
+
exports.funcEvery = new Constant_js_1.Constant((value, predicate) => value?.every((v, i, a) => predicate(v, BigInt(i), a)) ?? false, typeConditionSet);
|
|
44
|
+
exports.funcAny = new Constant_js_1.Constant((value, predicate) => value?.some((v, i, a) => predicate(v, BigInt(i), a)) ?? false, typeConditionSet);
|
|
45
|
+
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]));
|
|
46
|
+
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]));
|
|
47
47
|
exports.funcMutate = 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, [Type_js_1.Type.Array, Type_js_1.Type.functionType(Type_js_1.Type.Unknown, [Type_js_1.Type.Unknown, Type_js_1.Type.OptionalInteger, Type_js_1.Type.OptionalArray])]));
|
|
48
48
|
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]));
|
|
49
49
|
exports.funcReduce = new Constant_js_1.Constant((value, reducer, initial) => initial != null
|
|
50
|
-
? value?.reduce((p, v, i, a) => reducer(p, v, BigInt(i), a), initial)
|
|
50
|
+
? value?.reduce((p, v, i, a) => reducer(p, v, BigInt(i), a), initial)
|
|
51
|
+
: value?.reduce((p, v, i, a) => reducer(p, v, BigInt(i), a)), Type_js_1.Type.functionType(Type_js_1.Type.Unknown, [Type_js_1.Type.Array, Type_js_1.Type.functionType(Type_js_1.Type.Unknown, [Type_js_1.Type.Unknown, Type_js_1.Type.Unknown, Type_js_1.Type.OptionalInteger, Type_js_1.Type.OptionalArray])]));
|
|
51
52
|
exports.funcCompose = new Constant_js_1.Constant((value, callback) => {
|
|
52
53
|
if (value == null) {
|
|
53
54
|
return undefined;
|
|
@@ -60,11 +61,11 @@ exports.funcCompose = new Constant_js_1.Constant((value, callback) => {
|
|
|
60
61
|
return obj;
|
|
61
62
|
}, Type_js_1.Type.functionType(Type_js_1.Type.Object, [Type_js_1.Type.Array, Type_js_1.Type.functionType(Type_js_1.Type.Unknown, [Type_js_1.Type.Object, Type_js_1.Type.String, Type_js_1.Type.OptionalInteger, Type_js_1.Type.OptionalArray])]));
|
|
62
63
|
exports.funcPrepend = new Constant_js_1.Constant((value, ...items) => {
|
|
63
|
-
value
|
|
64
|
+
value?.unshift(items);
|
|
64
65
|
return value;
|
|
65
66
|
}, typeVariadicInsert);
|
|
66
67
|
exports.funcAppend = new Constant_js_1.Constant((value, ...items) => {
|
|
67
|
-
value
|
|
68
|
+
value?.push(items);
|
|
68
69
|
return value;
|
|
69
70
|
}, typeVariadicInsert);
|
|
70
71
|
const funcJoin = new Constant_js_1.Constant((...values) => values.flat(Infinity).reduce((acc, val) => [...acc, val], []), Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_1.Type.Array], true));
|
|
@@ -75,15 +76,15 @@ const funcRange = new Constant_js_1.Constant((value1, value2) => {
|
|
|
75
76
|
}, Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_1.Type.Integer, Type_js_1.Type.Integer]));
|
|
76
77
|
const funcUnique = new Constant_js_1.Constant((value) => {
|
|
77
78
|
const result = [];
|
|
78
|
-
value
|
|
79
|
+
value?.forEach((i) => {
|
|
79
80
|
if (result.every((v) => !(0, Unknown_js_1.equate)(v, i))) {
|
|
80
81
|
result.push(i);
|
|
81
82
|
}
|
|
82
83
|
});
|
|
83
84
|
return result;
|
|
84
85
|
}, Type_js_1.Type.functionType(Type_js_1.Type.Array, [Type_js_1.Type.Array]));
|
|
85
|
-
const funcIntersection = new Constant_js_1.Constant((value1, value2) => value1
|
|
86
|
-
const funcDifference = new Constant_js_1.Constant((value1, value2) => [...value1
|
|
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
|
+
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);
|
|
87
88
|
exports.constArray = {
|
|
88
89
|
Join: funcJoin,
|
|
89
90
|
Range: funcRange,
|
|
@@ -8,7 +8,7 @@ const typeBooleanLogic = Type_js_1.Type.functionType(Type_js_1.Type.Boolean, [ty
|
|
|
8
8
|
exports.funcOr = new Constant_js_1.Constant((...values) => values.flat().some((v) => v), typeBooleanLogic);
|
|
9
9
|
exports.funcAnd = new Constant_js_1.Constant((...values) => values.flat().every((v) => v), typeBooleanLogic);
|
|
10
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]));
|
|
11
|
-
const funcDecodeBoolean = new Constant_js_1.Constant((value, byteOffset) => Boolean(new Uint8Array(value)[byteOffset == null ? 0 : Number(byteOffset)]), Type_js_1.Type.functionType(Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.Buffer, Type_js_1.Type.OptionalInteger]));
|
|
11
|
+
const funcDecodeBoolean = new Constant_js_1.Constant((value, byteOffset) => value ? Boolean(new Uint8Array(value)[byteOffset == null ? 0 : Number(byteOffset)]) : undefined, Type_js_1.Type.functionType(Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.Buffer, Type_js_1.Type.OptionalInteger]));
|
|
12
12
|
const funcParseBoolean = new Constant_js_1.Constant((value) => {
|
|
13
13
|
if (value == null) {
|
|
14
14
|
return undefined;
|
|
@@ -98,7 +98,7 @@ exports.parseBuffer = parseBuffer;
|
|
|
98
98
|
exports.funcByte = new Constant_js_1.Constant((value, pos) => value == null
|
|
99
99
|
? undefined
|
|
100
100
|
: 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]));
|
|
101
|
-
const funcRandomBuffer = new Constant_js_1.Constant((value) => value == null || value
|
|
101
|
+
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);
|
|
102
102
|
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.String]));
|
|
103
103
|
exports.constBuffer = {
|
|
104
104
|
Random: funcRandomBuffer,
|
|
@@ -20,7 +20,7 @@ const add = (value1, value2) => {
|
|
|
20
20
|
if (typeof value1 === "bigint" && typeof value2 === "bigint") {
|
|
21
21
|
return BigInt.asIntN(64, value1 + value2);
|
|
22
22
|
}
|
|
23
|
-
if (typeof value1 === "number" || typeof value2 === "number") {
|
|
23
|
+
if ((typeof value1 === "number" || typeof value1 === "bigint") && (typeof value2 === "number" || typeof value2 === "bigint")) {
|
|
24
24
|
return Number(value1) + Number(value2);
|
|
25
25
|
}
|
|
26
26
|
return aggregate(value1, value2);
|
|
@@ -51,17 +51,17 @@ exports.formatFloat = formatFloat;
|
|
|
51
51
|
const typeNumberOrArray = Type_js_1.Type.union(Type_js_1.Type.Float, Type_js_1.Type.arrayType([Type_js_1.Type.Float]));
|
|
52
52
|
const typeAggregator = Type_js_1.Type.functionType(Type_js_1.Type.Float, [typeNumberOrArray], true);
|
|
53
53
|
const typeTransform = Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Float]);
|
|
54
|
-
const funcSum = new Constant_js_1.Constant((...values) => values.flat().reduce((acc, val) => acc + val, 0), typeAggregator);
|
|
55
|
-
const funcMin = new Constant_js_1.Constant((...values) => Math.min(Number.POSITIVE_INFINITY, ...values.flat()), typeAggregator);
|
|
56
|
-
const funcMax = new Constant_js_1.Constant((...values) => Math.max(Number.NEGATIVE_INFINITY, ...values.flat()), typeAggregator);
|
|
57
|
-
const funcExponent = new Constant_js_1.Constant((value) => Math.exp(value), typeTransform);
|
|
58
|
-
const funcLogarithm = new Constant_js_1.Constant((value) => Math.log(value), typeTransform);
|
|
59
|
-
const funcAbs = new Constant_js_1.Constant((value) => Math.abs(value), typeTransform);
|
|
60
|
-
const funcCeil = new Constant_js_1.Constant((value) => Math.ceil(value), typeTransform);
|
|
61
|
-
const funcFloor = new Constant_js_1.Constant((value) => Math.floor(value), typeTransform);
|
|
62
|
-
const funcRound = new Constant_js_1.Constant((value) => Math.round(value), typeTransform);
|
|
63
|
-
const funcTruncate = new Constant_js_1.Constant((value) => Math.trunc(value), typeTransform);
|
|
64
|
-
const funcRandomFloat = new Constant_js_1.Constant((value) => value == null ? undefined : Math.random() * value, Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Float]), false);
|
|
54
|
+
const funcSum = new Constant_js_1.Constant((...values) => values.flat().reduce((acc, val) => acc + Number(val), 0), typeAggregator);
|
|
55
|
+
const funcMin = new Constant_js_1.Constant((...values) => Math.min(Number.POSITIVE_INFINITY, ...values.flat().map((i) => Number(i))), typeAggregator);
|
|
56
|
+
const funcMax = new Constant_js_1.Constant((...values) => Math.max(Number.NEGATIVE_INFINITY, ...values.flat().map((i) => Number(i))), typeAggregator);
|
|
57
|
+
const funcExponent = new Constant_js_1.Constant((value) => Math.exp(Number(value)), typeTransform);
|
|
58
|
+
const funcLogarithm = new Constant_js_1.Constant((value) => Math.log(Number(value)), typeTransform);
|
|
59
|
+
const funcAbs = new Constant_js_1.Constant((value) => Math.abs(Number(value)), typeTransform);
|
|
60
|
+
const funcCeil = new Constant_js_1.Constant((value) => Math.ceil(Number(value)), typeTransform);
|
|
61
|
+
const funcFloor = new Constant_js_1.Constant((value) => Math.floor(Number(value)), typeTransform);
|
|
62
|
+
const funcRound = new Constant_js_1.Constant((value) => Math.round(Number(value)), typeTransform);
|
|
63
|
+
const funcTruncate = new Constant_js_1.Constant((value) => Math.trunc(Number(value)), typeTransform);
|
|
64
|
+
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);
|
|
65
65
|
const funcDecodeFloat = new Constant_js_1.Constant((value, encoding = "float64", byteOffset) => decodeFloat(value, encoding, byteOffset == null ? undefined : Number(byteOffset)), Type_js_1.Type.functionType(Type_js_1.Type.OptionalFloat, [Type_js_1.Type.Buffer, Type_js_1.Type.OptionalString, Type_js_1.Type.OptionalInteger]));
|
|
66
66
|
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.String]));
|
|
67
67
|
exports.constFloat = {
|
|
@@ -13,7 +13,7 @@ exports.funcLength = new Constant_js_1.Constant((value) => BigInt.asIntN(64, Big
|
|
|
13
13
|
? value.length
|
|
14
14
|
: Object.keys(value).length)), Type_js_1.Type.functionType(Type_js_1.Type.Integer, [Type_js_1.Type.Iterable]));
|
|
15
15
|
exports.funcContains = new Constant_js_1.Constant((value, search, start, ignoreCaseSpaceEtc) => value == null
|
|
16
|
-
?
|
|
16
|
+
? false
|
|
17
17
|
: value instanceof ArrayBuffer
|
|
18
18
|
? (0, Buffer_js_1.containsBuffer)(value, search, start == null ? undefined : Number(start))
|
|
19
19
|
: typeof value === "string"
|
|
@@ -33,7 +33,7 @@ exports.funcAt = new Constant_js_1.Constant((value, index) => {
|
|
|
33
33
|
}, 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
34
|
exports.funcHas = new Constant_js_1.Constant((value, index) => {
|
|
35
35
|
if (value == null) {
|
|
36
|
-
return
|
|
36
|
+
return false;
|
|
37
37
|
}
|
|
38
38
|
else if (Array.isArray(value)) {
|
|
39
39
|
const ix = Number(index);
|
|
@@ -4,7 +4,7 @@ exports.funcCastToInteger = exports.funcCastToFloat = exports.funcCast = exports
|
|
|
4
4
|
const Constant_js_1 = require("../Constant.js");
|
|
5
5
|
const Type_js_1 = require("../Type.js");
|
|
6
6
|
const castToInteger = (value) => {
|
|
7
|
-
if (Number.isNaN(value)) {
|
|
7
|
+
if (value == null || Number.isNaN(value)) {
|
|
8
8
|
return 0n;
|
|
9
9
|
}
|
|
10
10
|
if (value === Number.NEGATIVE_INFINITY) {
|
|
@@ -67,7 +67,7 @@ exports.funcRoot = new Constant_js_1.Constant((value, exponent) => {
|
|
|
67
67
|
}
|
|
68
68
|
return Math.pow(Number(value), 1 / Number(exponent));
|
|
69
69
|
}, typeOperator);
|
|
70
|
-
exports.funcNegate = new Constant_js_1.Constant((value) => typeof value === "number" ? -value : BigInt.asIntN(64, -value), Type_js_1.Type.union(Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Float]), Type_js_1.Type.functionType(Type_js_1.Type.Integer, [Type_js_1.Type.Integer])));
|
|
70
|
+
exports.funcNegate = new Constant_js_1.Constant((value) => value == null ? undefined : typeof value === "number" ? -value : BigInt.asIntN(64, -value), Type_js_1.Type.union(Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Float]), Type_js_1.Type.functionType(Type_js_1.Type.Integer, [Type_js_1.Type.Integer])));
|
|
71
71
|
exports.funcCast = new Constant_js_1.Constant((value) => typeof value !== "number"
|
|
72
72
|
? Number(value)
|
|
73
73
|
: castToInteger(value), Type_js_1.Type.union(Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Integer]), Type_js_1.Type.functionType(Type_js_1.Type.Integer, [Type_js_1.Type.Float])));
|
|
@@ -22,6 +22,9 @@ exports.isHexadecimal = isHexadecimal;
|
|
|
22
22
|
const isCaseSpaceEtc = (c) => (c < "a" || c > "z") && (c < "0" || c > "9");
|
|
23
23
|
exports.isCaseSpaceEtc = isCaseSpaceEtc;
|
|
24
24
|
const replaceWith = (value, replacement, ...search) => {
|
|
25
|
+
if (value == null) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
25
28
|
let str = value;
|
|
26
29
|
for (const s of search) {
|
|
27
30
|
str = str.split(s).join(replacement ?? "");
|
|
@@ -30,6 +33,12 @@ const replaceWith = (value, replacement, ...search) => {
|
|
|
30
33
|
};
|
|
31
34
|
exports.replaceWith = replaceWith;
|
|
32
35
|
const equateStrings = (value1, value2, ignoreCaseSpaceEtc) => {
|
|
36
|
+
if (value1 == null && value2 == null) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (value1 == null || value2 == null) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
33
42
|
if (!ignoreCaseSpaceEtc) {
|
|
34
43
|
return value1 === value2;
|
|
35
44
|
}
|
|
@@ -50,6 +59,12 @@ const equateStrings = (value1, value2, ignoreCaseSpaceEtc) => {
|
|
|
50
59
|
};
|
|
51
60
|
exports.equateStrings = equateStrings;
|
|
52
61
|
const containsString = (value, search, startPos, ignoreCaseSpaceEtc) => {
|
|
62
|
+
if (value == null) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
if (search == null) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
53
68
|
if (!ignoreCaseSpaceEtc) {
|
|
54
69
|
return value.includes(search, startPos);
|
|
55
70
|
}
|
|
@@ -83,6 +98,12 @@ const containsString = (value, search, startPos, ignoreCaseSpaceEtc) => {
|
|
|
83
98
|
};
|
|
84
99
|
exports.containsString = containsString;
|
|
85
100
|
const startsWithString = (value, search, startPos, ignoreCaseSpaceEtc) => {
|
|
101
|
+
if (value == null) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
if (search == null) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
86
107
|
if (!ignoreCaseSpaceEtc) {
|
|
87
108
|
return value.startsWith(search, startPos);
|
|
88
109
|
}
|
|
@@ -107,6 +128,12 @@ const startsWithString = (value, search, startPos, ignoreCaseSpaceEtc) => {
|
|
|
107
128
|
};
|
|
108
129
|
exports.startsWithString = startsWithString;
|
|
109
130
|
const endsWithString = (value, search, endPos, ignoreCaseSpaceEtc) => {
|
|
131
|
+
if (value == null) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
if (search == null) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
110
137
|
if (!ignoreCaseSpaceEtc) {
|
|
111
138
|
return value.endsWith(search, endPos);
|
|
112
139
|
}
|
|
@@ -178,14 +205,17 @@ exports.funcChar = new Constant_js_1.Constant((value, pos) => value == null
|
|
|
178
205
|
exports.funcCharCode = new Constant_js_1.Constant((value, pos) => value == null
|
|
179
206
|
? undefined
|
|
180
207
|
: value.charCodeAt(pos < 0 ? value.length + Number(pos) : Number(pos)), Type_js_1.Type.functionType(Type_js_1.Type.OptionalInteger, [Type_js_1.Type.String, Type_js_1.Type.Float]));
|
|
181
|
-
exports.funcTrim = new Constant_js_1.Constant((value) => value
|
|
182
|
-
exports.funcTrimStart = new Constant_js_1.Constant((value) => value
|
|
183
|
-
exports.funcTrimEnd = new Constant_js_1.Constant((value) => value
|
|
184
|
-
exports.funcLowerCase = new Constant_js_1.Constant((value) => value
|
|
185
|
-
exports.funcUpperCase = new Constant_js_1.Constant((value) => value
|
|
186
|
-
exports.funcSplit = new Constant_js_1.Constant((value, separator = " ") => value
|
|
208
|
+
exports.funcTrim = new Constant_js_1.Constant((value) => value?.trim(), typeStringMutator);
|
|
209
|
+
exports.funcTrimStart = new Constant_js_1.Constant((value) => value?.trimStart(), typeStringMutator);
|
|
210
|
+
exports.funcTrimEnd = new Constant_js_1.Constant((value) => value?.trimEnd(), typeStringMutator);
|
|
211
|
+
exports.funcLowerCase = new Constant_js_1.Constant((value) => value?.toLowerCase(), typeStringMutator);
|
|
212
|
+
exports.funcUpperCase = new Constant_js_1.Constant((value) => value?.toUpperCase(), typeStringMutator);
|
|
213
|
+
exports.funcSplit = new Constant_js_1.Constant((value, separator = " ") => value?.split(separator) ?? [], Type_js_1.Type.functionType(Type_js_1.Type.arrayType([Type_js_1.Type.String]), [Type_js_1.Type.String, Type_js_1.Type.OptionalString]));
|
|
187
214
|
exports.funcReplaceWith = new Constant_js_1.Constant((value, replacement, ...search) => (0, exports.replaceWith)(value, replacement, ...search.flat()), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.String, Type_js_1.Type.String, typeStringOrArray], true));
|
|
188
215
|
const funcAlphanum = new Constant_js_1.Constant((value) => {
|
|
216
|
+
if (!value) {
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
189
219
|
const lowerCase = value.toLowerCase();
|
|
190
220
|
let result = "";
|
|
191
221
|
for (let i = 0; i < lowerCase.length; ++i) {
|
|
@@ -197,10 +227,11 @@ const funcAlphanum = new Constant_js_1.Constant((value) => {
|
|
|
197
227
|
}, typeStringMutator);
|
|
198
228
|
const funcRandomString = new Constant_js_1.Constant((value) => {
|
|
199
229
|
let str = "";
|
|
200
|
-
|
|
230
|
+
const length = Number(value ?? 0);
|
|
231
|
+
while (str.length < length) {
|
|
201
232
|
str += Math.random().toString(36).slice(2);
|
|
202
233
|
}
|
|
203
|
-
return str.slice(0,
|
|
234
|
+
return str.slice(0, length);
|
|
204
235
|
}, Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Integer]), false);
|
|
205
236
|
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.Buffer, Type_js_1.Type.OptionalString, Type_js_1.Type.OptionalInteger, Type_js_1.Type.OptionalInteger]));
|
|
206
237
|
exports.constString = {
|
|
@@ -8,13 +8,16 @@ const typeTimestampSince = Type_js_1.Type.functionType(Type_js_1.Type.Float, [Ty
|
|
|
8
8
|
const encodeTimestamp = (value, encoding = "int64") => {
|
|
9
9
|
const buf = new ArrayBuffer(8);
|
|
10
10
|
const dv = new DataView(buf);
|
|
11
|
-
dv.setBigInt64(0, BigInt(value
|
|
11
|
+
dv.setBigInt64(0, BigInt(value?.getTime() ?? 0), encoding === "int64le");
|
|
12
12
|
return buf;
|
|
13
13
|
};
|
|
14
14
|
exports.encodeTimestamp = encodeTimestamp;
|
|
15
|
-
const decodeTimestamp = (value, encoding = "int64", byteOffset) => new Date(Number(new DataView(value).getBigInt64(byteOffset == null ? 0 : Number(byteOffset), encoding === "int64le")));
|
|
15
|
+
const decodeTimestamp = (value, encoding = "int64", byteOffset) => value ? new Date(Number(new DataView(value).getBigInt64(byteOffset == null ? 0 : Number(byteOffset), encoding === "int64le"))) : undefined;
|
|
16
16
|
exports.decodeTimestamp = decodeTimestamp;
|
|
17
17
|
const formatTimestamp = (value, radix) => {
|
|
18
|
+
if (value == null) {
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
18
21
|
const str = value.toISOString();
|
|
19
22
|
switch (radix) {
|
|
20
23
|
case 1: return str.slice(0, 4);
|
|
@@ -36,21 +39,21 @@ const parseTimestamp = (value) => {
|
|
|
36
39
|
return isNaN(date.getTime()) ? undefined : date;
|
|
37
40
|
};
|
|
38
41
|
const funcNow = new Constant_js_1.Constant(() => new Date(), Type_js_1.Type.functionType(Type_js_1.Type.Timestamp, []), false);
|
|
39
|
-
exports.funcYear = new Constant_js_1.Constant((value, utc = false) => BigInt(utc ? value.getUTCFullYear() : value.getFullYear()), typeTimestampPart);
|
|
40
|
-
exports.funcMonth = new Constant_js_1.Constant((value, utc = false) => BigInt(1 + (utc ? value.getUTCMonth() : value.getMonth())), typeTimestampPart);
|
|
41
|
-
exports.funcMonthIndex = new Constant_js_1.Constant((value, utc = false) => BigInt(utc ? value.getUTCMonth() : value.getMonth()), typeTimestampPart);
|
|
42
|
-
exports.funcWeekdayIndex = new Constant_js_1.Constant((value, utc = false) => BigInt(utc ? value.getUTCDay() : value.getDay()), typeTimestampPart);
|
|
43
|
-
exports.funcDay = new Constant_js_1.Constant((value, utc = false) => BigInt(utc ? value.getUTCDate() : value.getDate()), typeTimestampPart);
|
|
44
|
-
exports.funcHour = new Constant_js_1.Constant((value, utc = false) => BigInt(utc ? value.getUTCHours() : value.getHours()), typeTimestampPart);
|
|
45
|
-
exports.funcMinute = new Constant_js_1.Constant((value, utc = false) => BigInt(utc ? value.getUTCMinutes() : value.getMinutes()), typeTimestampPart);
|
|
46
|
-
exports.funcSecond = new Constant_js_1.Constant((value, utc = false) => BigInt(utc ? value.getUTCSeconds() : value.getSeconds()), typeTimestampPart);
|
|
47
|
-
exports.funcMillisecond = new Constant_js_1.Constant((value, utc = false) => BigInt(utc ? value.getUTCMilliseconds() : value.getMilliseconds()), typeTimestampPart);
|
|
48
|
-
exports.funcEpochTime = new Constant_js_1.Constant((value, epoch = new Date(0)) => BigInt.asIntN(64, BigInt(value.getTime() - epoch.getTime())), Type_js_1.Type.functionType(Type_js_1.Type.Integer, [Type_js_1.Type.Timestamp, Type_js_1.Type.OptionalTimestamp]));
|
|
49
|
-
exports.funcDaysSince = new Constant_js_1.Constant((value1, value2) => (value1
|
|
50
|
-
exports.funcHoursSince = new Constant_js_1.Constant((value1, value2) => (value1
|
|
51
|
-
exports.funcMinutesSince = new Constant_js_1.Constant((value1, value2) => (value1
|
|
52
|
-
exports.funcSecondsSince = new Constant_js_1.Constant((value1, value2) => (value1
|
|
53
|
-
const funcEpochTimestamp = new Constant_js_1.Constant((value, epoch = new Date(0)) => new Date(Number(value) + epoch
|
|
42
|
+
exports.funcYear = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCFullYear() : value.getFullYear()) : undefined, typeTimestampPart);
|
|
43
|
+
exports.funcMonth = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(1 + (utc ? value.getUTCMonth() : value.getMonth())) : undefined, typeTimestampPart);
|
|
44
|
+
exports.funcMonthIndex = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCMonth() : value.getMonth()) : undefined, typeTimestampPart);
|
|
45
|
+
exports.funcWeekdayIndex = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCDay() : value.getDay()) : undefined, typeTimestampPart);
|
|
46
|
+
exports.funcDay = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCDate() : value.getDate()) : undefined, typeTimestampPart);
|
|
47
|
+
exports.funcHour = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCHours() : value.getHours()) : undefined, typeTimestampPart);
|
|
48
|
+
exports.funcMinute = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCMinutes() : value.getMinutes()) : undefined, typeTimestampPart);
|
|
49
|
+
exports.funcSecond = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCSeconds() : value.getSeconds()) : undefined, typeTimestampPart);
|
|
50
|
+
exports.funcMillisecond = new Constant_js_1.Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCMilliseconds() : value.getMilliseconds()) : undefined, typeTimestampPart);
|
|
51
|
+
exports.funcEpochTime = new Constant_js_1.Constant((value, epoch = new Date(0)) => value ? BigInt.asIntN(64, 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]));
|
|
52
|
+
exports.funcDaysSince = new Constant_js_1.Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 86400000.0, typeTimestampSince);
|
|
53
|
+
exports.funcHoursSince = new Constant_js_1.Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 3600000.0, typeTimestampSince);
|
|
54
|
+
exports.funcMinutesSince = new Constant_js_1.Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 60000.0, typeTimestampSince);
|
|
55
|
+
exports.funcSecondsSince = new Constant_js_1.Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 1000.0, typeTimestampSince);
|
|
56
|
+
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]));
|
|
54
57
|
const funcDecodeTimestamp = new Constant_js_1.Constant((value, encoding = "int64", byteOffset) => (0, exports.decodeTimestamp)(value, encoding, byteOffset), Type_js_1.Type.functionType(Type_js_1.Type.OptionalTimestamp, [Type_js_1.Type.Buffer, Type_js_1.Type.OptionalString, Type_js_1.Type.OptionalInteger]));
|
|
55
58
|
const funcParseTimestamp = new Constant_js_1.Constant((value) => parseTimestamp(value), Type_js_1.Type.functionType(Type_js_1.Type.OptionalTimestamp, [Type_js_1.Type.String]));
|
|
56
59
|
exports.constTimestamp = {
|
package/dst/constant/Array.js
CHANGED
|
@@ -37,14 +37,15 @@ export const funcLastIndex = new Constant((value, predicate) => {
|
|
|
37
37
|
}
|
|
38
38
|
return undefined;
|
|
39
39
|
}, typeIndexFinder);
|
|
40
|
-
export const funcEvery = new Constant((value, predicate) => value?.every((v, i, a) => predicate(v, BigInt(i), a)), typeConditionSet);
|
|
41
|
-
export const funcAny = new Constant((value, predicate) => value?.some((v, i, a) => predicate(v, BigInt(i), a)), typeConditionSet);
|
|
42
|
-
export const funcFlatten = new Constant((values, depth = 1n) => values?.flat(Number(depth)), Type.functionType(Type.Array, [Type.Array, Type.OptionalInteger]));
|
|
43
|
-
export const funcReverse = new Constant((value) => [...value].reverse(), Type.functionType(Type.Array, [Type.Array]));
|
|
40
|
+
export const funcEvery = new Constant((value, predicate) => value?.every((v, i, a) => predicate(v, BigInt(i), a)) ?? false, typeConditionSet);
|
|
41
|
+
export const funcAny = new Constant((value, predicate) => value?.some((v, i, a) => predicate(v, BigInt(i), a)) ?? false, typeConditionSet);
|
|
42
|
+
export const funcFlatten = new Constant((values, depth = 1n) => values ? values?.flat(Number(depth)) : undefined, Type.functionType(Type.Array, [Type.Array, Type.OptionalInteger]));
|
|
43
|
+
export const funcReverse = new Constant((value) => value ? [...value].reverse() : undefined, Type.functionType(Type.Array, [Type.Array]));
|
|
44
44
|
export const funcMutate = new Constant((value, transform) => value?.map((v, i, a) => transform(v, BigInt(i), a)), Type.functionType(Type.Array, [Type.Array, Type.functionType(Type.Unknown, [Type.Unknown, Type.OptionalInteger, Type.OptionalArray])]));
|
|
45
45
|
export const funcFilter = new Constant((value, predicate) => value?.filter((v, i, a) => predicate(v, BigInt(i), a)), Type.functionType(Type.Array, [Type.Array, typePredicate]));
|
|
46
46
|
export const funcReduce = new Constant((value, reducer, initial) => initial != null
|
|
47
|
-
? value?.reduce((p, v, i, a) => reducer(p, v, BigInt(i), a), initial)
|
|
47
|
+
? value?.reduce((p, v, i, a) => reducer(p, v, BigInt(i), a), initial)
|
|
48
|
+
: value?.reduce((p, v, i, a) => reducer(p, v, BigInt(i), a)), Type.functionType(Type.Unknown, [Type.Array, Type.functionType(Type.Unknown, [Type.Unknown, Type.Unknown, Type.OptionalInteger, Type.OptionalArray])]));
|
|
48
49
|
export const funcCompose = new Constant((value, callback) => {
|
|
49
50
|
if (value == null) {
|
|
50
51
|
return undefined;
|
|
@@ -57,11 +58,11 @@ export const funcCompose = new Constant((value, callback) => {
|
|
|
57
58
|
return obj;
|
|
58
59
|
}, Type.functionType(Type.Object, [Type.Array, Type.functionType(Type.Unknown, [Type.Object, Type.String, Type.OptionalInteger, Type.OptionalArray])]));
|
|
59
60
|
export const funcPrepend = new Constant((value, ...items) => {
|
|
60
|
-
value
|
|
61
|
+
value?.unshift(items);
|
|
61
62
|
return value;
|
|
62
63
|
}, typeVariadicInsert);
|
|
63
64
|
export const funcAppend = new Constant((value, ...items) => {
|
|
64
|
-
value
|
|
65
|
+
value?.push(items);
|
|
65
66
|
return value;
|
|
66
67
|
}, typeVariadicInsert);
|
|
67
68
|
const funcJoin = new Constant((...values) => values.flat(Infinity).reduce((acc, val) => [...acc, val], []), Type.functionType(Type.Array, [Type.Array], true));
|
|
@@ -72,15 +73,15 @@ const funcRange = new Constant((value1, value2) => {
|
|
|
72
73
|
}, Type.functionType(Type.Array, [Type.Integer, Type.Integer]));
|
|
73
74
|
const funcUnique = new Constant((value) => {
|
|
74
75
|
const result = [];
|
|
75
|
-
value
|
|
76
|
+
value?.forEach((i) => {
|
|
76
77
|
if (result.every((v) => !equate(v, i))) {
|
|
77
78
|
result.push(i);
|
|
78
79
|
}
|
|
79
80
|
});
|
|
80
81
|
return result;
|
|
81
82
|
}, Type.functionType(Type.Array, [Type.Array]));
|
|
82
|
-
const funcIntersection = new Constant((value1, value2) => value1
|
|
83
|
-
const funcDifference = new Constant((value1, value2) => [...value1
|
|
83
|
+
const funcIntersection = new Constant((value1, value2) => value1?.filter((i) => value2?.some((v) => equate(v, i))) ?? [], typeArrayOperator);
|
|
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);
|
|
84
85
|
export const constArray = {
|
|
85
86
|
Join: funcJoin,
|
|
86
87
|
Range: funcRange,
|
package/dst/constant/Boolean.js
CHANGED
|
@@ -5,7 +5,7 @@ const typeBooleanLogic = Type.functionType(Type.Boolean, [typeBooleanOrArray], t
|
|
|
5
5
|
export const funcOr = new Constant((...values) => values.flat().some((v) => v), typeBooleanLogic);
|
|
6
6
|
export const funcAnd = new Constant((...values) => values.flat().every((v) => v), typeBooleanLogic);
|
|
7
7
|
export const funcNot = new Constant((value) => !value, Type.functionType(Type.Boolean, [Type.Boolean]));
|
|
8
|
-
const funcDecodeBoolean = new Constant((value, byteOffset) => Boolean(new Uint8Array(value)[byteOffset == null ? 0 : Number(byteOffset)]), Type.functionType(Type.OptionalBoolean, [Type.Buffer, Type.OptionalInteger]));
|
|
8
|
+
const funcDecodeBoolean = new Constant((value, byteOffset) => value ? Boolean(new Uint8Array(value)[byteOffset == null ? 0 : Number(byteOffset)]) : undefined, Type.functionType(Type.OptionalBoolean, [Type.Buffer, Type.OptionalInteger]));
|
|
9
9
|
const funcParseBoolean = new Constant((value) => {
|
|
10
10
|
if (value == null) {
|
|
11
11
|
return undefined;
|
package/dst/constant/Buffer.js
CHANGED
|
@@ -90,7 +90,7 @@ export const parseBuffer = (value) => {
|
|
|
90
90
|
export const funcByte = new Constant((value, pos) => value == null
|
|
91
91
|
? undefined
|
|
92
92
|
: value.slice(Number(pos), Number(pos) + 1), Type.functionType(Type.OptionalBuffer, [Type.Buffer, Type.Integer]));
|
|
93
|
-
const funcRandomBuffer = new Constant((value) => value == null || value
|
|
93
|
+
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);
|
|
94
94
|
const funcParseBuffer = new Constant((value) => parseBuffer(value), Type.functionType(Type.OptionalBuffer, [Type.String]));
|
|
95
95
|
export const constBuffer = {
|
|
96
96
|
Random: funcRandomBuffer,
|
|
@@ -17,7 +17,7 @@ const add = (value1, value2) => {
|
|
|
17
17
|
if (typeof value1 === "bigint" && typeof value2 === "bigint") {
|
|
18
18
|
return BigInt.asIntN(64, value1 + value2);
|
|
19
19
|
}
|
|
20
|
-
if (typeof value1 === "number" || typeof value2 === "number") {
|
|
20
|
+
if ((typeof value1 === "number" || typeof value1 === "bigint") && (typeof value2 === "number" || typeof value2 === "bigint")) {
|
|
21
21
|
return Number(value1) + Number(value2);
|
|
22
22
|
}
|
|
23
23
|
return aggregate(value1, value2);
|
package/dst/constant/Float.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Constant } from "../Constant.js";
|
|
2
|
-
export declare const encodeFloat: (value
|
|
2
|
+
export declare const encodeFloat: (value?: number, encoding?: "float32" | "float32le" | "float64" | "float64le") => ArrayBuffer;
|
|
3
3
|
export declare const formatFloat: (value: number, radix?: number) => string;
|
|
4
4
|
export declare const constFloat: {
|
|
5
5
|
NAN: Constant;
|
package/dst/constant/Float.js
CHANGED
|
@@ -46,17 +46,17 @@ export const formatFloat = (value, radix) => value.toString(radix) + (Number.isI
|
|
|
46
46
|
const typeNumberOrArray = Type.union(Type.Float, Type.arrayType([Type.Float]));
|
|
47
47
|
const typeAggregator = Type.functionType(Type.Float, [typeNumberOrArray], true);
|
|
48
48
|
const typeTransform = Type.functionType(Type.Float, [Type.Float]);
|
|
49
|
-
const funcSum = new Constant((...values) => values.flat().reduce((acc, val) => acc + val, 0), typeAggregator);
|
|
50
|
-
const funcMin = new Constant((...values) => Math.min(Number.POSITIVE_INFINITY, ...values.flat()), typeAggregator);
|
|
51
|
-
const funcMax = new Constant((...values) => Math.max(Number.NEGATIVE_INFINITY, ...values.flat()), typeAggregator);
|
|
52
|
-
const funcExponent = new Constant((value) => Math.exp(value), typeTransform);
|
|
53
|
-
const funcLogarithm = new Constant((value) => Math.log(value), typeTransform);
|
|
54
|
-
const funcAbs = new Constant((value) => Math.abs(value), typeTransform);
|
|
55
|
-
const funcCeil = new Constant((value) => Math.ceil(value), typeTransform);
|
|
56
|
-
const funcFloor = new Constant((value) => Math.floor(value), typeTransform);
|
|
57
|
-
const funcRound = new Constant((value) => Math.round(value), typeTransform);
|
|
58
|
-
const funcTruncate = new Constant((value) => Math.trunc(value), typeTransform);
|
|
59
|
-
const funcRandomFloat = new Constant((value) => value == null ? undefined : Math.random() * value, Type.functionType(Type.Float, [Type.Float]), false);
|
|
49
|
+
const funcSum = new Constant((...values) => values.flat().reduce((acc, val) => acc + Number(val), 0), typeAggregator);
|
|
50
|
+
const funcMin = new Constant((...values) => Math.min(Number.POSITIVE_INFINITY, ...values.flat().map((i) => Number(i))), typeAggregator);
|
|
51
|
+
const funcMax = new Constant((...values) => Math.max(Number.NEGATIVE_INFINITY, ...values.flat().map((i) => Number(i))), typeAggregator);
|
|
52
|
+
const funcExponent = new Constant((value) => Math.exp(Number(value)), typeTransform);
|
|
53
|
+
const funcLogarithm = new Constant((value) => Math.log(Number(value)), typeTransform);
|
|
54
|
+
const funcAbs = new Constant((value) => Math.abs(Number(value)), typeTransform);
|
|
55
|
+
const funcCeil = new Constant((value) => Math.ceil(Number(value)), typeTransform);
|
|
56
|
+
const funcFloor = new Constant((value) => Math.floor(Number(value)), typeTransform);
|
|
57
|
+
const funcRound = new Constant((value) => Math.round(Number(value)), typeTransform);
|
|
58
|
+
const funcTruncate = new Constant((value) => Math.trunc(Number(value)), typeTransform);
|
|
59
|
+
const funcRandomFloat = new Constant((value) => value == null ? undefined : Math.random() * Number(value), Type.functionType(Type.Float, [Type.Float]), false);
|
|
60
60
|
const funcDecodeFloat = new Constant((value, encoding = "float64", byteOffset) => decodeFloat(value, encoding, byteOffset == null ? undefined : Number(byteOffset)), Type.functionType(Type.OptionalFloat, [Type.Buffer, Type.OptionalString, Type.OptionalInteger]));
|
|
61
61
|
const funcParseFloat = new Constant((value) => value ? Number.parseFloat(value) : undefined, Type.functionType(Type.OptionalFloat, [Type.String]));
|
|
62
62
|
export const constFloat = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Constant } from "../Constant.js";
|
|
2
|
-
export declare const encodeInteger: (value
|
|
2
|
+
export declare const encodeInteger: (value?: bigint, encoding?: "int8" | "int16" | "int16le" | "int32" | "int32le" | "uint8" | "uint16" | "uint16le" | "uint32" | "uint32le" | "int64" | "int64le" | "uint64" | "uint64le") => ArrayBuffer;
|
|
3
3
|
export declare const constInteger: {
|
|
4
4
|
Sum: Constant;
|
|
5
5
|
Min: Constant;
|
package/dst/constant/Iterable.js
CHANGED
|
@@ -10,7 +10,7 @@ export const funcLength = new Constant((value) => BigInt.asIntN(64, BigInt(value
|
|
|
10
10
|
? value.length
|
|
11
11
|
: Object.keys(value).length)), Type.functionType(Type.Integer, [Type.Iterable]));
|
|
12
12
|
export const funcContains = new Constant((value, search, start, ignoreCaseSpaceEtc) => value == null
|
|
13
|
-
?
|
|
13
|
+
? false
|
|
14
14
|
: value instanceof ArrayBuffer
|
|
15
15
|
? containsBuffer(value, search, start == null ? undefined : Number(start))
|
|
16
16
|
: typeof value === "string"
|
|
@@ -30,7 +30,7 @@ export const funcAt = new Constant((value, index) => {
|
|
|
30
30
|
}, Type.union(Type.functionType(Type.Unknown, [Type.Array, Type.Integer]), Type.functionType(Type.Unknown, [Type.Object, Type.String])));
|
|
31
31
|
export const funcHas = new Constant((value, index) => {
|
|
32
32
|
if (value == null) {
|
|
33
|
-
return
|
|
33
|
+
return false;
|
|
34
34
|
}
|
|
35
35
|
else if (Array.isArray(value)) {
|
|
36
36
|
const ix = Number(index);
|
package/dst/constant/Number.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Constant } from "../Constant.js";
|
|
2
2
|
import { Type } from "../Type.js";
|
|
3
3
|
const castToInteger = (value) => {
|
|
4
|
-
if (Number.isNaN(value)) {
|
|
4
|
+
if (value == null || Number.isNaN(value)) {
|
|
5
5
|
return 0n;
|
|
6
6
|
}
|
|
7
7
|
if (value === Number.NEGATIVE_INFINITY) {
|
|
@@ -64,7 +64,7 @@ export const funcRoot = new Constant((value, exponent) => {
|
|
|
64
64
|
}
|
|
65
65
|
return Math.pow(Number(value), 1 / Number(exponent));
|
|
66
66
|
}, typeOperator);
|
|
67
|
-
export const funcNegate = new Constant((value) => typeof value === "number" ? -value : BigInt.asIntN(64, -value), Type.union(Type.functionType(Type.Float, [Type.Float]), Type.functionType(Type.Integer, [Type.Integer])));
|
|
67
|
+
export const funcNegate = new Constant((value) => value == null ? undefined : typeof value === "number" ? -value : BigInt.asIntN(64, -value), Type.union(Type.functionType(Type.Float, [Type.Float]), Type.functionType(Type.Integer, [Type.Integer])));
|
|
68
68
|
export const funcCast = new Constant((value) => typeof value !== "number"
|
|
69
69
|
? Number(value)
|
|
70
70
|
: castToInteger(value), Type.union(Type.functionType(Type.Float, [Type.Integer]), Type.functionType(Type.Integer, [Type.Float])));
|
package/dst/constant/String.d.ts
CHANGED
|
@@ -8,12 +8,12 @@ export declare const isTimeSymbol: (c: string) => boolean;
|
|
|
8
8
|
export declare const isDateTimeSeparator: (c: string) => c is " " | "T" | "@";
|
|
9
9
|
export declare const isHexadecimal: (c: string) => boolean;
|
|
10
10
|
export declare const isCaseSpaceEtc: (c: string) => boolean;
|
|
11
|
-
export declare const replaceWith: (value
|
|
12
|
-
export declare const equateStrings: (value1
|
|
13
|
-
export declare const containsString: (value
|
|
14
|
-
export declare const startsWithString: (value
|
|
15
|
-
export declare const endsWithString: (value
|
|
16
|
-
export declare const encodeString: (value
|
|
11
|
+
export declare const replaceWith: (value?: string, replacement?: string, ...search: string[]) => string | undefined;
|
|
12
|
+
export declare const equateStrings: (value1?: string, value2?: string, ignoreCaseSpaceEtc?: boolean) => boolean;
|
|
13
|
+
export declare const containsString: (value?: string, search?: string, startPos?: number, ignoreCaseSpaceEtc?: boolean) => boolean;
|
|
14
|
+
export declare const startsWithString: (value?: string, search?: string, startPos?: number, ignoreCaseSpaceEtc?: boolean) => boolean;
|
|
15
|
+
export declare const endsWithString: (value?: string, search?: string, endPos?: number, ignoreCaseSpaceEtc?: boolean) => boolean;
|
|
16
|
+
export declare const encodeString: (value?: string, encoding?: "utf8" | "ucs2" | "ucs2le") => ArrayBufferLike;
|
|
17
17
|
export declare const funcLike: Constant;
|
|
18
18
|
export declare const funcUnlike: Constant;
|
|
19
19
|
export declare const funcStartsWith: Constant;
|
package/dst/constant/String.js
CHANGED
|
@@ -10,6 +10,9 @@ export const isDateTimeSeparator = (c) => c === "T" || c === " " || c === "@";
|
|
|
10
10
|
export const isHexadecimal = (c) => isNumeric(c) || c >= "a" && c <= "f" || c >= "A" && c <= "F";
|
|
11
11
|
export const isCaseSpaceEtc = (c) => (c < "a" || c > "z") && (c < "0" || c > "9");
|
|
12
12
|
export const replaceWith = (value, replacement, ...search) => {
|
|
13
|
+
if (value == null) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
13
16
|
let str = value;
|
|
14
17
|
for (const s of search) {
|
|
15
18
|
str = str.split(s).join(replacement ?? "");
|
|
@@ -17,6 +20,12 @@ export const replaceWith = (value, replacement, ...search) => {
|
|
|
17
20
|
return str;
|
|
18
21
|
};
|
|
19
22
|
export const equateStrings = (value1, value2, ignoreCaseSpaceEtc) => {
|
|
23
|
+
if (value1 == null && value2 == null) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (value1 == null || value2 == null) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
20
29
|
if (!ignoreCaseSpaceEtc) {
|
|
21
30
|
return value1 === value2;
|
|
22
31
|
}
|
|
@@ -36,6 +45,12 @@ export const equateStrings = (value1, value2, ignoreCaseSpaceEtc) => {
|
|
|
36
45
|
return true;
|
|
37
46
|
};
|
|
38
47
|
export const containsString = (value, search, startPos, ignoreCaseSpaceEtc) => {
|
|
48
|
+
if (value == null) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
if (search == null) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
39
54
|
if (!ignoreCaseSpaceEtc) {
|
|
40
55
|
return value.includes(search, startPos);
|
|
41
56
|
}
|
|
@@ -68,6 +83,12 @@ export const containsString = (value, search, startPos, ignoreCaseSpaceEtc) => {
|
|
|
68
83
|
return true;
|
|
69
84
|
};
|
|
70
85
|
export const startsWithString = (value, search, startPos, ignoreCaseSpaceEtc) => {
|
|
86
|
+
if (value == null) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (search == null) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
71
92
|
if (!ignoreCaseSpaceEtc) {
|
|
72
93
|
return value.startsWith(search, startPos);
|
|
73
94
|
}
|
|
@@ -91,6 +112,12 @@ export const startsWithString = (value, search, startPos, ignoreCaseSpaceEtc) =>
|
|
|
91
112
|
return true;
|
|
92
113
|
};
|
|
93
114
|
export const endsWithString = (value, search, endPos, ignoreCaseSpaceEtc) => {
|
|
115
|
+
if (value == null) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
if (search == null) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
94
121
|
if (!ignoreCaseSpaceEtc) {
|
|
95
122
|
return value.endsWith(search, endPos);
|
|
96
123
|
}
|
|
@@ -160,14 +187,17 @@ export const funcChar = new Constant((value, pos) => value == null
|
|
|
160
187
|
export const funcCharCode = new Constant((value, pos) => value == null
|
|
161
188
|
? undefined
|
|
162
189
|
: value.charCodeAt(pos < 0 ? value.length + Number(pos) : Number(pos)), Type.functionType(Type.OptionalInteger, [Type.String, Type.Float]));
|
|
163
|
-
export const funcTrim = new Constant((value) => value
|
|
164
|
-
export const funcTrimStart = new Constant((value) => value
|
|
165
|
-
export const funcTrimEnd = new Constant((value) => value
|
|
166
|
-
export const funcLowerCase = new Constant((value) => value
|
|
167
|
-
export const funcUpperCase = new Constant((value) => value
|
|
168
|
-
export const funcSplit = new Constant((value, separator = " ") => value
|
|
190
|
+
export const funcTrim = new Constant((value) => value?.trim(), typeStringMutator);
|
|
191
|
+
export const funcTrimStart = new Constant((value) => value?.trimStart(), typeStringMutator);
|
|
192
|
+
export const funcTrimEnd = new Constant((value) => value?.trimEnd(), typeStringMutator);
|
|
193
|
+
export const funcLowerCase = new Constant((value) => value?.toLowerCase(), typeStringMutator);
|
|
194
|
+
export const funcUpperCase = new Constant((value) => value?.toUpperCase(), typeStringMutator);
|
|
195
|
+
export const funcSplit = new Constant((value, separator = " ") => value?.split(separator) ?? [], Type.functionType(Type.arrayType([Type.String]), [Type.String, Type.OptionalString]));
|
|
169
196
|
export const funcReplaceWith = new Constant((value, replacement, ...search) => replaceWith(value, replacement, ...search.flat()), Type.functionType(Type.String, [Type.String, Type.String, typeStringOrArray], true));
|
|
170
197
|
const funcAlphanum = new Constant((value) => {
|
|
198
|
+
if (!value) {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
171
201
|
const lowerCase = value.toLowerCase();
|
|
172
202
|
let result = "";
|
|
173
203
|
for (let i = 0; i < lowerCase.length; ++i) {
|
|
@@ -179,10 +209,11 @@ const funcAlphanum = new Constant((value) => {
|
|
|
179
209
|
}, typeStringMutator);
|
|
180
210
|
const funcRandomString = new Constant((value) => {
|
|
181
211
|
let str = "";
|
|
182
|
-
|
|
212
|
+
const length = Number(value ?? 0);
|
|
213
|
+
while (str.length < length) {
|
|
183
214
|
str += Math.random().toString(36).slice(2);
|
|
184
215
|
}
|
|
185
|
-
return str.slice(0,
|
|
216
|
+
return str.slice(0, length);
|
|
186
217
|
}, Type.functionType(Type.String, [Type.Integer]), false);
|
|
187
218
|
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.Buffer, Type.OptionalString, Type.OptionalInteger, Type.OptionalInteger]));
|
|
188
219
|
export const constString = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Constant } from "../Constant.js";
|
|
2
|
-
export declare const encodeTimestamp: (value
|
|
3
|
-
export declare const decodeTimestamp: (value
|
|
4
|
-
export declare const formatTimestamp: (value
|
|
2
|
+
export declare const encodeTimestamp: (value?: Date, encoding?: "int64" | "int64le") => ArrayBuffer;
|
|
3
|
+
export declare const decodeTimestamp: (value?: ArrayBuffer, encoding?: "int64" | "int64le", byteOffset?: bigint) => Date | undefined;
|
|
4
|
+
export declare const formatTimestamp: (value?: Date, radix?: number) => string;
|
|
5
5
|
export declare const funcYear: Constant;
|
|
6
6
|
export declare const funcMonth: Constant;
|
|
7
7
|
export declare const funcMonthIndex: Constant;
|
|
@@ -5,11 +5,14 @@ const typeTimestampSince = Type.functionType(Type.Float, [Type.Timestamp, Type.T
|
|
|
5
5
|
export const encodeTimestamp = (value, encoding = "int64") => {
|
|
6
6
|
const buf = new ArrayBuffer(8);
|
|
7
7
|
const dv = new DataView(buf);
|
|
8
|
-
dv.setBigInt64(0, BigInt(value
|
|
8
|
+
dv.setBigInt64(0, BigInt(value?.getTime() ?? 0), encoding === "int64le");
|
|
9
9
|
return buf;
|
|
10
10
|
};
|
|
11
|
-
export const decodeTimestamp = (value, encoding = "int64", byteOffset) => new Date(Number(new DataView(value).getBigInt64(byteOffset == null ? 0 : Number(byteOffset), encoding === "int64le")));
|
|
11
|
+
export const decodeTimestamp = (value, encoding = "int64", byteOffset) => value ? new Date(Number(new DataView(value).getBigInt64(byteOffset == null ? 0 : Number(byteOffset), encoding === "int64le"))) : undefined;
|
|
12
12
|
export const formatTimestamp = (value, radix) => {
|
|
13
|
+
if (value == null) {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
13
16
|
const str = value.toISOString();
|
|
14
17
|
switch (radix) {
|
|
15
18
|
case 1: return str.slice(0, 4);
|
|
@@ -30,21 +33,21 @@ const parseTimestamp = (value) => {
|
|
|
30
33
|
return isNaN(date.getTime()) ? undefined : date;
|
|
31
34
|
};
|
|
32
35
|
const funcNow = new Constant(() => new Date(), Type.functionType(Type.Timestamp, []), false);
|
|
33
|
-
export const funcYear = new Constant((value, utc = false) => BigInt(utc ? value.getUTCFullYear() : value.getFullYear()), typeTimestampPart);
|
|
34
|
-
export const funcMonth = new Constant((value, utc = false) => BigInt(1 + (utc ? value.getUTCMonth() : value.getMonth())), typeTimestampPart);
|
|
35
|
-
export const funcMonthIndex = new Constant((value, utc = false) => BigInt(utc ? value.getUTCMonth() : value.getMonth()), typeTimestampPart);
|
|
36
|
-
export const funcWeekdayIndex = new Constant((value, utc = false) => BigInt(utc ? value.getUTCDay() : value.getDay()), typeTimestampPart);
|
|
37
|
-
export const funcDay = new Constant((value, utc = false) => BigInt(utc ? value.getUTCDate() : value.getDate()), typeTimestampPart);
|
|
38
|
-
export const funcHour = new Constant((value, utc = false) => BigInt(utc ? value.getUTCHours() : value.getHours()), typeTimestampPart);
|
|
39
|
-
export const funcMinute = new Constant((value, utc = false) => BigInt(utc ? value.getUTCMinutes() : value.getMinutes()), typeTimestampPart);
|
|
40
|
-
export const funcSecond = new Constant((value, utc = false) => BigInt(utc ? value.getUTCSeconds() : value.getSeconds()), typeTimestampPart);
|
|
41
|
-
export const funcMillisecond = new Constant((value, utc = false) => BigInt(utc ? value.getUTCMilliseconds() : value.getMilliseconds()), typeTimestampPart);
|
|
42
|
-
export const funcEpochTime = new Constant((value, epoch = new Date(0)) => BigInt.asIntN(64, BigInt(value.getTime() - epoch.getTime())), Type.functionType(Type.Integer, [Type.Timestamp, Type.OptionalTimestamp]));
|
|
43
|
-
export const funcDaysSince = new Constant((value1, value2) => (value1
|
|
44
|
-
export const funcHoursSince = new Constant((value1, value2) => (value1
|
|
45
|
-
export const funcMinutesSince = new Constant((value1, value2) => (value1
|
|
46
|
-
export const funcSecondsSince = new Constant((value1, value2) => (value1
|
|
47
|
-
const funcEpochTimestamp = new Constant((value, epoch = new Date(0)) => new Date(Number(value) + epoch
|
|
36
|
+
export const funcYear = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCFullYear() : value.getFullYear()) : undefined, typeTimestampPart);
|
|
37
|
+
export const funcMonth = new Constant((value, utc = false) => value ? BigInt(1 + (utc ? value.getUTCMonth() : value.getMonth())) : undefined, typeTimestampPart);
|
|
38
|
+
export const funcMonthIndex = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCMonth() : value.getMonth()) : undefined, typeTimestampPart);
|
|
39
|
+
export const funcWeekdayIndex = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCDay() : value.getDay()) : undefined, typeTimestampPart);
|
|
40
|
+
export const funcDay = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCDate() : value.getDate()) : undefined, typeTimestampPart);
|
|
41
|
+
export const funcHour = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCHours() : value.getHours()) : undefined, typeTimestampPart);
|
|
42
|
+
export const funcMinute = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCMinutes() : value.getMinutes()) : undefined, typeTimestampPart);
|
|
43
|
+
export const funcSecond = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCSeconds() : value.getSeconds()) : undefined, typeTimestampPart);
|
|
44
|
+
export const funcMillisecond = new Constant((value, utc = false) => value ? BigInt(utc ? value.getUTCMilliseconds() : value.getMilliseconds()) : undefined, typeTimestampPart);
|
|
45
|
+
export const funcEpochTime = new Constant((value, epoch = new Date(0)) => value ? BigInt.asIntN(64, BigInt(value.getTime() - epoch.getTime())) : undefined, Type.functionType(Type.Integer, [Type.Timestamp, Type.OptionalTimestamp]));
|
|
46
|
+
export const funcDaysSince = new Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 86400000.0, typeTimestampSince);
|
|
47
|
+
export const funcHoursSince = new Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 3600000.0, typeTimestampSince);
|
|
48
|
+
export const funcMinutesSince = new Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 60000.0, typeTimestampSince);
|
|
49
|
+
export const funcSecondsSince = new Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 1000.0, typeTimestampSince);
|
|
50
|
+
const funcEpochTimestamp = new Constant((value, epoch = new Date(0)) => new Date(Number(value ?? 0) + epoch?.getTime()), Type.functionType(Type.Timestamp, [Type.Number, Type.OptionalTimestamp]));
|
|
48
51
|
const funcDecodeTimestamp = new Constant((value, encoding = "int64", byteOffset) => decodeTimestamp(value, encoding, byteOffset), Type.functionType(Type.OptionalTimestamp, [Type.Buffer, Type.OptionalString, Type.OptionalInteger]));
|
|
49
52
|
const funcParseTimestamp = new Constant((value) => parseTimestamp(value), Type.functionType(Type.OptionalTimestamp, [Type.String]));
|
|
50
53
|
export const constTimestamp = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "affinirum",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Affinirum Scripting Language",
|
|
5
5
|
"main": "dst/cjs/index.js",
|
|
6
6
|
"module": "dst/index.js",
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/jasmine": "~5.1.8",
|
|
60
60
|
"copyfiles": "~2.4.1",
|
|
61
|
-
"eslint": "~9.
|
|
61
|
+
"eslint": "~9.33.0",
|
|
62
62
|
"jasmine": "~5.9.0",
|
|
63
63
|
"rimraf": "~6.0.1",
|
|
64
64
|
"typescript": "~5.8.3",
|
|
65
|
-
"typescript-eslint": "~8.
|
|
65
|
+
"typescript-eslint": "~8.39.1"
|
|
66
66
|
}
|
|
67
67
|
}
|