@grain/stdlib 0.5.3 → 0.5.5
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/CHANGELOG.md +61 -0
- package/array.gr +65 -57
- package/array.md +54 -6
- package/buffer.gr +71 -1
- package/buffer.md +142 -0
- package/bytes.gr +52 -3
- package/bytes.md +117 -0
- package/char.gr +23 -20
- package/char.md +18 -3
- package/immutablemap.gr +493 -0
- package/immutablemap.md +479 -0
- package/immutablepriorityqueue.gr +44 -16
- package/immutablepriorityqueue.md +44 -1
- package/immutableset.gr +498 -0
- package/immutableset.md +449 -0
- package/int32.gr +39 -37
- package/int32.md +6 -0
- package/int64.gr +39 -37
- package/int64.md +6 -0
- package/list.gr +33 -24
- package/list.md +39 -10
- package/map.gr +19 -28
- package/marshal.gr +4 -4
- package/number.gr +727 -26
- package/number.md +345 -23
- package/option.gr +30 -26
- package/option.md +12 -0
- package/package.json +1 -1
- package/path.gr +787 -0
- package/path.md +727 -0
- package/pervasives.gr +3 -4
- package/pervasives.md +6 -1
- package/priorityqueue.gr +25 -5
- package/priorityqueue.md +30 -0
- package/queue.gr +22 -7
- package/queue.md +18 -1
- package/regex.gr +161 -65
- package/regex.md +70 -0
- package/result.gr +24 -20
- package/result.md +12 -0
- package/runtime/atof/common.gr +198 -0
- package/runtime/atof/common.md +243 -0
- package/runtime/atof/decimal.gr +663 -0
- package/runtime/atof/decimal.md +59 -0
- package/runtime/atof/lemire.gr +264 -0
- package/runtime/atof/lemire.md +6 -0
- package/runtime/atof/parse.gr +615 -0
- package/runtime/atof/parse.md +12 -0
- package/runtime/atof/slow.gr +238 -0
- package/runtime/atof/slow.md +6 -0
- package/runtime/atof/table.gr +2016 -0
- package/runtime/atof/table.md +12 -0
- package/runtime/{stringUtils.gr → atoi/parse.gr} +1 -1
- package/runtime/{stringUtils.md → atoi/parse.md} +1 -1
- package/runtime/bigint.gr +7 -7
- package/runtime/compare.gr +2 -1
- package/runtime/equal.gr +3 -2
- package/runtime/exception.gr +9 -5
- package/runtime/exception.md +8 -2
- package/runtime/gc.gr +2 -1
- package/runtime/malloc.gr +1 -3
- package/runtime/numberUtils.gr +13 -13
- package/runtime/numberUtils.md +6 -0
- package/runtime/numbers.gr +123 -39
- package/runtime/numbers.md +26 -0
- package/runtime/string.gr +4 -2
- package/runtime/unsafe/conv.gr +21 -41
- package/runtime/unsafe/conv.md +0 -3
- package/runtime/unsafe/printWasm.gr +4 -40
- package/runtime/utils/printing.gr +3 -3
- package/set.gr +25 -25
- package/stack.gr +14 -0
- package/stack.md +17 -0
- package/string.gr +313 -39
- package/string.md +99 -0
- package/sys/file.gr +1 -1
- package/sys/time.gr +4 -4
package/int32.gr
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Int32: Utilities for working with the Int32 type.
|
|
3
3
|
* @example import Int32 from "int32"
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* @since v0.2.0
|
|
6
6
|
*/
|
|
7
7
|
import WasmI32 from "runtime/unsafe/wasmi32"
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
*
|
|
24
24
|
* @param number: The value to convert
|
|
25
25
|
* @returns The Number represented as an Int32
|
|
26
|
-
*
|
|
26
|
+
*
|
|
27
27
|
* @since v0.2.0
|
|
28
28
|
*/
|
|
29
29
|
export fromNumber
|
|
@@ -33,7 +33,7 @@ export fromNumber
|
|
|
33
33
|
*
|
|
34
34
|
* @param value: The value to convert
|
|
35
35
|
* @returns The Int32 represented as a Number
|
|
36
|
-
*
|
|
36
|
+
*
|
|
37
37
|
* @since v0.2.0
|
|
38
38
|
*/
|
|
39
39
|
export toNumber
|
|
@@ -47,7 +47,7 @@ export toNumber
|
|
|
47
47
|
*
|
|
48
48
|
* @param value: The value to increment
|
|
49
49
|
* @returns The incremented value
|
|
50
|
-
*
|
|
50
|
+
*
|
|
51
51
|
* @since v0.2.0
|
|
52
52
|
*/
|
|
53
53
|
@unsafe
|
|
@@ -62,7 +62,7 @@ export let incr = (value: Int32) => {
|
|
|
62
62
|
*
|
|
63
63
|
* @param value: The value to decrement
|
|
64
64
|
* @returns The decremented value
|
|
65
|
-
*
|
|
65
|
+
*
|
|
66
66
|
* @since v0.2.0
|
|
67
67
|
*/
|
|
68
68
|
@unsafe
|
|
@@ -78,7 +78,7 @@ export let decr = (value: Int32) => {
|
|
|
78
78
|
* @param x: The first operand
|
|
79
79
|
* @param y: The second operand
|
|
80
80
|
* @returns The sum of the two operands
|
|
81
|
-
*
|
|
81
|
+
*
|
|
82
82
|
* @since v0.2.0
|
|
83
83
|
*/
|
|
84
84
|
@unsafe
|
|
@@ -95,7 +95,7 @@ export let add = (x: Int32, y: Int32) => {
|
|
|
95
95
|
* @param x: The first operand
|
|
96
96
|
* @param y: The second operand
|
|
97
97
|
* @returns The difference of the two operands
|
|
98
|
-
*
|
|
98
|
+
*
|
|
99
99
|
* @since v0.2.0
|
|
100
100
|
*/
|
|
101
101
|
@unsafe
|
|
@@ -112,7 +112,7 @@ export let sub = (x: Int32, y: Int32) => {
|
|
|
112
112
|
* @param x: The first operand
|
|
113
113
|
* @param y: The second operand
|
|
114
114
|
* @returns The product of the two operands
|
|
115
|
-
*
|
|
115
|
+
*
|
|
116
116
|
* @since v0.2.0
|
|
117
117
|
*/
|
|
118
118
|
@unsafe
|
|
@@ -129,7 +129,7 @@ export let mul = (x: Int32, y: Int32) => {
|
|
|
129
129
|
* @param x: The first operand
|
|
130
130
|
* @param y: The second operand
|
|
131
131
|
* @returns The quotient of its operands
|
|
132
|
-
*
|
|
132
|
+
*
|
|
133
133
|
* @since v0.2.0
|
|
134
134
|
*/
|
|
135
135
|
@unsafe
|
|
@@ -146,7 +146,7 @@ export let div = (x: Int32, y: Int32) => {
|
|
|
146
146
|
* @param x: The first operand
|
|
147
147
|
* @param y: The second operand
|
|
148
148
|
* @returns The quotient of its operands
|
|
149
|
-
*
|
|
149
|
+
*
|
|
150
150
|
* @since v0.2.0
|
|
151
151
|
*/
|
|
152
152
|
@unsafe
|
|
@@ -163,7 +163,7 @@ export let divU = (x: Int32, y: Int32) => {
|
|
|
163
163
|
* @param x: The first operand
|
|
164
164
|
* @param y: The second operand
|
|
165
165
|
* @returns The remainder of its operands
|
|
166
|
-
*
|
|
166
|
+
*
|
|
167
167
|
* @since v0.2.0
|
|
168
168
|
*/
|
|
169
169
|
@unsafe
|
|
@@ -180,7 +180,7 @@ export let rem = (x: Int32, y: Int32) => {
|
|
|
180
180
|
* @param x: The first operand
|
|
181
181
|
* @param y: The second operand
|
|
182
182
|
* @returns The remainder of its operands
|
|
183
|
-
*
|
|
183
|
+
*
|
|
184
184
|
* @since v0.2.0
|
|
185
185
|
*/
|
|
186
186
|
@unsafe
|
|
@@ -198,13 +198,15 @@ let abs = n => {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
|
-
* Computes the remainder of the division of the first operand by the second.
|
|
201
|
+
* Computes the remainder of the division of the first operand by the second.
|
|
202
202
|
* The result will have the sign of the second operand.
|
|
203
203
|
*
|
|
204
204
|
* @param x: The first operand
|
|
205
205
|
* @param y: The second operand
|
|
206
206
|
* @returns The modulus of its operands
|
|
207
|
-
*
|
|
207
|
+
*
|
|
208
|
+
* @throws ModuloByZero: When `y` is zero
|
|
209
|
+
*
|
|
208
210
|
* @since v0.2.0
|
|
209
211
|
*/
|
|
210
212
|
@unsafe
|
|
@@ -242,7 +244,7 @@ export let mod = (x: Int32, y: Int32) => {
|
|
|
242
244
|
* @param value: The value to rotate
|
|
243
245
|
* @param amount: The number of bits to rotate by
|
|
244
246
|
* @returns The rotated value
|
|
245
|
-
*
|
|
247
|
+
*
|
|
246
248
|
* @since v0.4.0
|
|
247
249
|
*/
|
|
248
250
|
@unsafe
|
|
@@ -259,7 +261,7 @@ export let rotl = (value: Int32, amount: Int32) => {
|
|
|
259
261
|
* @param value: The value to rotate
|
|
260
262
|
* @param amount: The number of bits to rotate by
|
|
261
263
|
* @returns The rotated value
|
|
262
|
-
*
|
|
264
|
+
*
|
|
263
265
|
* @since v0.4.0
|
|
264
266
|
*/
|
|
265
267
|
@unsafe
|
|
@@ -276,7 +278,7 @@ export let rotr = (value: Int32, amount: Int32) => {
|
|
|
276
278
|
* @param value: The value to shift
|
|
277
279
|
* @param amount: The number of bits to shift by
|
|
278
280
|
* @returns The shifted value
|
|
279
|
-
*
|
|
281
|
+
*
|
|
280
282
|
* @since v0.2.0
|
|
281
283
|
*/
|
|
282
284
|
@unsafe
|
|
@@ -293,7 +295,7 @@ export let shl = (value: Int32, amount: Int32) => {
|
|
|
293
295
|
* @param value: The value to shift
|
|
294
296
|
* @param amount: The amount to shift by
|
|
295
297
|
* @returns The shifted value
|
|
296
|
-
*
|
|
298
|
+
*
|
|
297
299
|
* @since v0.2.0
|
|
298
300
|
*/
|
|
299
301
|
@unsafe
|
|
@@ -310,7 +312,7 @@ export let shr = (value: Int32, amount: Int32) => {
|
|
|
310
312
|
* @param value: The value to shift
|
|
311
313
|
* @param amount: The amount to shift by
|
|
312
314
|
* @returns The shifted value
|
|
313
|
-
*
|
|
315
|
+
*
|
|
314
316
|
* @since v0.2.0
|
|
315
317
|
*/
|
|
316
318
|
@unsafe
|
|
@@ -331,7 +333,7 @@ export let shrU = (value: Int32, amount: Int32) => {
|
|
|
331
333
|
* @param x: The first value
|
|
332
334
|
* @param y: The second value
|
|
333
335
|
* @returns `true` if the first value is equal to the second value or `false` otherwise
|
|
334
|
-
*
|
|
336
|
+
*
|
|
335
337
|
* @since v0.4.0
|
|
336
338
|
*/
|
|
337
339
|
@unsafe
|
|
@@ -347,7 +349,7 @@ export let eq = (x: Int32, y: Int32) => {
|
|
|
347
349
|
* @param x: The first value
|
|
348
350
|
* @param y: The second value
|
|
349
351
|
* @returns `true` if the first value is not equal to the second value or `false` otherwise
|
|
350
|
-
*
|
|
352
|
+
*
|
|
351
353
|
* @since v0.4.0
|
|
352
354
|
*/
|
|
353
355
|
@unsafe
|
|
@@ -362,7 +364,7 @@ export let ne = (x: Int32, y: Int32) => {
|
|
|
362
364
|
*
|
|
363
365
|
* @param value: The value to inspect
|
|
364
366
|
* @returns `true` if the first value is equal to zero or `false` otherwise
|
|
365
|
-
*
|
|
367
|
+
*
|
|
366
368
|
* @since v0.4.0
|
|
367
369
|
*/
|
|
368
370
|
@unsafe
|
|
@@ -377,7 +379,7 @@ export let eqz = (value: Int32) => {
|
|
|
377
379
|
* @param x: The first value
|
|
378
380
|
* @param y: The second value
|
|
379
381
|
* @returns `true` if the first value is less than the second value or `false` otherwise
|
|
380
|
-
*
|
|
382
|
+
*
|
|
381
383
|
* @since v0.2.0
|
|
382
384
|
*/
|
|
383
385
|
@unsafe
|
|
@@ -397,7 +399,7 @@ export let lt = (x: Int32, y: Int32) => {
|
|
|
397
399
|
* @since v0.5.0
|
|
398
400
|
*/
|
|
399
401
|
@unsafe
|
|
400
|
-
export let
|
|
402
|
+
export let ltU = (x: Int32, y: Int32) => {
|
|
401
403
|
let xv = WasmI32.load(WasmI32.fromGrain(x), 8n)
|
|
402
404
|
let yv = WasmI32.load(WasmI32.fromGrain(y), 8n)
|
|
403
405
|
WasmI32.ltU(xv, yv)
|
|
@@ -409,7 +411,7 @@ export let rec ltU = (x: Int32, y: Int32) => {
|
|
|
409
411
|
* @param x: The first value
|
|
410
412
|
* @param y: The second value
|
|
411
413
|
* @returns `true` if the first value is greater than the second value or `false` otherwise
|
|
412
|
-
*
|
|
414
|
+
*
|
|
413
415
|
* @since v0.2.0
|
|
414
416
|
*/
|
|
415
417
|
@unsafe
|
|
@@ -429,7 +431,7 @@ export let gt = (x: Int32, y: Int32) => {
|
|
|
429
431
|
* @since v0.5.0
|
|
430
432
|
*/
|
|
431
433
|
@unsafe
|
|
432
|
-
export let
|
|
434
|
+
export let gtU = (x: Int32, y: Int32) => {
|
|
433
435
|
let xv = WasmI32.load(WasmI32.fromGrain(x), 8n)
|
|
434
436
|
let yv = WasmI32.load(WasmI32.fromGrain(y), 8n)
|
|
435
437
|
WasmI32.gtU(xv, yv)
|
|
@@ -441,7 +443,7 @@ export let rec gtU = (x: Int32, y: Int32) => {
|
|
|
441
443
|
* @param x: The first value
|
|
442
444
|
* @param y: The second value
|
|
443
445
|
* @returns `true` if the first value is less than or equal to the second value or `false` otherwise
|
|
444
|
-
*
|
|
446
|
+
*
|
|
445
447
|
* @since v0.2.0
|
|
446
448
|
*/
|
|
447
449
|
@unsafe
|
|
@@ -461,7 +463,7 @@ export let lte = (x: Int32, y: Int32) => {
|
|
|
461
463
|
* @since v0.5.0
|
|
462
464
|
*/
|
|
463
465
|
@unsafe
|
|
464
|
-
export let
|
|
466
|
+
export let lteU = (x: Int32, y: Int32) => {
|
|
465
467
|
let xv = WasmI32.load(WasmI32.fromGrain(x), 8n)
|
|
466
468
|
let yv = WasmI32.load(WasmI32.fromGrain(y), 8n)
|
|
467
469
|
WasmI32.leU(xv, yv)
|
|
@@ -473,7 +475,7 @@ export let rec lteU = (x: Int32, y: Int32) => {
|
|
|
473
475
|
* @param x: The first value
|
|
474
476
|
* @param y: The second value
|
|
475
477
|
* @returns `true` if the first value is greater than or equal to the second value or `false` otherwise
|
|
476
|
-
*
|
|
478
|
+
*
|
|
477
479
|
* @since v0.2.0
|
|
478
480
|
*/
|
|
479
481
|
@unsafe
|
|
@@ -493,7 +495,7 @@ export let gte = (x: Int32, y: Int32) => {
|
|
|
493
495
|
* @since v0.5.0
|
|
494
496
|
*/
|
|
495
497
|
@unsafe
|
|
496
|
-
export let
|
|
498
|
+
export let gteU = (x: Int32, y: Int32) => {
|
|
497
499
|
let xv = WasmI32.load(WasmI32.fromGrain(x), 8n)
|
|
498
500
|
let yv = WasmI32.load(WasmI32.fromGrain(y), 8n)
|
|
499
501
|
WasmI32.geU(xv, yv)
|
|
@@ -508,7 +510,7 @@ export let rec gteU = (x: Int32, y: Int32) => {
|
|
|
508
510
|
*
|
|
509
511
|
* @param value: The given value
|
|
510
512
|
* @returns Containing the inverted bits of the given value
|
|
511
|
-
*
|
|
513
|
+
*
|
|
512
514
|
* @since v0.2.0
|
|
513
515
|
*/
|
|
514
516
|
@unsafe
|
|
@@ -524,7 +526,7 @@ export let lnot = (value: Int32) => {
|
|
|
524
526
|
* @param x: The first operand
|
|
525
527
|
* @param y: The second operand
|
|
526
528
|
* @returns Containing a `1` in each bit position for which the corresponding bits of both operands are `1`
|
|
527
|
-
*
|
|
529
|
+
*
|
|
528
530
|
* @since v0.2.0
|
|
529
531
|
*/
|
|
530
532
|
@unsafe
|
|
@@ -541,7 +543,7 @@ export let land = (x: Int32, y: Int32) => {
|
|
|
541
543
|
* @param x: The first operand
|
|
542
544
|
* @param y: The second operand
|
|
543
545
|
* @returns Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`
|
|
544
|
-
*
|
|
546
|
+
*
|
|
545
547
|
* @since v0.2.0
|
|
546
548
|
*/
|
|
547
549
|
@unsafe
|
|
@@ -558,7 +560,7 @@ export let lor = (x: Int32, y: Int32) => {
|
|
|
558
560
|
* @param x: The first operand
|
|
559
561
|
* @param y: The second operand
|
|
560
562
|
* @returns Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`
|
|
561
|
-
*
|
|
563
|
+
*
|
|
562
564
|
* @since v0.2.0
|
|
563
565
|
*/
|
|
564
566
|
@unsafe
|
|
@@ -574,7 +576,7 @@ export let lxor = (x: Int32, y: Int32) => {
|
|
|
574
576
|
*
|
|
575
577
|
* @param value: The value to inspect
|
|
576
578
|
* @returns The amount of leading zeros
|
|
577
|
-
*
|
|
579
|
+
*
|
|
578
580
|
* @since v0.4.0
|
|
579
581
|
*/
|
|
580
582
|
@unsafe
|
|
@@ -589,7 +591,7 @@ export let clz = (value: Int32) => {
|
|
|
589
591
|
*
|
|
590
592
|
* @param value: The value to inspect
|
|
591
593
|
* @returns The amount of trailing zeros
|
|
592
|
-
*
|
|
594
|
+
*
|
|
593
595
|
* @since v0.4.0
|
|
594
596
|
*/
|
|
595
597
|
@unsafe
|
|
@@ -604,7 +606,7 @@ export let ctz = (value: Int32) => {
|
|
|
604
606
|
*
|
|
605
607
|
* @param value: The value to inspect
|
|
606
608
|
* @returns The amount of 1-bits in its operand
|
|
607
|
-
*
|
|
609
|
+
*
|
|
608
610
|
* @since v0.4.0
|
|
609
611
|
*/
|
|
610
612
|
@unsafe
|
package/int32.md
CHANGED
package/int64.gr
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Int64: Utilities for working with the Int64 type.
|
|
3
3
|
* @example import Int64 from "int64"
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* @since v0.2.0
|
|
6
6
|
*/
|
|
7
7
|
import WasmI32 from "runtime/unsafe/wasmi32"
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
*
|
|
25
25
|
* @param number: The value to convert
|
|
26
26
|
* @returns The Number represented as an Int64
|
|
27
|
-
*
|
|
27
|
+
*
|
|
28
28
|
* @since v0.2.0
|
|
29
29
|
*/
|
|
30
30
|
export fromNumber
|
|
@@ -34,7 +34,7 @@ export fromNumber
|
|
|
34
34
|
*
|
|
35
35
|
* @param value: The value to convert
|
|
36
36
|
* @returns The Int64 represented as a Number
|
|
37
|
-
*
|
|
37
|
+
*
|
|
38
38
|
* @since v0.2.0
|
|
39
39
|
*/
|
|
40
40
|
export toNumber
|
|
@@ -48,7 +48,7 @@ export toNumber
|
|
|
48
48
|
*
|
|
49
49
|
* @param value: The value to increment
|
|
50
50
|
* @returns The incremented value
|
|
51
|
-
*
|
|
51
|
+
*
|
|
52
52
|
* @since v0.2.0
|
|
53
53
|
*/
|
|
54
54
|
@unsafe
|
|
@@ -63,7 +63,7 @@ export let incr = (value: Int64) => {
|
|
|
63
63
|
*
|
|
64
64
|
* @param value: The value to decrement
|
|
65
65
|
* @returns The decremented value
|
|
66
|
-
*
|
|
66
|
+
*
|
|
67
67
|
* @since v0.2.0
|
|
68
68
|
*/
|
|
69
69
|
@unsafe
|
|
@@ -79,7 +79,7 @@ export let decr = (value: Int64) => {
|
|
|
79
79
|
* @param x: The first operand
|
|
80
80
|
* @param y: The second operand
|
|
81
81
|
* @returns The sum of the two operands
|
|
82
|
-
*
|
|
82
|
+
*
|
|
83
83
|
* @since v0.2.0
|
|
84
84
|
*/
|
|
85
85
|
@unsafe
|
|
@@ -96,7 +96,7 @@ export let add = (x: Int64, y: Int64) => {
|
|
|
96
96
|
* @param x: The first operand
|
|
97
97
|
* @param y: The second operand
|
|
98
98
|
* @returns The difference of the two operands
|
|
99
|
-
*
|
|
99
|
+
*
|
|
100
100
|
* @since v0.2.0
|
|
101
101
|
*/
|
|
102
102
|
@unsafe
|
|
@@ -113,7 +113,7 @@ export let sub = (x: Int64, y: Int64) => {
|
|
|
113
113
|
* @param x: The first operand
|
|
114
114
|
* @param y: The second operand
|
|
115
115
|
* @returns The product of the two operands
|
|
116
|
-
*
|
|
116
|
+
*
|
|
117
117
|
* @since v0.2.0
|
|
118
118
|
*/
|
|
119
119
|
@unsafe
|
|
@@ -130,7 +130,7 @@ export let mul = (x: Int64, y: Int64) => {
|
|
|
130
130
|
* @param x: The first operand
|
|
131
131
|
* @param y: The second operand
|
|
132
132
|
* @returns The quotient of its operands
|
|
133
|
-
*
|
|
133
|
+
*
|
|
134
134
|
* @since v0.2.0
|
|
135
135
|
*/
|
|
136
136
|
@unsafe
|
|
@@ -147,7 +147,7 @@ export let div = (x: Int64, y: Int64) => {
|
|
|
147
147
|
* @param x: The first operand
|
|
148
148
|
* @param y: The second operand
|
|
149
149
|
* @returns The quotient of its operands
|
|
150
|
-
*
|
|
150
|
+
*
|
|
151
151
|
* @since v0.2.0
|
|
152
152
|
*/
|
|
153
153
|
@unsafe
|
|
@@ -164,7 +164,7 @@ export let divU = (x: Int64, y: Int64) => {
|
|
|
164
164
|
* @param x: The first operand
|
|
165
165
|
* @param y: The second operand
|
|
166
166
|
* @returns The remainder of its operands
|
|
167
|
-
*
|
|
167
|
+
*
|
|
168
168
|
* @since v0.2.0
|
|
169
169
|
*/
|
|
170
170
|
@unsafe
|
|
@@ -181,7 +181,7 @@ export let rem = (x: Int64, y: Int64) => {
|
|
|
181
181
|
* @param x: The first operand
|
|
182
182
|
* @param y: The second operand
|
|
183
183
|
* @returns The remainder of its operands
|
|
184
|
-
*
|
|
184
|
+
*
|
|
185
185
|
* @since v0.2.0
|
|
186
186
|
*/
|
|
187
187
|
@unsafe
|
|
@@ -199,13 +199,15 @@ let abs = n => {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
|
-
* Computes the remainder of the division of the first operand by the second.
|
|
202
|
+
* Computes the remainder of the division of the first operand by the second.
|
|
203
203
|
* The result will have the sign of the second operand.
|
|
204
204
|
*
|
|
205
205
|
* @param x: The first operand
|
|
206
206
|
* @param y: The second operand
|
|
207
207
|
* @returns The modulus of its operands
|
|
208
|
-
*
|
|
208
|
+
*
|
|
209
|
+
* @throws ModuloByZero: When `y` is zero
|
|
210
|
+
*
|
|
209
211
|
* @since v0.2.0
|
|
210
212
|
*/
|
|
211
213
|
@unsafe
|
|
@@ -243,7 +245,7 @@ export let mod = (x: Int64, y: Int64) => {
|
|
|
243
245
|
* @param value: The value to rotate
|
|
244
246
|
* @param amount: The number of bits to rotate by
|
|
245
247
|
* @returns The rotated value
|
|
246
|
-
*
|
|
248
|
+
*
|
|
247
249
|
* @since v0.4.0
|
|
248
250
|
*/
|
|
249
251
|
@unsafe
|
|
@@ -260,7 +262,7 @@ export let rotl = (value: Int64, amount: Int64) => {
|
|
|
260
262
|
* @param value: The value to rotate
|
|
261
263
|
* @param amount: The number of bits to rotate by
|
|
262
264
|
* @returns The rotated value
|
|
263
|
-
*
|
|
265
|
+
*
|
|
264
266
|
* @since v0.4.0
|
|
265
267
|
*/
|
|
266
268
|
@unsafe
|
|
@@ -277,7 +279,7 @@ export let rotr = (value: Int64, amount: Int64) => {
|
|
|
277
279
|
* @param value: The value to shift
|
|
278
280
|
* @param amount: The number of bits to shift by
|
|
279
281
|
* @returns The shifted value
|
|
280
|
-
*
|
|
282
|
+
*
|
|
281
283
|
* @since v0.2.0
|
|
282
284
|
*/
|
|
283
285
|
@unsafe
|
|
@@ -294,7 +296,7 @@ export let shl = (value: Int64, amount: Int64) => {
|
|
|
294
296
|
* @param value: The value to shift
|
|
295
297
|
* @param amount: The amount to shift by
|
|
296
298
|
* @returns The shifted value
|
|
297
|
-
*
|
|
299
|
+
*
|
|
298
300
|
* @since v0.2.0
|
|
299
301
|
*/
|
|
300
302
|
@unsafe
|
|
@@ -311,7 +313,7 @@ export let shr = (value: Int64, amount: Int64) => {
|
|
|
311
313
|
* @param value: The value to shift
|
|
312
314
|
* @param amount: The amount to shift by
|
|
313
315
|
* @returns The shifted value
|
|
314
|
-
*
|
|
316
|
+
*
|
|
315
317
|
* @since v0.2.0
|
|
316
318
|
*/
|
|
317
319
|
@unsafe
|
|
@@ -332,7 +334,7 @@ export let shrU = (value: Int64, amount: Int64) => {
|
|
|
332
334
|
* @param x: The first value
|
|
333
335
|
* @param y: The second value
|
|
334
336
|
* @returns `true` if the first value is equal to the second value or `false` otherwise
|
|
335
|
-
*
|
|
337
|
+
*
|
|
336
338
|
* @since v0.4.0
|
|
337
339
|
*/
|
|
338
340
|
@unsafe
|
|
@@ -348,7 +350,7 @@ export let eq = (x: Int64, y: Int64) => {
|
|
|
348
350
|
* @param x: The first value
|
|
349
351
|
* @param y: The second value
|
|
350
352
|
* @returns `true` if the first value is not equal to the second value or `false` otherwise
|
|
351
|
-
*
|
|
353
|
+
*
|
|
352
354
|
* @since v0.4.0
|
|
353
355
|
*/
|
|
354
356
|
@unsafe
|
|
@@ -363,7 +365,7 @@ export let ne = (x: Int64, y: Int64) => {
|
|
|
363
365
|
*
|
|
364
366
|
* @param value: The value to inspect
|
|
365
367
|
* @returns `true` if the first value is equal to zero or `false` otherwise
|
|
366
|
-
*
|
|
368
|
+
*
|
|
367
369
|
* @since v0.4.0
|
|
368
370
|
*/
|
|
369
371
|
@unsafe
|
|
@@ -378,7 +380,7 @@ export let eqz = (value: Int64) => {
|
|
|
378
380
|
* @param x: The first value
|
|
379
381
|
* @param y: The second value
|
|
380
382
|
* @returns `true` if the first value is less than the second value or `false` otherwise
|
|
381
|
-
*
|
|
383
|
+
*
|
|
382
384
|
* @since v0.2.0
|
|
383
385
|
*/
|
|
384
386
|
@unsafe
|
|
@@ -398,7 +400,7 @@ export let lt = (x: Int64, y: Int64) => {
|
|
|
398
400
|
* @since v0.5.0
|
|
399
401
|
*/
|
|
400
402
|
@unsafe
|
|
401
|
-
export let
|
|
403
|
+
export let ltU = (x: Int64, y: Int64) => {
|
|
402
404
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
403
405
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
404
406
|
WasmI64.ltU(xv, yv)
|
|
@@ -410,7 +412,7 @@ export let rec ltU = (x: Int64, y: Int64) => {
|
|
|
410
412
|
* @param x: The first value
|
|
411
413
|
* @param y: The second value
|
|
412
414
|
* @returns `true` if the first value is greater than the second value or `false` otherwise
|
|
413
|
-
*
|
|
415
|
+
*
|
|
414
416
|
* @since v0.2.0
|
|
415
417
|
*/
|
|
416
418
|
@unsafe
|
|
@@ -430,7 +432,7 @@ export let gt = (x: Int64, y: Int64) => {
|
|
|
430
432
|
* @since v0.5.0
|
|
431
433
|
*/
|
|
432
434
|
@unsafe
|
|
433
|
-
export let
|
|
435
|
+
export let gtU = (x: Int64, y: Int64) => {
|
|
434
436
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
435
437
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
436
438
|
WasmI64.gtU(xv, yv)
|
|
@@ -442,7 +444,7 @@ export let rec gtU = (x: Int64, y: Int64) => {
|
|
|
442
444
|
* @param x: The first value
|
|
443
445
|
* @param y: The second value
|
|
444
446
|
* @returns `true` if the first value is less than or equal to the second value or `false` otherwise
|
|
445
|
-
*
|
|
447
|
+
*
|
|
446
448
|
* @since v0.2.0
|
|
447
449
|
*/
|
|
448
450
|
@unsafe
|
|
@@ -462,7 +464,7 @@ export let lte = (x: Int64, y: Int64) => {
|
|
|
462
464
|
* @since v0.5.0
|
|
463
465
|
*/
|
|
464
466
|
@unsafe
|
|
465
|
-
export let
|
|
467
|
+
export let lteU = (x: Int64, y: Int64) => {
|
|
466
468
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
467
469
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
468
470
|
WasmI64.leU(xv, yv)
|
|
@@ -474,7 +476,7 @@ export let rec lteU = (x: Int64, y: Int64) => {
|
|
|
474
476
|
* @param x: The first value
|
|
475
477
|
* @param y: The second value
|
|
476
478
|
* @returns `true` if the first value is greater than or equal to the second value or `false` otherwise
|
|
477
|
-
*
|
|
479
|
+
*
|
|
478
480
|
* @since v0.2.0
|
|
479
481
|
*/
|
|
480
482
|
@unsafe
|
|
@@ -494,7 +496,7 @@ export let gte = (x: Int64, y: Int64) => {
|
|
|
494
496
|
* @since v0.5.0
|
|
495
497
|
*/
|
|
496
498
|
@unsafe
|
|
497
|
-
export let
|
|
499
|
+
export let gteU = (x: Int64, y: Int64) => {
|
|
498
500
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
499
501
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
500
502
|
WasmI64.geU(xv, yv)
|
|
@@ -509,7 +511,7 @@ export let rec gteU = (x: Int64, y: Int64) => {
|
|
|
509
511
|
*
|
|
510
512
|
* @param value: The given value
|
|
511
513
|
* @returns Containing the inverted bits of the given value
|
|
512
|
-
*
|
|
514
|
+
*
|
|
513
515
|
* @since v0.2.0
|
|
514
516
|
*/
|
|
515
517
|
@unsafe
|
|
@@ -525,7 +527,7 @@ export let lnot = (value: Int64) => {
|
|
|
525
527
|
* @param x: The first operand
|
|
526
528
|
* @param y: The second operand
|
|
527
529
|
* @returns Containing a `1` in each bit position for which the corresponding bits of both operands are `1`
|
|
528
|
-
*
|
|
530
|
+
*
|
|
529
531
|
* @since v0.2.0
|
|
530
532
|
*/
|
|
531
533
|
@unsafe
|
|
@@ -542,7 +544,7 @@ export let land = (x: Int64, y: Int64) => {
|
|
|
542
544
|
* @param x: The first operand
|
|
543
545
|
* @param y: The second operand
|
|
544
546
|
* @returns Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`
|
|
545
|
-
*
|
|
547
|
+
*
|
|
546
548
|
* @since v0.2.0
|
|
547
549
|
*/
|
|
548
550
|
@unsafe
|
|
@@ -559,7 +561,7 @@ export let lor = (x: Int64, y: Int64) => {
|
|
|
559
561
|
* @param x: The first operand
|
|
560
562
|
* @param y: The second operand
|
|
561
563
|
* @returns Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`
|
|
562
|
-
*
|
|
564
|
+
*
|
|
563
565
|
* @since v0.2.0
|
|
564
566
|
*/
|
|
565
567
|
@unsafe
|
|
@@ -575,7 +577,7 @@ export let lxor = (x: Int64, y: Int64) => {
|
|
|
575
577
|
*
|
|
576
578
|
* @param value: The value to inspect
|
|
577
579
|
* @returns The amount of leading zeros
|
|
578
|
-
*
|
|
580
|
+
*
|
|
579
581
|
* @since v0.4.0
|
|
580
582
|
*/
|
|
581
583
|
@unsafe
|
|
@@ -590,7 +592,7 @@ export let clz = (value: Int64) => {
|
|
|
590
592
|
*
|
|
591
593
|
* @param value: The value to inspect
|
|
592
594
|
* @returns The amount of trailing zeros
|
|
593
|
-
*
|
|
595
|
+
*
|
|
594
596
|
* @since v0.4.0
|
|
595
597
|
*/
|
|
596
598
|
@unsafe
|
|
@@ -605,7 +607,7 @@ export let ctz = (value: Int64) => {
|
|
|
605
607
|
*
|
|
606
608
|
* @param value: The value to inspect
|
|
607
609
|
* @returns The amount of 1-bits in its operand
|
|
608
|
-
*
|
|
610
|
+
*
|
|
609
611
|
* @since v0.4.0
|
|
610
612
|
*/
|
|
611
613
|
@unsafe
|
package/int64.md
CHANGED