affinirum 1.4.0 → 1.4.1
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/README.md +66 -48
- package/dst/Constants.js +2 -0
- package/dst/atom/FunctionAtom.js +1 -1
- package/dst/cjs/Constants.js +2 -0
- package/dst/cjs/atom/FunctionAtom.js +1 -1
- package/dst/cjs/native/Boolean.js +5 -2
- package/dst/cjs/native/Buffer.js +43 -11
- package/dst/cjs/native/Float.js +2 -5
- package/dst/cjs/native/Integer.js +8 -5
- package/dst/cjs/native/String.js +32 -15
- package/dst/cjs/native/Timestamp.js +25 -11
- package/dst/cjs/native/Unknown.js +10 -10
- package/dst/cjs/native/notation/AN.js +4 -4
- package/dst/cjs/native/notation/IP.js +239 -0
- package/dst/cjs/native/notation/JSON.js +3 -3
- package/dst/native/Boolean.js +5 -2
- package/dst/native/Buffer.d.ts +3 -1
- package/dst/native/Buffer.js +41 -10
- package/dst/native/Float.d.ts +1 -1
- package/dst/native/Float.js +2 -5
- package/dst/native/Integer.d.ts +1 -1
- package/dst/native/Integer.js +8 -5
- package/dst/native/String.d.ts +2 -2
- package/dst/native/String.js +32 -15
- package/dst/native/Timestamp.d.ts +3 -3
- package/dst/native/Timestamp.js +25 -11
- package/dst/native/Unknown.js +11 -11
- package/dst/native/notation/AN.js +4 -4
- package/dst/native/notation/IP.d.ts +6 -0
- package/dst/native/notation/IP.js +236 -0
- package/dst/native/notation/JSON.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -129,71 +129,85 @@ Whitespace characters are ignored.
|
|
|
129
129
|
|
|
130
130
|
### Native Global Functions
|
|
131
131
|
|
|
132
|
+
Native conversions use the following null handling:
|
|
133
|
+
|
|
134
|
+
- `Format` returns an empty string for a **null**.
|
|
135
|
+
- `Encode` returns a zero-length buffer for a **null**.
|
|
136
|
+
- `Decode` and `Parse` return **null** when their input value is **null**.
|
|
137
|
+
|
|
138
|
+
Empty strings and zero-length buffers remain ordinary values; they are not serialized null markers.
|
|
139
|
+
Invalid non-null inputs are function-specific and may raise an evaluation error.
|
|
140
|
+
|
|
132
141
|
#### Boolean
|
|
133
|
-
- **Boolean.Or(values
|
|
134
|
-
- **Boolean.And(values: ...array):boolean** — Boolean conjunction
|
|
142
|
+
- **Boolean.Or(values: ...(boolean | array)):boolean** — Boolean disjunction of booleans and arrays of booleans
|
|
143
|
+
- **Boolean.And(values: ...(boolean | array)):boolean** — Boolean conjunction of booleans and arrays of booleans
|
|
135
144
|
- **Boolean.Not(value: boolean):boolean** — Boolean negation
|
|
136
|
-
- **Boolean.Decode(value: buffer
|
|
137
|
-
- **Boolean.Parse():boolean?** — Parse
|
|
145
|
+
- **Boolean.Decode(value: buffer?, offset: integer?):boolean?** — Decode a byte at the optional offset; missing or out-of-range input returns **void**
|
|
146
|
+
- **Boolean.Parse(value: string?):boolean?** — Parse case-insensitive `true` or `false`; other values return **void**
|
|
138
147
|
|
|
139
148
|
#### Timestamp
|
|
140
149
|
- **Timestamp.Now():timestamp** — Current date and time
|
|
141
150
|
- **Timestamp.Epoch(value: float | integer, epoch: timestamp?):timestamp** — Create timestamp from milliseconds
|
|
142
|
-
- **Timestamp.Decode(value: buffer
|
|
143
|
-
- **Timestamp.Parse(value: string):timestamp?** — Parse string
|
|
151
|
+
- **Timestamp.Decode(value: buffer?, encoding: string?, offset: integer?):timestamp?** — Decode a timestamp using `i64` (default) or `i64le`
|
|
152
|
+
- **Timestamp.Parse(value: string?):timestamp?** — Parse a string as a timestamp
|
|
144
153
|
|
|
145
154
|
#### Float
|
|
146
155
|
- **Float.NAN** — Not-a-number
|
|
147
156
|
- **Float.PositiveInfinity** — Positive infinity
|
|
148
157
|
- **Float.NegativeInfinity** — Negative infinity
|
|
149
158
|
- **Float.Epsilon** — Smallest positive float
|
|
150
|
-
- **Float.Sum(values: ...array):float** — Numeric sum
|
|
151
|
-
- **Float.Min(values: ...array):float** — Numeric minimum
|
|
152
|
-
- **Float.Max(values: ...array):float** — Numeric maximum
|
|
153
|
-
- **Float.Exponent():float** —
|
|
154
|
-
- **Float.Logarithm():float** —
|
|
155
|
-
- **Float.Abs():float** — Absolute value
|
|
156
|
-
- **Float.Ceil():float** —
|
|
157
|
-
- **Float.Floor():float** —
|
|
158
|
-
- **Float.Round():float** — Rounded value
|
|
159
|
-
- **Float.Truncate():float** —
|
|
159
|
+
- **Float.Sum(values: ...(float | array)):float** — Numeric sum
|
|
160
|
+
- **Float.Min(values: ...(float | array)):float** — Numeric minimum
|
|
161
|
+
- **Float.Max(values: ...(float | array)):float** — Numeric maximum
|
|
162
|
+
- **Float.Exponent(value: float):float** — Natural exponential
|
|
163
|
+
- **Float.Logarithm(value: float):float** — Natural logarithm
|
|
164
|
+
- **Float.Abs(value: float):float** — Absolute value
|
|
165
|
+
- **Float.Ceil(value: float):float** — Smallest integer greater than or equal to the value
|
|
166
|
+
- **Float.Floor(value: float):float** — Largest integer less than or equal to the value
|
|
167
|
+
- **Float.Round(value: float):float** — Rounded value
|
|
168
|
+
- **Float.Truncate(value: float):float** — Integer portion of the value
|
|
160
169
|
- **Float.Random(exclusiveTo: float):float** — Random float up to value
|
|
161
|
-
- **Float.Decode(value: buffer
|
|
162
|
-
- **Float.Parse(value: string):float?** — Parse
|
|
170
|
+
- **Float.Decode(value: buffer?, encoding: string?, offset: integer?):float?** — Decode using `f64` (default), `f64le`, `f32`, or `f32le`
|
|
171
|
+
- **Float.Parse(value: string?):float?** — Parse a string as a float
|
|
163
172
|
|
|
164
173
|
#### Integer
|
|
165
|
-
- **Integer.Sum(values: ...array):integer** — Numeric sum
|
|
166
|
-
- **Integer.Min(values: ...array):integer** — Numeric minimum
|
|
167
|
-
- **Integer.Max(values: ...array):integer** — Numeric maximum
|
|
174
|
+
- **Integer.Sum(values: ...(integer | array)):integer** — Numeric sum
|
|
175
|
+
- **Integer.Min(values: ...(integer | array)):integer** — Numeric minimum
|
|
176
|
+
- **Integer.Max(values: ...(integer | array)):integer** — Numeric maximum
|
|
168
177
|
- **Integer.Random(exclusiveTo: integer):integer** — Random integer up to value
|
|
169
|
-
- **Integer.Decode(value: buffer
|
|
170
|
-
- **Integer.Parse(value: string):integer?** — Parse
|
|
178
|
+
- **Integer.Decode(value: buffer?, encoding: string?, offset: integer?):integer?** — Decode using signed `i8`, `i16`, `i16le`, `i32`, `i32le`, `i64` (default), or `i64le`, or unsigned `n8`, `n16`, `n16le`, `n32`, `n32le`, `n64`, or `n64le`
|
|
179
|
+
- **Integer.Parse(value: string?):integer?** — Parse a string as an integer
|
|
171
180
|
|
|
172
181
|
#### String
|
|
182
|
+
- **String.Alphanum(value: string):string** — Keep only ASCII letters and digits
|
|
173
183
|
- **String.Random(length: integer):string** — Random alphanumeric string
|
|
174
|
-
- **String.Decode(value: buffer
|
|
184
|
+
- **String.Decode(value: buffer?, encoding: string?, offset: integer?, length: integer?):string?** — Decode using `utf8` (default), `sbcs`, `ucs2`, or `ucs2le`
|
|
175
185
|
|
|
176
186
|
#### Buffer
|
|
177
187
|
- **Buffer.Random(length: integer):buffer** — Buffer of given length filled with random bytes
|
|
178
|
-
- **Buffer.Parse(value: string):buffer?** — Parse
|
|
188
|
+
- **Buffer.Parse(value: string?):buffer?** — Parse a hexadecimal string as a buffer
|
|
179
189
|
|
|
180
190
|
#### Array
|
|
181
191
|
- **Array.Join(values: ...array):array** — Join arrays of any depths into a single array
|
|
182
192
|
- **Array.Range(inclusiveFrom: integer, exclusiveTo: integer):array** — New array filled with integers in range
|
|
183
|
-
- **Array.Unique():array** — Array of unique values
|
|
193
|
+
- **Array.Unique(value: array):array** — Array of unique values
|
|
184
194
|
- **Array.Intersection(a1: array, a2: array):array** — Common values from two arrays
|
|
185
195
|
- **Array.Difference(a1: array, a2: array):array** — Symmetrical difference between arrays
|
|
186
196
|
|
|
187
197
|
#### Object
|
|
188
|
-
- **Object.Merge(values: ...array):object** — Merge
|
|
198
|
+
- **Object.Merge(values: ...(object | array)):object** — Merge objects and arrays of objects
|
|
189
199
|
|
|
190
200
|
#### AN
|
|
191
|
-
- **AN.Format(value: ??, whitespace: string?):string** — Format
|
|
201
|
+
- **AN.Format(value: ??, whitespace: string?):string** — Format a value as AN notation
|
|
192
202
|
|
|
193
203
|
#### JSON
|
|
194
|
-
- **JSON.Format(value: (void | boolean | float | string | array | object), whitespace: string?):string** — Format as JSON
|
|
195
|
-
- **JSON.Parse(value: string):(void | boolean | float | string | array | object)** — Parse JSON-formatted string
|
|
204
|
+
- **JSON.Format(value: (void | boolean | timestamp | float | integer | string | array | object), whitespace: string?):string** — Format a value as JSON
|
|
205
|
+
- **JSON.Parse(value: string?):(void | boolean | timestamp | float | integer | string | array | object)** — Parse a JSON-formatted string; standard JSON values are not revived as timestamps or integers
|
|
196
206
|
|
|
207
|
+
#### IP
|
|
208
|
+
- **IP.Match(values: array, search: ...(string | array)):boolean** — Check whether any searched IPv4 or IPv6 address belongs to the supplied addresses or CIDR ranges
|
|
209
|
+
- **IP.Encode(value: string?):buffer** — Encode an IPv4, IPv6, or CIDR string as a network-byte-order buffer; malformed or **void** input returns a zero-length buffer
|
|
210
|
+
- **IP.Decode(value: buffer?):string?** — Decode a 4-, 5-, 16-, or 17-byte buffer as canonical IPv4, IPv6, or CIDR notation; malformed or **void** input returns **void**
|
|
197
211
|
|
|
198
212
|
### Native Method Functions
|
|
199
213
|
|
|
@@ -202,36 +216,36 @@ Whitespace characters are ignored.
|
|
|
202
216
|
- **??.Equal(value: ??):boolean** — Equals to
|
|
203
217
|
- **??.Unequal(value: ??):boolean** — Not equals to
|
|
204
218
|
- **(boolean | buffer | function).Encode():buffer** — Encode value to buffer
|
|
205
|
-
- **(timestamp | float | integer | string | array | object).Encode(encoding: string?):buffer** — Encode value
|
|
219
|
+
- **(void | timestamp | float | integer | string | array | object).Encode(encoding: string?):buffer** — Encode a value; defaults are `i64` for timestamps and integers, `f64` for floats, and `utf8` for strings
|
|
206
220
|
- **(boolean | string | function).Format():string** — Format value to string
|
|
207
|
-
- **(timestamp | float | integer | buffer | array | object).Format(formatting: string?):string** — Format value
|
|
221
|
+
- **(void | timestamp | float | integer | buffer | array | object).Format(formatting: string?):string** — Format a value; buffers use `hex` by default and also support `base64`
|
|
208
222
|
|
|
209
223
|
#### Aggregable Functions
|
|
210
|
-
- **float.Add(
|
|
211
|
-
- **integer.Add(
|
|
212
|
-
- **
|
|
213
|
-
- **
|
|
214
|
-
- **
|
|
224
|
+
- **float.Add(value: integer):float** — Add an integer
|
|
225
|
+
- **integer.Add(value: float):float** — Add a float
|
|
226
|
+
- **integer.Add(value: integer):integer** — Add an integer
|
|
227
|
+
- **buffer.Add(value: buffer):buffer** — Concatenate buffers
|
|
228
|
+
- **string.Add(value: string):string** — Concatenate strings
|
|
229
|
+
- **array.Add(value: array):array** — Concatenate arrays
|
|
215
230
|
|
|
216
231
|
#### Array Functions
|
|
217
232
|
- **array.First(condition: function):??** — First item satisfying condition
|
|
218
233
|
- **array.Last(condition: function):??** — Last item satisfying condition
|
|
219
|
-
- **array.FirstIndex(condition: function):integer
|
|
220
|
-
- **array.LastIndex(condition: function):integer
|
|
234
|
+
- **array.FirstIndex(condition: function):integer?** — First index satisfying condition, or **void** if none does
|
|
235
|
+
- **array.LastIndex(condition: function):integer?** — Last index satisfying condition, or **void** if none does
|
|
221
236
|
- **array.Every(condition: function):boolean** — All items satisfy condition
|
|
222
237
|
- **array.Any(condition: function):boolean** — Any item satisfies condition
|
|
223
238
|
- **array.Reverse():array** — Reversed array
|
|
224
239
|
- **array.Flatten(depth: integer = 1):array** — Flatten array
|
|
225
240
|
- **array.Derive(transformation: function):array** — Derived array
|
|
226
241
|
- **array.Filter(condition: function):array** — Filtered array
|
|
227
|
-
- **array.Reduce(reducer: function):??** — Reduced value
|
|
242
|
+
- **array.Reduce(reducer: function, initial: ?? = void):??** — Reduced value
|
|
228
243
|
- **array.Compose(generator: function):object** — Compose object from array
|
|
229
|
-
- **array.Prepend(items:
|
|
230
|
-
- **array.Append(items:
|
|
244
|
+
- **array.Prepend(items: ...??):array** — Prepend items
|
|
245
|
+
- **array.Append(items: ...??):array** — Append items
|
|
231
246
|
|
|
232
247
|
#### Buffer Functions
|
|
233
|
-
- **buffer.Byte(pos: integer):buffer
|
|
234
|
-
- **Buffer.FormatBuffer(value: buffer):string** — Hexadecimal string from buffer
|
|
248
|
+
- **buffer.Byte(pos: integer):buffer?** — Byte at position, or **void** when unavailable
|
|
235
249
|
|
|
236
250
|
#### Enumerable Functions
|
|
237
251
|
- **buffer.Slice(start: integer?, end: integer?):buffer** — Slice section
|
|
@@ -264,8 +278,9 @@ Whitespace characters are ignored.
|
|
|
264
278
|
- **integer.Subtract(subtrahend):integer** — Subtract value
|
|
265
279
|
- **float.Negate():float** — Negate number
|
|
266
280
|
- **integer.Negate():integer** — Negate number
|
|
267
|
-
- **float.Multiply(
|
|
268
|
-
- **integer.Multiply(
|
|
281
|
+
- **float.Multiply(value: integer):float** — Multiply by an integer
|
|
282
|
+
- **integer.Multiply(value: float):float** — Multiply by a float
|
|
283
|
+
- **integer.Multiply(value: integer):integer** — Multiply by an integer
|
|
269
284
|
- **float.Divide(divisor):float** — Divide value
|
|
270
285
|
- **integer.Divide(divisor):integer** — Divide value
|
|
271
286
|
- **float.Remainder(divisor):float** — Remainder
|
|
@@ -293,14 +308,13 @@ Whitespace characters are ignored.
|
|
|
293
308
|
- **string.EndsWith(search: string, endPos: integer?, ignoreCaseSpaceEtc: boolean?):boolean** — Suffix check
|
|
294
309
|
- **string.Char(pos: integer):string** — Character at position
|
|
295
310
|
- **string.CharCode(pos: integer):integer** — Character code
|
|
296
|
-
- **string.Alphanum():string** — Alphanumeric digest
|
|
297
311
|
- **string.Trim():string** — Trim whitespace
|
|
298
312
|
- **string.TrimStart():string** — Trim leading whitespace
|
|
299
313
|
- **string.TrimEnd():string** — Trim trailing whitespace
|
|
300
314
|
- **string.LowerCase():string** — To lowercase
|
|
301
315
|
- **string.UpperCase():string** — To uppercase
|
|
302
316
|
- **string.Split(separator: string = ' '):array** — Split into array
|
|
303
|
-
- **string.ReplaceWith(replacement: string, search: ...array):string** — Replace all instances of
|
|
317
|
+
- **string.ReplaceWith(replacement: string, search: ...(string | array)):string** — Replace all instances of the searched strings
|
|
304
318
|
|
|
305
319
|
#### Timestamp Functions
|
|
306
320
|
- **timestamp.Year(utc: boolean?):integer** — Get year
|
|
@@ -313,6 +327,10 @@ Whitespace characters are ignored.
|
|
|
313
327
|
- **timestamp.Second(utc: boolean?):integer** — Second
|
|
314
328
|
- **timestamp.Millisecond(utc: boolean?):integer** — Millisecond
|
|
315
329
|
- **timestamp.EpochTime(epoch: timestamp?):integer** — Milliseconds since epoch or 1970-01-01 00:00:00 UTC
|
|
330
|
+
- **timestamp.DaysSince(value: timestamp):float** — Difference from another timestamp in days
|
|
331
|
+
- **timestamp.HoursSince(value: timestamp):float** — Difference from another timestamp in hours
|
|
332
|
+
- **timestamp.MinutesSince(value: timestamp):float** — Difference from another timestamp in minutes
|
|
333
|
+
- **timestamp.SecondsSince(value: timestamp):float** — Difference from another timestamp in seconds
|
|
316
334
|
|
|
317
335
|
## Reference
|
|
318
336
|
|
package/dst/Constants.js
CHANGED
|
@@ -7,6 +7,7 @@ import { constObject } from "./native/Object.js";
|
|
|
7
7
|
import { constString } from "./native/String.js";
|
|
8
8
|
import { constTimestamp } from "./native/Timestamp.js";
|
|
9
9
|
import { constAN } from "./native/notation/AN.js";
|
|
10
|
+
import { constIP } from "./native/notation/IP.js";
|
|
10
11
|
import { constJSON } from "./native/notation/JSON.js";
|
|
11
12
|
export const Constants = [
|
|
12
13
|
["Array", constArray],
|
|
@@ -18,5 +19,6 @@ export const Constants = [
|
|
|
18
19
|
["String", constString],
|
|
19
20
|
["Timestamp", constTimestamp],
|
|
20
21
|
["AN", constAN],
|
|
22
|
+
["IP", constIP],
|
|
21
23
|
["JSON", constJSON],
|
|
22
24
|
];
|
package/dst/atom/FunctionAtom.js
CHANGED
package/dst/cjs/Constants.js
CHANGED
|
@@ -10,6 +10,7 @@ const Object_js_1 = require("./native/Object.js");
|
|
|
10
10
|
const String_js_1 = require("./native/String.js");
|
|
11
11
|
const Timestamp_js_1 = require("./native/Timestamp.js");
|
|
12
12
|
const AN_js_1 = require("./native/notation/AN.js");
|
|
13
|
+
const IP_js_1 = require("./native/notation/IP.js");
|
|
13
14
|
const JSON_js_1 = require("./native/notation/JSON.js");
|
|
14
15
|
exports.Constants = [
|
|
15
16
|
["Array", Array_js_1.constArray],
|
|
@@ -21,5 +22,6 @@ exports.Constants = [
|
|
|
21
22
|
["String", String_js_1.constString],
|
|
22
23
|
["Timestamp", Timestamp_js_1.constTimestamp],
|
|
23
24
|
["AN", AN_js_1.constAN],
|
|
25
|
+
["IP", IP_js_1.constIP],
|
|
24
26
|
["JSON", JSON_js_1.constJSON],
|
|
25
27
|
];
|
|
@@ -8,14 +8,17 @@ 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) =>
|
|
11
|
+
const funcDecodeBoolean = new Constant_js_1.Constant((value, byteOffset) => {
|
|
12
|
+
const offset = byteOffset == null ? 0 : Number(byteOffset);
|
|
13
|
+
return value && offset >= 0 && value.byteLength > offset ? Boolean(new Uint8Array(value)[offset]) : undefined;
|
|
14
|
+
}, Type_js_1.Type.functionType(Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.OptionalBuffer, Type_js_1.Type.OptionalInteger]));
|
|
12
15
|
const funcParseBoolean = new Constant_js_1.Constant((value) => {
|
|
13
16
|
if (value == null) {
|
|
14
17
|
return undefined;
|
|
15
18
|
}
|
|
16
19
|
const v = value.toLowerCase();
|
|
17
20
|
return v === "true" ? true : v === "false" ? false : undefined;
|
|
18
|
-
}, Type_js_1.Type.functionType(Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.
|
|
21
|
+
}, Type_js_1.Type.functionType(Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.OptionalString]));
|
|
19
22
|
exports.constBoolean = {
|
|
20
23
|
Or: exports.funcOr,
|
|
21
24
|
And: exports.funcAnd,
|
package/dst/cjs/native/Buffer.js
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.constBuffer = exports.funcByte = exports.parseBuffer = exports.formatBuffer = exports.concatBuffers = exports.containsBuffer = exports.equateBuffers = void 0;
|
|
3
|
+
exports.constBuffer = exports.funcByte = exports.parseBuffer = exports.formatBuffer = exports.concatBuffers = exports.containsBuffer = exports.equateBuffers = exports.parseBoundedInteger = exports.EmptyBuffer = void 0;
|
|
4
4
|
const Constant_js_1 = require("../Constant.js");
|
|
5
5
|
const Type_js_1 = require("../Type.js");
|
|
6
|
+
exports.EmptyBuffer = new ArrayBuffer(0);
|
|
7
|
+
const ZERO = "0".charCodeAt(0), NINE = "9".charCodeAt(0);
|
|
8
|
+
const UPPER_A = "A".charCodeAt(0), UPPER_F = "F".charCodeAt(0);
|
|
9
|
+
const LOWER_A = "a".charCodeAt(0), LOWER_F = "f".charCodeAt(0);
|
|
10
|
+
const parseBoundedInteger = (input, base, min, max) => {
|
|
11
|
+
if (input.length === 0) {
|
|
12
|
+
throw new Error(`Invalid IP component: ${input}`);
|
|
13
|
+
}
|
|
14
|
+
let value = 0;
|
|
15
|
+
for (let i = 0; i < input.length; i++) {
|
|
16
|
+
const code = input.charCodeAt(i);
|
|
17
|
+
let digit;
|
|
18
|
+
if (code >= ZERO && code <= NINE) {
|
|
19
|
+
digit = code - ZERO;
|
|
20
|
+
}
|
|
21
|
+
else if (base === 16 && code >= UPPER_A && code <= UPPER_F) {
|
|
22
|
+
digit = code - UPPER_A + 10;
|
|
23
|
+
}
|
|
24
|
+
else if (base === 16 && code >= LOWER_A && code <= LOWER_F) {
|
|
25
|
+
digit = code - LOWER_A + 10;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw new Error(`Invalid IP component: ${input}`);
|
|
29
|
+
}
|
|
30
|
+
value = value * base + digit;
|
|
31
|
+
}
|
|
32
|
+
if (value < min || value > max) {
|
|
33
|
+
throw new Error(`Invalid IP component: ${input}`);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
};
|
|
37
|
+
exports.parseBoundedInteger = parseBoundedInteger;
|
|
6
38
|
const equateBuffers = (value1, value2) => {
|
|
7
39
|
if (value1.byteLength !== value2.byteLength) {
|
|
8
40
|
return false;
|
|
@@ -73,9 +105,6 @@ const concatBuffers = (value1, value2) => {
|
|
|
73
105
|
};
|
|
74
106
|
exports.concatBuffers = concatBuffers;
|
|
75
107
|
const formatBuffer = (value, formatting = "hex") => {
|
|
76
|
-
if (value == null) {
|
|
77
|
-
return "";
|
|
78
|
-
}
|
|
79
108
|
if (formatting === "base64") {
|
|
80
109
|
let binary = "";
|
|
81
110
|
const bytes = new Uint8Array(value);
|
|
@@ -86,12 +115,15 @@ const formatBuffer = (value, formatting = "hex") => {
|
|
|
86
115
|
}
|
|
87
116
|
return btoa(binary);
|
|
88
117
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
118
|
+
else if (formatting === "hex") {
|
|
119
|
+
const bytes = new Uint8Array(value);
|
|
120
|
+
let str = "";
|
|
121
|
+
for (let i = 0; i < bytes.byteLength; ++i) {
|
|
122
|
+
str += bytes[i].toString(16).padStart(2, "0");
|
|
123
|
+
}
|
|
124
|
+
return str;
|
|
93
125
|
}
|
|
94
|
-
|
|
126
|
+
throw new Error(`${formatting} formatting not supported`);
|
|
95
127
|
};
|
|
96
128
|
exports.formatBuffer = formatBuffer;
|
|
97
129
|
const parseBuffer = (value) => {
|
|
@@ -100,7 +132,7 @@ const parseBuffer = (value) => {
|
|
|
100
132
|
}
|
|
101
133
|
const bytes = new Uint8Array(Math.ceil(value.length / 2));
|
|
102
134
|
for (let i = 0, c = 0; c < value.length; ++i) {
|
|
103
|
-
bytes[i] =
|
|
135
|
+
bytes[i] = (0, exports.parseBoundedInteger)(value.slice(c, c += 2), 16, 0, 0xff);
|
|
104
136
|
}
|
|
105
137
|
return bytes.buffer;
|
|
106
138
|
};
|
|
@@ -109,7 +141,7 @@ exports.funcByte = new Constant_js_1.Constant((value, pos) => value == null
|
|
|
109
141
|
? undefined
|
|
110
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]));
|
|
111
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);
|
|
112
|
-
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.
|
|
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]));
|
|
113
145
|
exports.constBuffer = {
|
|
114
146
|
Random: funcRandomBuffer,
|
|
115
147
|
Parse: funcParseBuffer,
|
package/dst/cjs/native/Float.js
CHANGED
|
@@ -4,9 +4,6 @@ exports.constFloat = exports.encodeFloat = void 0;
|
|
|
4
4
|
const Constant_js_1 = require("../Constant.js");
|
|
5
5
|
const Type_js_1 = require("../Type.js");
|
|
6
6
|
const encodeFloat = (value, encoding = "f64") => {
|
|
7
|
-
if (value == null) {
|
|
8
|
-
return new Uint8Array(0).buffer;
|
|
9
|
-
}
|
|
10
7
|
let bits = "";
|
|
11
8
|
for (let i = 0; i < encoding.length; ++i) {
|
|
12
9
|
const c = encoding[i];
|
|
@@ -60,8 +57,8 @@ const funcFloor = new Constant_js_1.Constant((value) => Math.floor(Number(value)
|
|
|
60
57
|
const funcRound = new Constant_js_1.Constant((value) => Math.round(Number(value)), typeTransform);
|
|
61
58
|
const funcTruncate = new Constant_js_1.Constant((value) => Math.trunc(Number(value)), typeTransform);
|
|
62
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);
|
|
63
|
-
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.
|
|
64
|
-
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.
|
|
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
|
+
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]));
|
|
65
62
|
exports.constFloat = {
|
|
66
63
|
NAN: new Constant_js_1.Constant(Number.NaN),
|
|
67
64
|
PositiveInfinity: new Constant_js_1.Constant(Number.POSITIVE_INFINITY),
|
|
@@ -4,9 +4,6 @@ exports.constInteger = exports.encodeInteger = void 0;
|
|
|
4
4
|
const Constant_js_1 = require("../Constant.js");
|
|
5
5
|
const Type_js_1 = require("../Type.js");
|
|
6
6
|
const encodeInteger = (value, encoding = "i64") => {
|
|
7
|
-
if (value == null) {
|
|
8
|
-
return new Uint8Array(0).buffer;
|
|
9
|
-
}
|
|
10
7
|
let bits = "";
|
|
11
8
|
for (let i = 0; i < encoding.length; ++i) {
|
|
12
9
|
const c = encoding[i];
|
|
@@ -92,8 +89,14 @@ const funcSum = new Constant_js_1.Constant((...values) => BigInt.asIntN(64, valu
|
|
|
92
89
|
const funcMin = new Constant_js_1.Constant((...values) => BigInt.asIntN(64, values.flat().reduce((min, val) => val < min ? val : min)), typeAggregator);
|
|
93
90
|
const funcMax = new Constant_js_1.Constant((...values) => BigInt.asIntN(64, values.flat().reduce((max, val) => val > max ? val : max)), typeAggregator);
|
|
94
91
|
const funcRandomInteger = new Constant_js_1.Constant((value) => value == null ? undefined : BigInt.asIntN(64, BigInt(Math.floor(Math.random() * Number(value)))), Type_js_1.Type.functionType(Type_js_1.Type.Integer, [Type_js_1.Type.Integer]), false);
|
|
95
|
-
const funcDecodeInteger = new Constant_js_1.Constant((value, encoding = "i64", byteOffset) => decodeInteger(value, encoding, byteOffset == null ? undefined : Number(byteOffset)), Type_js_1.Type.functionType(Type_js_1.Type.OptionalInteger, [Type_js_1.Type.
|
|
96
|
-
const funcParseInteger = new Constant_js_1.Constant((value) =>
|
|
92
|
+
const funcDecodeInteger = new Constant_js_1.Constant((value, encoding = "i64", byteOffset) => decodeInteger(value, encoding, byteOffset == null ? undefined : Number(byteOffset)), Type_js_1.Type.functionType(Type_js_1.Type.OptionalInteger, [Type_js_1.Type.OptionalBuffer, Type_js_1.Type.OptionalString, Type_js_1.Type.OptionalInteger]));
|
|
93
|
+
const funcParseInteger = new Constant_js_1.Constant((value) => {
|
|
94
|
+
try {
|
|
95
|
+
return value ? BigInt.asIntN(64, BigInt(value)) : undefined;
|
|
96
|
+
}
|
|
97
|
+
catch { }
|
|
98
|
+
return undefined;
|
|
99
|
+
}, Type_js_1.Type.functionType(Type_js_1.Type.OptionalInteger, [Type_js_1.Type.OptionalString]));
|
|
97
100
|
exports.constInteger = {
|
|
98
101
|
Sum: funcSum,
|
|
99
102
|
Min: funcMin,
|
package/dst/cjs/native/String.js
CHANGED
|
@@ -162,16 +162,24 @@ const endsWithString = (value, search, endPos, ignoreCaseSpaceEtc) => {
|
|
|
162
162
|
};
|
|
163
163
|
exports.endsWithString = endsWithString;
|
|
164
164
|
const encodeString = (value, encoding = "utf8") => {
|
|
165
|
-
|
|
166
|
-
return new
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
switch (encoding) {
|
|
166
|
+
case "utf8": return new TextEncoder().encode(value).buffer;
|
|
167
|
+
case "sbcs": break;
|
|
168
|
+
case "ucs2": break;
|
|
169
|
+
case "ucs2le": break;
|
|
170
|
+
default: throw new Error(`${encoding} encoding not supported`);
|
|
171
|
+
}
|
|
172
|
+
if (encoding === "sbcs") {
|
|
173
|
+
const dv = new Uint8Array(value.length);
|
|
174
|
+
for (let i = 0; i < value.length; ++i) {
|
|
175
|
+
dv[i] = value.charCodeAt(i);
|
|
176
|
+
}
|
|
177
|
+
return dv.buffer;
|
|
170
178
|
}
|
|
171
179
|
const dv = new DataView(new Uint16Array(value.length).buffer);
|
|
172
|
-
const
|
|
180
|
+
const littleEndian = encoding.endsWith("le");
|
|
173
181
|
for (let i = 0; i < value.length; ++i) {
|
|
174
|
-
dv.setUint16(i << 1, value.charCodeAt(i),
|
|
182
|
+
dv.setUint16(i << 1, value.charCodeAt(i), littleEndian);
|
|
175
183
|
}
|
|
176
184
|
return dv.buffer;
|
|
177
185
|
};
|
|
@@ -180,18 +188,27 @@ const decodeString = (value, encoding = "utf8", byteOffset, byteLength) => {
|
|
|
180
188
|
if (value == null) {
|
|
181
189
|
return undefined;
|
|
182
190
|
}
|
|
183
|
-
|
|
184
|
-
return new TextDecoder().decode(new DataView(value, byteOffset, byteLength));
|
|
191
|
+
switch (encoding) {
|
|
192
|
+
case "utf8": return new TextDecoder().decode(new DataView(value, byteOffset, byteLength));
|
|
193
|
+
case "sbcs": break;
|
|
194
|
+
case "ucs2": break;
|
|
195
|
+
case "ucs2le": break;
|
|
196
|
+
default: throw new Error(`${encoding} encoding not supported`);
|
|
185
197
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const lessOrEqual = encoding.endsWith("le");
|
|
198
|
+
const dv = new DataView(value, byteOffset, byteLength);
|
|
199
|
+
if (encoding === "sbcs") {
|
|
189
200
|
let str = "";
|
|
190
|
-
for (let i = 0; i < dv.byteLength; i
|
|
191
|
-
str += String.fromCharCode(dv.
|
|
201
|
+
for (let i = 0; i < dv.byteLength; ++i) {
|
|
202
|
+
str += String.fromCharCode(dv.getUint8(i));
|
|
192
203
|
}
|
|
193
204
|
return str;
|
|
194
205
|
}
|
|
206
|
+
const littleEndian = encoding.endsWith("le");
|
|
207
|
+
let str = "";
|
|
208
|
+
for (let i = 0; i < dv.byteLength; i += 2) {
|
|
209
|
+
str += String.fromCharCode(dv.getUint16(i, littleEndian));
|
|
210
|
+
}
|
|
211
|
+
return str;
|
|
195
212
|
};
|
|
196
213
|
const typeStringEquator = Type_js_1.Type.functionType(Type_js_1.Type.Boolean, [Type_js_1.Type.String, Type_js_1.Type.String]);
|
|
197
214
|
const typeStringComparator = Type_js_1.Type.functionType(Type_js_1.Type.Boolean, [Type_js_1.Type.String, Type_js_1.Type.String, Type_js_1.Type.OptionalInteger, Type_js_1.Type.OptionalBoolean]);
|
|
@@ -235,7 +252,7 @@ const funcRandomString = new Constant_js_1.Constant((value) => {
|
|
|
235
252
|
}
|
|
236
253
|
return str.slice(0, length);
|
|
237
254
|
}, Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Integer]), false);
|
|
238
|
-
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.
|
|
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]));
|
|
239
256
|
exports.constString = {
|
|
240
257
|
Alphanum: funcAlphanum,
|
|
241
258
|
Random: funcRandomString,
|
|
@@ -5,19 +5,33 @@ const Constant_js_1 = require("../Constant.js");
|
|
|
5
5
|
const Type_js_1 = require("../Type.js");
|
|
6
6
|
const typeTimestampPart = Type_js_1.Type.functionType(Type_js_1.Type.Integer, [Type_js_1.Type.Timestamp, Type_js_1.Type.OptionalBoolean]);
|
|
7
7
|
const typeTimestampSince = Type_js_1.Type.functionType(Type_js_1.Type.Float, [Type_js_1.Type.Timestamp, Type_js_1.Type.Timestamp]);
|
|
8
|
-
const encodeTimestamp = (value, encoding = "
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const encodeTimestamp = (value, encoding = "i64") => {
|
|
9
|
+
switch (encoding) {
|
|
10
|
+
case "i64": break;
|
|
11
|
+
case "i64le": break;
|
|
12
|
+
default: throw new Error(`${encoding} encoding not supported`);
|
|
13
|
+
}
|
|
14
|
+
const dv = new DataView(new BigInt64Array(1).buffer);
|
|
15
|
+
const littleEndian = encoding.endsWith("le");
|
|
16
|
+
dv.setBigInt64(0, BigInt(value?.getTime() ?? 0), littleEndian);
|
|
17
|
+
return dv.buffer;
|
|
13
18
|
};
|
|
14
19
|
exports.encodeTimestamp = encodeTimestamp;
|
|
15
|
-
const decodeTimestamp = (value, encoding = "
|
|
20
|
+
const decodeTimestamp = (value, encoding = "i64", byteOffset) => {
|
|
21
|
+
switch (encoding) {
|
|
22
|
+
case "i64": break;
|
|
23
|
+
case "i64le": break;
|
|
24
|
+
default: throw new Error(`${encoding} encoding not supported`);
|
|
25
|
+
}
|
|
26
|
+
const offset = byteOffset == null ? 0 : Number(byteOffset);
|
|
27
|
+
if (!value || offset < 0 || value.byteLength < offset + 8) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const littleEndian = encoding.endsWith("le");
|
|
31
|
+
return new Date(Number(new DataView(value).getBigInt64(offset, littleEndian)));
|
|
32
|
+
};
|
|
16
33
|
exports.decodeTimestamp = decodeTimestamp;
|
|
17
34
|
const formatTimestamp = (value, template) => {
|
|
18
|
-
if (value == null) {
|
|
19
|
-
return "";
|
|
20
|
-
}
|
|
21
35
|
if (!template || typeof template !== "string") {
|
|
22
36
|
return value.toISOString();
|
|
23
37
|
}
|
|
@@ -76,8 +90,8 @@ exports.funcHoursSince = new Constant_js_1.Constant((value1, value2) => (value1?
|
|
|
76
90
|
exports.funcMinutesSince = new Constant_js_1.Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 60000.0, typeTimestampSince);
|
|
77
91
|
exports.funcSecondsSince = new Constant_js_1.Constant((value1, value2) => (value1?.getTime() - value2?.getTime()) / 1000.0, typeTimestampSince);
|
|
78
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]));
|
|
79
|
-
const funcDecodeTimestamp = new Constant_js_1.Constant((value, encoding = "
|
|
80
|
-
const funcParseTimestamp = new Constant_js_1.Constant((value) => parseTimestamp(value), Type_js_1.Type.functionType(Type_js_1.Type.OptionalTimestamp, [Type_js_1.Type.
|
|
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
|
+
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]));
|
|
81
95
|
exports.constTimestamp = {
|
|
82
96
|
Now: funcNow,
|
|
83
97
|
Epoch: funcEpochTimestamp,
|
|
@@ -55,7 +55,7 @@ const equate = (value1, value2) => {
|
|
|
55
55
|
};
|
|
56
56
|
exports.equate = equate;
|
|
57
57
|
const encode = (value, encoding) => value == null
|
|
58
|
-
?
|
|
58
|
+
? Buffer_js_1.EmptyBuffer
|
|
59
59
|
: typeof value === "boolean"
|
|
60
60
|
? new Uint8Array([value ? 255 : 0]).buffer
|
|
61
61
|
: value instanceof Date
|
|
@@ -69,15 +69,15 @@ const encode = (value, encoding) => value == null
|
|
|
69
69
|
: typeof value === "string"
|
|
70
70
|
? (0, String_js_1.encodeString)(value, encoding ?? "utf8")
|
|
71
71
|
: Array.isArray(value)
|
|
72
|
-
? value.map((i) => (0, exports.encode)(i, encoding)).reduce((acc, val) => (0, Buffer_js_1.concatBuffers)(acc, val))
|
|
72
|
+
? value.map((i) => (0, exports.encode)(i, encoding)).reduce((acc, val) => (0, Buffer_js_1.concatBuffers)(acc, val), Buffer_js_1.EmptyBuffer)
|
|
73
73
|
: typeof value === "object"
|
|
74
74
|
? Object.entries(value)
|
|
75
75
|
.map(([k, v]) => (0, Buffer_js_1.concatBuffers)((0, exports.encode)(k, encoding), (0, exports.encode)(v, encoding)))
|
|
76
|
-
.reduce((acc, val) => (0, Buffer_js_1.concatBuffers)(acc, val))
|
|
77
|
-
:
|
|
76
|
+
.reduce((acc, val) => (0, Buffer_js_1.concatBuffers)(acc, val), Buffer_js_1.EmptyBuffer)
|
|
77
|
+
: Buffer_js_1.EmptyBuffer;
|
|
78
78
|
exports.encode = encode;
|
|
79
79
|
const format = (value, formatting) => value == null
|
|
80
|
-
? "
|
|
80
|
+
? ""
|
|
81
81
|
: typeof value === "boolean"
|
|
82
82
|
? value.toString()
|
|
83
83
|
: value instanceof Date
|
|
@@ -91,16 +91,16 @@ const format = (value, formatting) => value == null
|
|
|
91
91
|
: typeof value === "string"
|
|
92
92
|
? value
|
|
93
93
|
: Array.isArray(value)
|
|
94
|
-
? value.map((i) => (0, exports.format)(i, formatting)).reduce((acc, val) => acc + val)
|
|
94
|
+
? value.map((i) => (0, exports.format)(i, formatting)).reduce((acc, val) => acc + val, "")
|
|
95
95
|
: typeof value === "object"
|
|
96
96
|
? Object.entries(value)
|
|
97
97
|
.map(([k, v]) => (0, exports.format)(k, formatting) + (0, exports.format)(v, formatting))
|
|
98
|
-
.reduce((acc, val) => acc + val)
|
|
99
|
-
: "
|
|
98
|
+
.reduce((acc, val) => acc + val, "")
|
|
99
|
+
: "";
|
|
100
100
|
exports.format = format;
|
|
101
101
|
const typeEquator = Type_js_1.Type.functionType(Type_js_1.Type.Boolean, [Type_js_1.Type.Unknown, Type_js_1.Type.Unknown]);
|
|
102
102
|
exports.funcCoalesce = new Constant_js_1.Constant((value, valueOtherwise) => value ?? valueOtherwise, Type_js_1.Type.union(Type_js_1.Type.functionType(Type_js_1.Type.Unknown, [Type_js_1.Type.Unknown, Type_js_1.Type.Unknown]), Type_js_1.Type.functionType(Type_js_1.Type.OptionalFloat, [Type_js_1.Type.OptionalFloat, Type_js_1.Type.OptionalFloat]), Type_js_1.Type.functionType(Type_js_1.Type.OptionalBoolean, [Type_js_1.Type.OptionalBoolean, Type_js_1.Type.OptionalBoolean]), Type_js_1.Type.functionType(Type_js_1.Type.OptionalTimestamp, [Type_js_1.Type.OptionalTimestamp, Type_js_1.Type.OptionalTimestamp]), Type_js_1.Type.functionType(Type_js_1.Type.OptionalInteger, [Type_js_1.Type.OptionalInteger, Type_js_1.Type.OptionalInteger]), Type_js_1.Type.functionType(Type_js_1.Type.OptionalBuffer, [Type_js_1.Type.OptionalBuffer, Type_js_1.Type.OptionalBuffer]), Type_js_1.Type.functionType(Type_js_1.Type.OptionalString, [Type_js_1.Type.OptionalString, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.OptionalArray, [Type_js_1.Type.OptionalArray, Type_js_1.Type.OptionalArray]), Type_js_1.Type.functionType(Type_js_1.Type.OptionalObject, [Type_js_1.Type.OptionalObject, Type_js_1.Type.OptionalObject]), Type_js_1.Type.functionType(Type_js_1.Type.OptionalFunction, [Type_js_1.Type.OptionalFunction, Type_js_1.Type.OptionalFunction])));
|
|
103
103
|
exports.funcEqual = new Constant_js_1.Constant((value1, value2) => (0, exports.equate)(value1, value2), typeEquator);
|
|
104
104
|
exports.funcNotEqual = new Constant_js_1.Constant((value1, value2) => !(0, exports.equate)(value1, value2), typeEquator);
|
|
105
|
-
exports.funcEncode = new Constant_js_1.Constant((value, encoding) => (0, exports.encode)(value, encoding), Type_js_1.Type.union(Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Boolean]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Timestamp, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Float, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Integer, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Buffer]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.String, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Array, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Object, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Function])));
|
|
106
|
-
exports.funcFormat = new Constant_js_1.Constant((value, formatting) => (0, exports.format)(value, formatting), Type_js_1.Type.union(Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Boolean]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Timestamp, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Float, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Integer, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Buffer, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.String]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Array, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Object, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Function])));
|
|
105
|
+
exports.funcEncode = new Constant_js_1.Constant((value, encoding) => (0, exports.encode)(value, encoding), Type_js_1.Type.union(Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Void, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Boolean]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Timestamp, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Float, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Integer, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Buffer]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.String, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Array, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Object, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.Buffer, [Type_js_1.Type.Function])));
|
|
106
|
+
exports.funcFormat = new Constant_js_1.Constant((value, formatting) => (0, exports.format)(value, formatting), Type_js_1.Type.union(Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Void, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Boolean]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Timestamp, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Float, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Integer, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Buffer, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.String]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Array, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Object, Type_js_1.Type.OptionalString]), Type_js_1.Type.functionType(Type_js_1.Type.String, [Type_js_1.Type.Function])));
|