@hotmeshio/hotmesh 0.14.1 → 0.14.3
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/build/package.json +2 -1
- package/build/services/engine/init.js +1 -1
- package/build/services/engine/schema.js +5 -1
- package/build/services/pipe/functions/array.d.ts +219 -0
- package/build/services/pipe/functions/array.js +219 -0
- package/build/services/pipe/functions/bitwise.d.ts +94 -0
- package/build/services/pipe/functions/bitwise.js +94 -0
- package/build/services/pipe/functions/conditional.d.ts +161 -0
- package/build/services/pipe/functions/conditional.js +161 -0
- package/build/services/pipe/functions/cron.d.ts +23 -4
- package/build/services/pipe/functions/cron.js +23 -4
- package/build/services/pipe/functions/date.d.ts +737 -6
- package/build/services/pipe/functions/date.js +742 -5
- package/build/services/pipe/functions/json.d.ts +42 -0
- package/build/services/pipe/functions/json.js +42 -0
- package/build/services/pipe/functions/logical.d.ts +38 -0
- package/build/services/pipe/functions/logical.js +38 -0
- package/build/services/pipe/functions/math.d.ts +533 -0
- package/build/services/pipe/functions/math.js +533 -0
- package/build/services/pipe/functions/number.d.ts +258 -0
- package/build/services/pipe/functions/number.js +258 -0
- package/build/services/pipe/functions/object.d.ts +321 -0
- package/build/services/pipe/functions/object.js +321 -0
- package/build/services/pipe/functions/string.d.ts +306 -0
- package/build/services/pipe/functions/string.js +306 -0
- package/build/services/pipe/functions/symbol.d.ts +112 -0
- package/build/services/pipe/functions/symbol.js +112 -0
- package/build/services/pipe/functions/unary.d.ts +65 -0
- package/build/services/pipe/functions/unary.js +65 -0
- package/build/services/quorum/index.js +1 -1
- package/build/services/router/consumption/index.js +20 -2
- package/build/services/router/error-handling/index.js +1 -1
- package/build/services/store/factory.d.ts +1 -1
- package/build/services/store/factory.js +2 -2
- package/build/services/store/index.d.ts +1 -1
- package/build/services/store/providers/postgres/kvsql.d.ts +11 -1
- package/build/services/store/providers/postgres/kvsql.js +22 -12
- package/build/services/store/providers/postgres/kvtables.js +39 -6
- package/build/services/store/providers/postgres/kvtypes/hash/basic.js +6 -6
- package/build/services/store/providers/postgres/kvtypes/hash/scan.js +2 -1
- package/build/services/store/providers/postgres/kvtypes/list.js +7 -6
- package/build/services/store/providers/postgres/kvtypes/string.js +3 -3
- package/build/services/store/providers/postgres/kvtypes/zset.js +7 -7
- package/build/services/store/providers/postgres/postgres.d.ts +3 -2
- package/build/services/store/providers/postgres/postgres.js +55 -55
- package/build/services/store/providers/postgres/time-notify.js +18 -25
- package/build/services/store/providers/store-initializable.d.ts +1 -1
- package/build/services/virtual/index.js +6 -0
- package/build/services/virtual/schemas/factory.js +1 -1
- package/build/services/worker/index.js +1 -1
- package/build/types/virtual.d.ts +21 -0
- package/package.json +2 -1
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MathHandler = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Provides mathematical operations and transformations for use in HotMesh
|
|
6
|
+
* mapping rules. The functions facilitate a wide range of mathematical
|
|
7
|
+
* operations during the mapping process, all of which can be utilised
|
|
8
|
+
* through the `@pipe` system for a functional approach.
|
|
9
|
+
*
|
|
10
|
+
* @remarks Methods are invoked with the syntax `{@math.<method>}`, e.g., `{@math.add}` or `{@math.sqrt}`.
|
|
11
|
+
*/
|
|
4
12
|
class MathHandler {
|
|
13
|
+
/**
|
|
14
|
+
* Sums all the numbers passed as arguments. Accepts any number of
|
|
15
|
+
* arguments, including nested arrays, and returns their total.
|
|
16
|
+
*
|
|
17
|
+
* @param {...(number | number[])[]} operands - Numbers or arrays of numbers to sum.
|
|
18
|
+
* @returns {number} The sum of all operands.
|
|
19
|
+
* @example
|
|
20
|
+
* ```yaml
|
|
21
|
+
* sum:
|
|
22
|
+
* "@pipe":
|
|
23
|
+
* - ["{a.output.data.values}"]
|
|
24
|
+
* - ["{@math.add}"]
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
5
27
|
add(...operands) {
|
|
6
28
|
// @ts-ignore
|
|
7
29
|
return operands.reduce((a, b) => {
|
|
@@ -13,6 +35,22 @@ class MathHandler {
|
|
|
13
35
|
}
|
|
14
36
|
}, 0);
|
|
15
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Subtracts all the numbers passed as arguments in the order they are
|
|
40
|
+
* given. Accepts any number of arguments, and all arguments should be
|
|
41
|
+
* numbers. The first number is the starting value; subsequent numbers are
|
|
42
|
+
* subtracted from it.
|
|
43
|
+
*
|
|
44
|
+
* @param {...(number | number[])[]} operands - Numbers or arrays of numbers to subtract sequentially.
|
|
45
|
+
* @returns {number} The result of sequential subtraction.
|
|
46
|
+
* @example
|
|
47
|
+
* ```yaml
|
|
48
|
+
* difference:
|
|
49
|
+
* "@pipe":
|
|
50
|
+
* - ["{a.output.data.values}"]
|
|
51
|
+
* - ["{@math.subtract}"]
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
16
54
|
subtract(...operands) {
|
|
17
55
|
if (operands.length === 0) {
|
|
18
56
|
throw new Error('At least one operand is required.');
|
|
@@ -34,6 +72,20 @@ class MathHandler {
|
|
|
34
72
|
});
|
|
35
73
|
return result;
|
|
36
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Multiplies all the numbers passed as arguments. Accepts any number of
|
|
77
|
+
* arguments, including nested arrays, and returns their product.
|
|
78
|
+
*
|
|
79
|
+
* @param {...(number | number[])[]} operands - Numbers or arrays of numbers to multiply.
|
|
80
|
+
* @returns {number} The product of all operands.
|
|
81
|
+
* @example
|
|
82
|
+
* ```yaml
|
|
83
|
+
* product:
|
|
84
|
+
* "@pipe":
|
|
85
|
+
* - ["{a.output.data.values}", 5]
|
|
86
|
+
* - ["{@math.multiply}"]
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
37
89
|
multiply(...operands) {
|
|
38
90
|
if (operands.length === 0) {
|
|
39
91
|
throw new Error('At least one operand is required.');
|
|
@@ -48,6 +100,21 @@ class MathHandler {
|
|
|
48
100
|
}
|
|
49
101
|
}, 1);
|
|
50
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Divides all the numbers passed as arguments in the order they are given.
|
|
105
|
+
* The first number is the dividend; subsequent numbers are divisors.
|
|
106
|
+
* Division by zero returns `NaN`.
|
|
107
|
+
*
|
|
108
|
+
* @param {...(number | number[])[]} operands - Numbers or arrays of numbers to divide sequentially.
|
|
109
|
+
* @returns {number} The result of sequential division, or `NaN` on division by zero.
|
|
110
|
+
* @example
|
|
111
|
+
* ```yaml
|
|
112
|
+
* quotient:
|
|
113
|
+
* "@pipe":
|
|
114
|
+
* - ["{a.output.data.values}"]
|
|
115
|
+
* - ["{@math.divide}"]
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
51
118
|
divide(...operands) {
|
|
52
119
|
if (operands.length === 0) {
|
|
53
120
|
throw new Error('At least one operand is required.');
|
|
@@ -75,108 +142,574 @@ class MathHandler {
|
|
|
75
142
|
}
|
|
76
143
|
return result;
|
|
77
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Returns the absolute value of a number.
|
|
147
|
+
*
|
|
148
|
+
* @param {number} x - The number to find the absolute value of.
|
|
149
|
+
* @returns {number} The absolute value.
|
|
150
|
+
* @example
|
|
151
|
+
* ```yaml
|
|
152
|
+
* absolute_value:
|
|
153
|
+
* "@pipe":
|
|
154
|
+
* - ["{a.output.data.value}"]
|
|
155
|
+
* - ["{@math.abs}"]
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
78
158
|
abs(x) {
|
|
79
159
|
return Math.abs(x);
|
|
80
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Returns the arccosine (in radians) of a number.
|
|
163
|
+
*
|
|
164
|
+
* @param {number} x - A number between -1 and 1.
|
|
165
|
+
* @returns {number} The arccosine in radians.
|
|
166
|
+
* @example
|
|
167
|
+
* ```yaml
|
|
168
|
+
* arccosine_value:
|
|
169
|
+
* "@pipe":
|
|
170
|
+
* - ["{a.output.data.value}"]
|
|
171
|
+
* - ["{@math.acos}"]
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
81
174
|
acos(x) {
|
|
82
175
|
return Math.acos(x);
|
|
83
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Returns the inverse hyperbolic cosine of a number.
|
|
179
|
+
*
|
|
180
|
+
* @param {number} x - A number greater than or equal to 1.
|
|
181
|
+
* @returns {number} The inverse hyperbolic cosine.
|
|
182
|
+
* @example
|
|
183
|
+
* ```yaml
|
|
184
|
+
* inverse_hyp_cosine:
|
|
185
|
+
* "@pipe":
|
|
186
|
+
* - ["{a.output.data.value}"]
|
|
187
|
+
* - ["{@math.acosh}"]
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
84
190
|
acosh(x) {
|
|
85
191
|
return Math.acosh(x);
|
|
86
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Returns the arcsine (in radians) of a number.
|
|
195
|
+
*
|
|
196
|
+
* @param {number} x - A number between -1 and 1.
|
|
197
|
+
* @returns {number} The arcsine in radians.
|
|
198
|
+
* @example
|
|
199
|
+
* ```yaml
|
|
200
|
+
* arcsine_value:
|
|
201
|
+
* "@pipe":
|
|
202
|
+
* - ["{a.output.data.value}"]
|
|
203
|
+
* - ["{@math.asin}"]
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
87
206
|
asin(x) {
|
|
88
207
|
return Math.asin(x);
|
|
89
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Returns the inverse hyperbolic sine of a number.
|
|
211
|
+
*
|
|
212
|
+
* @param {number} x - The number to compute the inverse hyperbolic sine of.
|
|
213
|
+
* @returns {number} The inverse hyperbolic sine.
|
|
214
|
+
* @example
|
|
215
|
+
* ```yaml
|
|
216
|
+
* inverse_hyp_sine:
|
|
217
|
+
* "@pipe":
|
|
218
|
+
* - ["{a.output.data.value}"]
|
|
219
|
+
* - ["{@math.asinh}"]
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
90
222
|
asinh(x) {
|
|
91
223
|
return Math.asinh(x);
|
|
92
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Returns the arctangent (in radians) of a number.
|
|
227
|
+
*
|
|
228
|
+
* @param {number} x - The number to compute the arctangent of.
|
|
229
|
+
* @returns {number} The arctangent in radians.
|
|
230
|
+
* @example
|
|
231
|
+
* ```yaml
|
|
232
|
+
* arctangent_value:
|
|
233
|
+
* "@pipe":
|
|
234
|
+
* - ["{a.output.data.value}"]
|
|
235
|
+
* - ["{@math.atan}"]
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
93
238
|
atan(x) {
|
|
94
239
|
return Math.atan(x);
|
|
95
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Returns the arctangent (in radians) of the quotient of its arguments
|
|
243
|
+
* (y/x), using the signs of both to determine the quadrant.
|
|
244
|
+
*
|
|
245
|
+
* @param {number} y - The dividend (y-coordinate).
|
|
246
|
+
* @param {number} x - The divisor (x-coordinate).
|
|
247
|
+
* @returns {number} The arctangent of y/x in radians.
|
|
248
|
+
* @example
|
|
249
|
+
* ```yaml
|
|
250
|
+
* arctangent2_value:
|
|
251
|
+
* "@pipe":
|
|
252
|
+
* - ["{a.output.data.y}", "{a.output.data.x}"]
|
|
253
|
+
* - ["{@math.atan2}"]
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
96
256
|
atan2(y, x) {
|
|
97
257
|
return Math.atan2(y, x);
|
|
98
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Returns the inverse hyperbolic tangent of a number.
|
|
261
|
+
*
|
|
262
|
+
* @param {number} x - A number between -1 and 1 (exclusive).
|
|
263
|
+
* @returns {number} The inverse hyperbolic tangent.
|
|
264
|
+
* @example
|
|
265
|
+
* ```yaml
|
|
266
|
+
* inverse_hyp_tangent:
|
|
267
|
+
* "@pipe":
|
|
268
|
+
* - ["{a.output.data.value}"]
|
|
269
|
+
* - ["{@math.atanh}"]
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
99
272
|
atanh(x) {
|
|
100
273
|
return Math.atanh(x);
|
|
101
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Returns the cube root of a number.
|
|
277
|
+
*
|
|
278
|
+
* @param {number} x - The number to compute the cube root of.
|
|
279
|
+
* @returns {number} The cube root.
|
|
280
|
+
* @example
|
|
281
|
+
* ```yaml
|
|
282
|
+
* cube_root:
|
|
283
|
+
* "@pipe":
|
|
284
|
+
* - ["{a.output.data.value}"]
|
|
285
|
+
* - ["{@math.cbrt}"]
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
102
288
|
cbrt(x) {
|
|
103
289
|
return Math.cbrt(x);
|
|
104
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Returns the smallest integer greater than or equal to a given number
|
|
293
|
+
* (rounds up).
|
|
294
|
+
*
|
|
295
|
+
* @param {number} x - The number to round up.
|
|
296
|
+
* @returns {number} The ceiling value.
|
|
297
|
+
* @example
|
|
298
|
+
* ```yaml
|
|
299
|
+
* ceiling_value:
|
|
300
|
+
* "@pipe":
|
|
301
|
+
* - ["{a.output.data.value}"]
|
|
302
|
+
* - ["{@math.ceil}"]
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
105
305
|
ceil(x) {
|
|
106
306
|
return Math.ceil(x);
|
|
107
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Returns the number of leading zero bits in the 32-bit binary
|
|
310
|
+
* representation of a number.
|
|
311
|
+
*
|
|
312
|
+
* @param {number} x - The number to count leading zero bits for.
|
|
313
|
+
* @returns {number} The count of leading zero bits.
|
|
314
|
+
* @example
|
|
315
|
+
* ```yaml
|
|
316
|
+
* leading_zeros:
|
|
317
|
+
* "@pipe":
|
|
318
|
+
* - ["{a.output.data.value}"]
|
|
319
|
+
* - ["{@math.clz32}"]
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
108
322
|
clz32(x) {
|
|
109
323
|
return Math.clz32(x);
|
|
110
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Returns the cosine of a number (in radians).
|
|
327
|
+
*
|
|
328
|
+
* @param {number} x - The angle in radians.
|
|
329
|
+
* @returns {number} The cosine of the angle.
|
|
330
|
+
* @example
|
|
331
|
+
* ```yaml
|
|
332
|
+
* cosine_value:
|
|
333
|
+
* "@pipe":
|
|
334
|
+
* - ["{a.output.data.angle}"]
|
|
335
|
+
* - ["{@math.cos}"]
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
111
338
|
cos(x) {
|
|
112
339
|
return Math.cos(x);
|
|
113
340
|
}
|
|
341
|
+
/**
|
|
342
|
+
* Returns the hyperbolic cosine of a number.
|
|
343
|
+
*
|
|
344
|
+
* @param {number} x - The number to compute the hyperbolic cosine of.
|
|
345
|
+
* @returns {number} The hyperbolic cosine.
|
|
346
|
+
* @example
|
|
347
|
+
* ```yaml
|
|
348
|
+
* hyperbolic_cosine:
|
|
349
|
+
* "@pipe":
|
|
350
|
+
* - ["{a.output.data.value}"]
|
|
351
|
+
* - ["{@math.cosh}"]
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
114
354
|
cosh(x) {
|
|
115
355
|
return Math.cosh(x);
|
|
116
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* Returns e raised to the power of the given number (e^x).
|
|
359
|
+
*
|
|
360
|
+
* @param {number} x - The exponent to raise e to.
|
|
361
|
+
* @returns {number} The value of e^x.
|
|
362
|
+
* @example
|
|
363
|
+
* ```yaml
|
|
364
|
+
* exponential_value:
|
|
365
|
+
* "@pipe":
|
|
366
|
+
* - ["{a.output.data.exponent}"]
|
|
367
|
+
* - ["{@math.exp}"]
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
117
370
|
exp(x) {
|
|
118
371
|
return Math.exp(x);
|
|
119
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Returns e^x minus 1, providing better precision for small values of x
|
|
375
|
+
* than using `exp(x) - 1`.
|
|
376
|
+
*
|
|
377
|
+
* @param {number} x - The exponent to raise e to before subtracting 1.
|
|
378
|
+
* @returns {number} The value of e^x - 1.
|
|
379
|
+
* @example
|
|
380
|
+
* ```yaml
|
|
381
|
+
* exponential_minus_one:
|
|
382
|
+
* "@pipe":
|
|
383
|
+
* - ["{a.output.data.exponent}"]
|
|
384
|
+
* - ["{@math.expm1}"]
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
120
387
|
expm1(x) {
|
|
121
388
|
return Math.expm1(x);
|
|
122
389
|
}
|
|
390
|
+
/**
|
|
391
|
+
* Returns the largest integer less than or equal to a given number (rounds
|
|
392
|
+
* down).
|
|
393
|
+
*
|
|
394
|
+
* @param {number} x - The number to round down.
|
|
395
|
+
* @returns {number} The floor value.
|
|
396
|
+
* @example
|
|
397
|
+
* ```yaml
|
|
398
|
+
* floor_value:
|
|
399
|
+
* "@pipe":
|
|
400
|
+
* - ["{a.output.data.value}"]
|
|
401
|
+
* - ["{@math.floor}"]
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
123
404
|
floor(x) {
|
|
124
405
|
return Math.floor(x);
|
|
125
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* Returns the nearest single-precision float representation of a number.
|
|
409
|
+
*
|
|
410
|
+
* @param {number} x - The number to round to single-precision float.
|
|
411
|
+
* @returns {number} The nearest single-precision float.
|
|
412
|
+
* @example
|
|
413
|
+
* ```yaml
|
|
414
|
+
* fround_value:
|
|
415
|
+
* "@pipe":
|
|
416
|
+
* - ["{a.output.data.value}"]
|
|
417
|
+
* - ["{@math.fround}"]
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
126
420
|
fround(x) {
|
|
127
421
|
return Math.fround(x);
|
|
128
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* Returns the square root of the sum of the squares of its arguments
|
|
425
|
+
* (Euclidean distance / hypotenuse).
|
|
426
|
+
*
|
|
427
|
+
* @param {...number[]} values - The numbers to compute the hypotenuse from.
|
|
428
|
+
* @returns {number} The square root of the sum of squares.
|
|
429
|
+
* @example
|
|
430
|
+
* ```yaml
|
|
431
|
+
* hypot_value:
|
|
432
|
+
* "@pipe":
|
|
433
|
+
* - ["{a.output.data.a}", "{a.output.data.b}"]
|
|
434
|
+
* - ["{@math.hypot}"]
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
129
437
|
hypot(...values) {
|
|
130
438
|
return Math.hypot(...values);
|
|
131
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Returns the result of a 32-bit integer multiplication of two numbers.
|
|
442
|
+
*
|
|
443
|
+
* @param {number} x - The first number to multiply.
|
|
444
|
+
* @param {number} y - The second number to multiply.
|
|
445
|
+
* @returns {number} The 32-bit integer product.
|
|
446
|
+
* @example
|
|
447
|
+
* ```yaml
|
|
448
|
+
* imul_value:
|
|
449
|
+
* "@pipe":
|
|
450
|
+
* - ["{a.output.data.a}", "{a.output.data.b}"]
|
|
451
|
+
* - ["{@math.imul}"]
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
132
454
|
imul(x, y) {
|
|
133
455
|
return Math.imul(x, y);
|
|
134
456
|
}
|
|
457
|
+
/**
|
|
458
|
+
* Returns the natural logarithm (base e) of a number.
|
|
459
|
+
*
|
|
460
|
+
* @param {number} x - The number to compute the natural logarithm of.
|
|
461
|
+
* @returns {number} The natural logarithm.
|
|
462
|
+
* @example
|
|
463
|
+
* ```yaml
|
|
464
|
+
* log_value:
|
|
465
|
+
* "@pipe":
|
|
466
|
+
* - ["{a.output.data.value}"]
|
|
467
|
+
* - ["{@math.log}"]
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
135
470
|
log(x) {
|
|
136
471
|
return Math.log(x);
|
|
137
472
|
}
|
|
473
|
+
/**
|
|
474
|
+
* Returns the base 10 logarithm of a number.
|
|
475
|
+
*
|
|
476
|
+
* @param {number} x - The number to compute the base 10 logarithm of.
|
|
477
|
+
* @returns {number} The base 10 logarithm.
|
|
478
|
+
* @example
|
|
479
|
+
* ```yaml
|
|
480
|
+
* log10_value:
|
|
481
|
+
* "@pipe":
|
|
482
|
+
* - ["{a.output.data.value}"]
|
|
483
|
+
* - ["{@math.log10}"]
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
138
486
|
log10(x) {
|
|
139
487
|
return Math.log10(x);
|
|
140
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* Returns the natural logarithm (base e) of 1 plus a given number.
|
|
491
|
+
* Provides better precision for small values of x than `log(1 + x)`.
|
|
492
|
+
*
|
|
493
|
+
* @param {number} x - The number to add to 1 before computing the logarithm.
|
|
494
|
+
* @returns {number} The natural logarithm of 1 + x.
|
|
495
|
+
* @example
|
|
496
|
+
* ```yaml
|
|
497
|
+
* log1p_value:
|
|
498
|
+
* "@pipe":
|
|
499
|
+
* - ["{a.output.data.value}"]
|
|
500
|
+
* - ["{@math.log1p}"]
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
141
503
|
log1p(x) {
|
|
142
504
|
return Math.log1p(x);
|
|
143
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* Returns the base 2 logarithm of a number.
|
|
508
|
+
*
|
|
509
|
+
* @param {number} x - The number to compute the base 2 logarithm of.
|
|
510
|
+
* @returns {number} The base 2 logarithm.
|
|
511
|
+
* @example
|
|
512
|
+
* ```yaml
|
|
513
|
+
* log2_value:
|
|
514
|
+
* "@pipe":
|
|
515
|
+
* - ["{a.output.data.value}"]
|
|
516
|
+
* - ["{@math.log2}"]
|
|
517
|
+
* ```
|
|
518
|
+
*/
|
|
144
519
|
log2(x) {
|
|
145
520
|
return Math.log2(x);
|
|
146
521
|
}
|
|
522
|
+
/**
|
|
523
|
+
* Returns the largest of the given numbers.
|
|
524
|
+
*
|
|
525
|
+
* @param {...number[]} values - The numbers to compare.
|
|
526
|
+
* @returns {number} The largest value.
|
|
527
|
+
* @example
|
|
528
|
+
* ```yaml
|
|
529
|
+
* max_value:
|
|
530
|
+
* "@pipe":
|
|
531
|
+
* - ["{a.output.data.a}", "{a.output.data.b}", "{a.output.data.c}"]
|
|
532
|
+
* - ["{@math.max}"]
|
|
533
|
+
* ```
|
|
534
|
+
*/
|
|
147
535
|
max(...values) {
|
|
148
536
|
return Math.max(...values);
|
|
149
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* Returns the smallest of the given numbers.
|
|
540
|
+
*
|
|
541
|
+
* @param {...number[]} values - The numbers to compare.
|
|
542
|
+
* @returns {number} The smallest value.
|
|
543
|
+
* @example
|
|
544
|
+
* ```yaml
|
|
545
|
+
* min_value:
|
|
546
|
+
* "@pipe":
|
|
547
|
+
* - ["{a.output.data.a}", "{a.output.data.b}", "{a.output.data.c}"]
|
|
548
|
+
* - ["{@math.min}"]
|
|
549
|
+
* ```
|
|
550
|
+
*/
|
|
150
551
|
min(...values) {
|
|
151
552
|
return Math.min(...values);
|
|
152
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* Returns the result of raising the base to the exponent power (base^exp).
|
|
556
|
+
*
|
|
557
|
+
* @param {number} x - The base.
|
|
558
|
+
* @param {number} y - The exponent.
|
|
559
|
+
* @returns {number} The result of x raised to the power y.
|
|
560
|
+
* @example
|
|
561
|
+
* ```yaml
|
|
562
|
+
* pow_value:
|
|
563
|
+
* "@pipe":
|
|
564
|
+
* - ["{a.output.data.base}", "{a.output.data.exponent}"]
|
|
565
|
+
* - ["{@math.pow}"]
|
|
566
|
+
* ```
|
|
567
|
+
*/
|
|
153
568
|
pow(x, y) {
|
|
154
569
|
return Math.pow(x, y);
|
|
155
570
|
}
|
|
571
|
+
/**
|
|
572
|
+
* Returns a random number between 0 (inclusive) and 1 (exclusive). Takes
|
|
573
|
+
* no parameters.
|
|
574
|
+
*
|
|
575
|
+
* @returns {number} A pseudo-random number in [0, 1).
|
|
576
|
+
* @example
|
|
577
|
+
* ```yaml
|
|
578
|
+
* random_value:
|
|
579
|
+
* "@pipe":
|
|
580
|
+
* - []
|
|
581
|
+
* - ["{@math.random}"]
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
156
584
|
random() {
|
|
157
585
|
return Math.random();
|
|
158
586
|
}
|
|
587
|
+
/**
|
|
588
|
+
* Returns the value of a number rounded to the nearest integer.
|
|
589
|
+
*
|
|
590
|
+
* @param {number} x - The number to round.
|
|
591
|
+
* @returns {number} The rounded integer.
|
|
592
|
+
* @example
|
|
593
|
+
* ```yaml
|
|
594
|
+
* rounded_value:
|
|
595
|
+
* "@pipe":
|
|
596
|
+
* - ["{a.output.data.value}"]
|
|
597
|
+
* - ["{@math.round}"]
|
|
598
|
+
* ```
|
|
599
|
+
*/
|
|
159
600
|
round(x) {
|
|
160
601
|
return Math.round(x);
|
|
161
602
|
}
|
|
603
|
+
/**
|
|
604
|
+
* Returns the sign of a number, indicating whether the number is positive
|
|
605
|
+
* (1), negative (-1), or zero (0).
|
|
606
|
+
*
|
|
607
|
+
* @param {number} x - The number to determine the sign of.
|
|
608
|
+
* @returns {number} 1, -1, or 0.
|
|
609
|
+
* @example
|
|
610
|
+
* ```yaml
|
|
611
|
+
* sign_value:
|
|
612
|
+
* "@pipe":
|
|
613
|
+
* - ["{a.output.data.value}"]
|
|
614
|
+
* - ["{@math.sign}"]
|
|
615
|
+
* ```
|
|
616
|
+
*/
|
|
162
617
|
sign(x) {
|
|
163
618
|
return Math.sign(x);
|
|
164
619
|
}
|
|
620
|
+
/**
|
|
621
|
+
* Returns the sine of a number (in radians).
|
|
622
|
+
*
|
|
623
|
+
* @param {number} x - The angle in radians.
|
|
624
|
+
* @returns {number} The sine of the angle.
|
|
625
|
+
* @example
|
|
626
|
+
* ```yaml
|
|
627
|
+
* sin_value:
|
|
628
|
+
* "@pipe":
|
|
629
|
+
* - ["{a.output.data.angle}"]
|
|
630
|
+
* - ["{@math.sin}"]
|
|
631
|
+
* ```
|
|
632
|
+
*/
|
|
165
633
|
sin(x) {
|
|
166
634
|
return Math.sin(x);
|
|
167
635
|
}
|
|
636
|
+
/**
|
|
637
|
+
* Returns the hyperbolic sine of a number.
|
|
638
|
+
*
|
|
639
|
+
* @param {number} x - The number to compute the hyperbolic sine of.
|
|
640
|
+
* @returns {number} The hyperbolic sine.
|
|
641
|
+
* @example
|
|
642
|
+
* ```yaml
|
|
643
|
+
* sinh_value:
|
|
644
|
+
* "@pipe":
|
|
645
|
+
* - ["{a.output.data.value}"]
|
|
646
|
+
* - ["{@math.sinh}"]
|
|
647
|
+
* ```
|
|
648
|
+
*/
|
|
168
649
|
sinh(x) {
|
|
169
650
|
return Math.sinh(x);
|
|
170
651
|
}
|
|
652
|
+
/**
|
|
653
|
+
* Returns the square root of a number.
|
|
654
|
+
*
|
|
655
|
+
* @param {number} x - The number to compute the square root of.
|
|
656
|
+
* @returns {number} The square root.
|
|
657
|
+
* @example
|
|
658
|
+
* ```yaml
|
|
659
|
+
* sqrt_value:
|
|
660
|
+
* "@pipe":
|
|
661
|
+
* - ["{a.output.data.value}"]
|
|
662
|
+
* - ["{@math.sqrt}"]
|
|
663
|
+
* ```
|
|
664
|
+
*/
|
|
171
665
|
sqrt(x) {
|
|
172
666
|
return Math.sqrt(x);
|
|
173
667
|
}
|
|
668
|
+
/**
|
|
669
|
+
* Returns the tangent of a number (in radians).
|
|
670
|
+
*
|
|
671
|
+
* @param {number} x - The angle in radians.
|
|
672
|
+
* @returns {number} The tangent of the angle.
|
|
673
|
+
* @example
|
|
674
|
+
* ```yaml
|
|
675
|
+
* tan_value:
|
|
676
|
+
* "@pipe":
|
|
677
|
+
* - ["{a.output.data.angle}"]
|
|
678
|
+
* - ["{@math.tan}"]
|
|
679
|
+
* ```
|
|
680
|
+
*/
|
|
174
681
|
tan(x) {
|
|
175
682
|
return Math.tan(x);
|
|
176
683
|
}
|
|
684
|
+
/**
|
|
685
|
+
* Returns the hyperbolic tangent of a number.
|
|
686
|
+
*
|
|
687
|
+
* @param {number} x - The number to compute the hyperbolic tangent of.
|
|
688
|
+
* @returns {number} The hyperbolic tangent.
|
|
689
|
+
* @example
|
|
690
|
+
* ```yaml
|
|
691
|
+
* tanh_value:
|
|
692
|
+
* "@pipe":
|
|
693
|
+
* - ["{a.output.data.value}"]
|
|
694
|
+
* - ["{@math.tanh}"]
|
|
695
|
+
* ```
|
|
696
|
+
*/
|
|
177
697
|
tanh(x) {
|
|
178
698
|
return Math.tanh(x);
|
|
179
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* Returns the integer part of a number by removing any fractional digits.
|
|
702
|
+
*
|
|
703
|
+
* @param {number} x - The number to truncate.
|
|
704
|
+
* @returns {number} The integer part of the number.
|
|
705
|
+
* @example
|
|
706
|
+
* ```yaml
|
|
707
|
+
* trunc_value:
|
|
708
|
+
* "@pipe":
|
|
709
|
+
* - ["{a.output.data.value}"]
|
|
710
|
+
* - ["{@math.trunc}"]
|
|
711
|
+
* ```
|
|
712
|
+
*/
|
|
180
713
|
trunc(x) {
|
|
181
714
|
return Math.trunc(x);
|
|
182
715
|
}
|