@grain/stdlib 0.5.4 → 0.5.6
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 +30 -0
- package/array.gr +60 -57
- package/array.md +24 -6
- package/buffer.gr +71 -1
- package/buffer.md +142 -0
- package/bytes.gr +52 -3
- package/bytes.md +117 -0
- package/char.gr +21 -18
- package/char.md +18 -3
- package/immutablepriorityqueue.gr +13 -13
- package/int32.gr +39 -37
- package/int32.md +6 -0
- package/int64.gr +39 -37
- package/int64.md +6 -0
- package/list.gr +31 -22
- package/list.md +39 -10
- package/map.gr +19 -28
- package/number.gr +81 -5
- package/number.md +64 -2
- 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/queue.gr +11 -9
- package/queue.md +2 -0
- package/regex.gr +76 -3
- 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 +3 -3
- package/runtime/equal.gr +1 -1
- package/runtime/numberUtils.gr +2 -2
- package/runtime/numberUtils.md +6 -0
- package/runtime/numbers.gr +4 -4
- 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/stack.gr +4 -2
- package/stack.md +2 -0
- package/string.gr +1 -1
- package/sys/time.gr +4 -4
package/buffer.md
CHANGED
|
@@ -47,6 +47,12 @@ Returns:
|
|
|
47
47
|
|----|-----------|
|
|
48
48
|
|`Buffer`|The new buffer|
|
|
49
49
|
|
|
50
|
+
Throws:
|
|
51
|
+
|
|
52
|
+
`InvalidArgument(String)`
|
|
53
|
+
|
|
54
|
+
* When the `initialSize` is a negative number
|
|
55
|
+
|
|
50
56
|
### Buffer.**length**
|
|
51
57
|
|
|
52
58
|
<details disabled>
|
|
@@ -136,6 +142,13 @@ Parameters:
|
|
|
136
142
|
|`length`|`Number`|The number of bytes to truncate the buffer to|
|
|
137
143
|
|`buffer`|`Buffer`|The buffer to truncate|
|
|
138
144
|
|
|
145
|
+
Throws:
|
|
146
|
+
|
|
147
|
+
`IndexOutOfBounds`
|
|
148
|
+
|
|
149
|
+
* When the `length` is negative
|
|
150
|
+
* When the `length` is greater than the buffer size
|
|
151
|
+
|
|
139
152
|
### Buffer.**toBytes**
|
|
140
153
|
|
|
141
154
|
<details disabled>
|
|
@@ -188,6 +201,14 @@ Returns:
|
|
|
188
201
|
|----|-----------|
|
|
189
202
|
|`Bytes`|A byte sequence with bytes copied from the buffer|
|
|
190
203
|
|
|
204
|
+
Throws:
|
|
205
|
+
|
|
206
|
+
`IndexOutOfBounds`
|
|
207
|
+
|
|
208
|
+
* When `start` is negative
|
|
209
|
+
* When `start` is greater than or equal to the buffer size
|
|
210
|
+
* When `start + length` is greater than the buffer size
|
|
211
|
+
|
|
191
212
|
### Buffer.**toString**
|
|
192
213
|
|
|
193
214
|
<details disabled>
|
|
@@ -351,6 +372,15 @@ Parameters:
|
|
|
351
372
|
|`bytes`|`Bytes`|The byte sequence to append|
|
|
352
373
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
353
374
|
|
|
375
|
+
Throws:
|
|
376
|
+
|
|
377
|
+
`IndexOutOfBounds`
|
|
378
|
+
|
|
379
|
+
* When the `start` is negative
|
|
380
|
+
* When the `start` is greater than or equal to the `bytes` size
|
|
381
|
+
* When the `length` is negative
|
|
382
|
+
* When the `length` is greater than the `bytes` length minus `start`
|
|
383
|
+
|
|
354
384
|
### Buffer.**addBuffer**
|
|
355
385
|
|
|
356
386
|
<details disabled>
|
|
@@ -427,6 +457,14 @@ Returns:
|
|
|
427
457
|
|----|-----------|
|
|
428
458
|
|`Int32`|A 32-bit integer representing a signed 8-bit integer that starts at the given index|
|
|
429
459
|
|
|
460
|
+
Throws:
|
|
461
|
+
|
|
462
|
+
`IndexOutOfBounds`
|
|
463
|
+
|
|
464
|
+
* When `index` is negative
|
|
465
|
+
* When `index` is greater than or equal to the buffer size
|
|
466
|
+
* When `index + 1` is greater than the buffer size
|
|
467
|
+
|
|
430
468
|
### Buffer.**getInt8U**
|
|
431
469
|
|
|
432
470
|
<details disabled>
|
|
@@ -453,6 +491,14 @@ Returns:
|
|
|
453
491
|
|----|-----------|
|
|
454
492
|
|`Int32`|A 32-bit integer representing an unsigned 8-bit integer that starts at the given index|
|
|
455
493
|
|
|
494
|
+
Throws:
|
|
495
|
+
|
|
496
|
+
`IndexOutOfBounds`
|
|
497
|
+
|
|
498
|
+
* When `index` is negative
|
|
499
|
+
* When `index` is greater than or equal to the buffer size
|
|
500
|
+
* When `index + 1` is greater than the buffer size
|
|
501
|
+
|
|
456
502
|
### Buffer.**setInt8**
|
|
457
503
|
|
|
458
504
|
<details disabled>
|
|
@@ -474,6 +520,14 @@ Parameters:
|
|
|
474
520
|
|`value`|`Int32`|The value to set|
|
|
475
521
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
476
522
|
|
|
523
|
+
Throws:
|
|
524
|
+
|
|
525
|
+
`IndexOutOfBounds`
|
|
526
|
+
|
|
527
|
+
* When `index` is negative
|
|
528
|
+
* When `index` is greater than or equal to the buffer size
|
|
529
|
+
* When `index + 1` is greater than the buffer size
|
|
530
|
+
|
|
477
531
|
### Buffer.**addInt8**
|
|
478
532
|
|
|
479
533
|
<details disabled>
|
|
@@ -520,6 +574,14 @@ Returns:
|
|
|
520
574
|
|----|-----------|
|
|
521
575
|
|`Int32`|A 32-bit integer representing a signed 16-bit integer that starts at the given index|
|
|
522
576
|
|
|
577
|
+
Throws:
|
|
578
|
+
|
|
579
|
+
`IndexOutOfBounds`
|
|
580
|
+
|
|
581
|
+
* When `index` is negative
|
|
582
|
+
* When `index` is greater than or equal to the buffer size
|
|
583
|
+
* When `index + 2` is greater than the buffer size
|
|
584
|
+
|
|
523
585
|
### Buffer.**getInt16U**
|
|
524
586
|
|
|
525
587
|
<details disabled>
|
|
@@ -546,6 +608,14 @@ Returns:
|
|
|
546
608
|
|----|-----------|
|
|
547
609
|
|`Int32`|A 32-bit integer representing an unsigned 16-bit integer that starts at the given index|
|
|
548
610
|
|
|
611
|
+
Throws:
|
|
612
|
+
|
|
613
|
+
`IndexOutOfBounds`
|
|
614
|
+
|
|
615
|
+
* When `index` is negative
|
|
616
|
+
* When `index` is greater than or equal to the buffer size
|
|
617
|
+
* When `index + 2` is greater than the buffer size
|
|
618
|
+
|
|
549
619
|
### Buffer.**setInt16**
|
|
550
620
|
|
|
551
621
|
<details disabled>
|
|
@@ -567,6 +637,14 @@ Parameters:
|
|
|
567
637
|
|`value`|`Int32`|The value to set|
|
|
568
638
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
569
639
|
|
|
640
|
+
Throws:
|
|
641
|
+
|
|
642
|
+
`IndexOutOfBounds`
|
|
643
|
+
|
|
644
|
+
* When `index` is negative
|
|
645
|
+
* When `index` is greater than or equal to the buffer size
|
|
646
|
+
* When `index + 2` is greater than the buffer size
|
|
647
|
+
|
|
570
648
|
### Buffer.**addInt16**
|
|
571
649
|
|
|
572
650
|
<details disabled>
|
|
@@ -613,6 +691,14 @@ Returns:
|
|
|
613
691
|
|----|-----------|
|
|
614
692
|
|`Int32`|A signed 32-bit integer that starts at the given index|
|
|
615
693
|
|
|
694
|
+
Throws:
|
|
695
|
+
|
|
696
|
+
`IndexOutOfBounds`
|
|
697
|
+
|
|
698
|
+
* When `index` is negative
|
|
699
|
+
* When `index` is greater than or equal to the buffer size
|
|
700
|
+
* When `index + 4` is greater than the buffer size
|
|
701
|
+
|
|
616
702
|
### Buffer.**setInt32**
|
|
617
703
|
|
|
618
704
|
<details disabled>
|
|
@@ -634,6 +720,14 @@ Parameters:
|
|
|
634
720
|
|`value`|`Int32`|The value to set|
|
|
635
721
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
636
722
|
|
|
723
|
+
Throws:
|
|
724
|
+
|
|
725
|
+
`IndexOutOfBounds`
|
|
726
|
+
|
|
727
|
+
* When `index` is negative
|
|
728
|
+
* When `index` is greater than or equal to the buffer size
|
|
729
|
+
* When `index + 4` is greater than the buffer size
|
|
730
|
+
|
|
637
731
|
### Buffer.**addInt32**
|
|
638
732
|
|
|
639
733
|
<details disabled>
|
|
@@ -680,6 +774,14 @@ Returns:
|
|
|
680
774
|
|----|-----------|
|
|
681
775
|
|`Float32`|A 32-bit float that starts at the given index|
|
|
682
776
|
|
|
777
|
+
Throws:
|
|
778
|
+
|
|
779
|
+
`IndexOutOfBounds`
|
|
780
|
+
|
|
781
|
+
* When `index` is negative
|
|
782
|
+
* When `index` is greater than or equal to the buffer size
|
|
783
|
+
* When `index + 4` is greater than the buffer size
|
|
784
|
+
|
|
683
785
|
### Buffer.**setFloat32**
|
|
684
786
|
|
|
685
787
|
<details disabled>
|
|
@@ -701,6 +803,14 @@ Parameters:
|
|
|
701
803
|
|`value`|`Float32`|The value to set|
|
|
702
804
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
703
805
|
|
|
806
|
+
Throws:
|
|
807
|
+
|
|
808
|
+
`IndexOutOfBounds`
|
|
809
|
+
|
|
810
|
+
* When `index` is negative
|
|
811
|
+
* When `index` is greater than or equal to the buffer size
|
|
812
|
+
* When `index + 4` is greater than the buffer size
|
|
813
|
+
|
|
704
814
|
### Buffer.**addFloat32**
|
|
705
815
|
|
|
706
816
|
<details disabled>
|
|
@@ -747,6 +857,14 @@ Returns:
|
|
|
747
857
|
|----|-----------|
|
|
748
858
|
|`Int64`|A signed 64-bit integer that starts at the given index|
|
|
749
859
|
|
|
860
|
+
Throws:
|
|
861
|
+
|
|
862
|
+
`IndexOutOfBounds`
|
|
863
|
+
|
|
864
|
+
* When `index` is negative
|
|
865
|
+
* When `index` is greater than or equal to the buffer size
|
|
866
|
+
* When `index + 8` is greater than the buffer size
|
|
867
|
+
|
|
750
868
|
### Buffer.**setInt64**
|
|
751
869
|
|
|
752
870
|
<details disabled>
|
|
@@ -768,6 +886,14 @@ Parameters:
|
|
|
768
886
|
|`value`|`Int64`|The value to set|
|
|
769
887
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
770
888
|
|
|
889
|
+
Throws:
|
|
890
|
+
|
|
891
|
+
`IndexOutOfBounds`
|
|
892
|
+
|
|
893
|
+
* When `index` is negative
|
|
894
|
+
* When `index` is greater than or equal to the buffer size
|
|
895
|
+
* When `index + 8` is greater than the buffer size
|
|
896
|
+
|
|
771
897
|
### Buffer.**addInt64**
|
|
772
898
|
|
|
773
899
|
<details disabled>
|
|
@@ -814,6 +940,14 @@ Returns:
|
|
|
814
940
|
|----|-----------|
|
|
815
941
|
|`Float64`|A 64-bit float that starts at the given index|
|
|
816
942
|
|
|
943
|
+
Throws:
|
|
944
|
+
|
|
945
|
+
`IndexOutOfBounds`
|
|
946
|
+
|
|
947
|
+
* When `index` is negative
|
|
948
|
+
* When `index` is greater than or equal to the buffer size
|
|
949
|
+
* When `index + 8` is greater than the buffer size
|
|
950
|
+
|
|
817
951
|
### Buffer.**setFloat64**
|
|
818
952
|
|
|
819
953
|
<details disabled>
|
|
@@ -835,6 +969,14 @@ Parameters:
|
|
|
835
969
|
|`value`|`Float64`|The value to set|
|
|
836
970
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
837
971
|
|
|
972
|
+
Throws:
|
|
973
|
+
|
|
974
|
+
`IndexOutOfBounds`
|
|
975
|
+
|
|
976
|
+
* When `index` is negative
|
|
977
|
+
* When `index` is greater than or equal to the buffer size
|
|
978
|
+
* When `index + 8` is greater than the buffer size
|
|
979
|
+
|
|
838
980
|
### Buffer.**addFloat64**
|
|
839
981
|
|
|
840
982
|
<details disabled>
|
package/bytes.gr
CHANGED
|
@@ -153,6 +153,8 @@ export let copy = (b: Bytes) => {
|
|
|
153
153
|
* @param bytes: The byte sequence to copy from
|
|
154
154
|
* @returns A byte sequence with of the copied bytes
|
|
155
155
|
*
|
|
156
|
+
* @throws InvalidArgument(String): When `start + length` is greater than the bytes size
|
|
157
|
+
*
|
|
156
158
|
* @since v0.3.2
|
|
157
159
|
*/
|
|
158
160
|
@unsafe
|
|
@@ -186,6 +188,8 @@ export let slice = (start: Number, length: Number, bytes: Bytes) => {
|
|
|
186
188
|
* @param bytes: The byte sequence get a subset of bytes from
|
|
187
189
|
* @returns A resized byte sequence
|
|
188
190
|
*
|
|
191
|
+
* @throws InvalidArgument(String): When the new size is negative
|
|
192
|
+
*
|
|
189
193
|
* @since v0.3.2
|
|
190
194
|
*/
|
|
191
195
|
@unsafe
|
|
@@ -241,6 +245,9 @@ export let resize = (left: Number, right: Number, bytes: Bytes) => {
|
|
|
241
245
|
* @param src: The source byte sequence
|
|
242
246
|
* @param dst: The destination byte sequence
|
|
243
247
|
*
|
|
248
|
+
* @throws InvalidArgument(String): When `srcIndex + length` is greater than the `src` bytes size
|
|
249
|
+
* @throws InvalidArgument(String): When the `dstIndex + length` is greater than the `dst` bytes size
|
|
250
|
+
*
|
|
244
251
|
* @since v0.3.2
|
|
245
252
|
*/
|
|
246
253
|
@unsafe
|
|
@@ -338,6 +345,9 @@ export let clear = (bytes: Bytes) => {
|
|
|
338
345
|
* @param bytes: The byte sequence to access
|
|
339
346
|
* @returns A 32-bit integer representing a signed 8-bit integer that starts at the given index
|
|
340
347
|
*
|
|
348
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
349
|
+
* @throws IndexOutOfBounds: When `index + 1` is greater than the bytes size
|
|
350
|
+
*
|
|
341
351
|
* @since v0.3.2
|
|
342
352
|
*/
|
|
343
353
|
@unsafe
|
|
@@ -358,10 +368,13 @@ export let getInt8S = (index: Number, bytes: Bytes) => {
|
|
|
358
368
|
* @param bytes: The byte sequence to access
|
|
359
369
|
* @returns A 32-bit integer representing an unsigned 8-bit integer that starts at the given index
|
|
360
370
|
*
|
|
371
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
372
|
+
* @throws IndexOutOfBounds: When `index + 1` is greater than the bytes size
|
|
373
|
+
*
|
|
361
374
|
* @since v0.3.2
|
|
362
375
|
*/
|
|
363
376
|
@unsafe
|
|
364
|
-
export let
|
|
377
|
+
export let getInt8U = (index: Number, bytes: Bytes) => {
|
|
365
378
|
let (+) = WasmI32.add
|
|
366
379
|
let ptr = WasmI32.fromGrain(bytes)
|
|
367
380
|
let size = getSize(ptr)
|
|
@@ -378,10 +391,13 @@ export let rec getInt8U = (index: Number, bytes: Bytes) => {
|
|
|
378
391
|
* @param value: The value to set
|
|
379
392
|
* @param bytes: The byte sequence to mutate
|
|
380
393
|
*
|
|
394
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
395
|
+
* @throws IndexOutOfBounds: When `index + 1` is greater than the bytes size
|
|
396
|
+
*
|
|
381
397
|
* @since v0.3.2
|
|
382
398
|
*/
|
|
383
399
|
@unsafe
|
|
384
|
-
export let
|
|
400
|
+
export let setInt8 = (index: Number, value: Int32, bytes: Bytes) => {
|
|
385
401
|
let (+) = WasmI32.add
|
|
386
402
|
let ptr = WasmI32.fromGrain(bytes)
|
|
387
403
|
let size = getSize(ptr)
|
|
@@ -398,6 +414,9 @@ export let rec setInt8 = (index: Number, value: Int32, bytes: Bytes) => {
|
|
|
398
414
|
* @param bytes: The byte sequence to access
|
|
399
415
|
* @returns A 32-bit integer representing a signed 16-bit integer that starts at the given index
|
|
400
416
|
*
|
|
417
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
418
|
+
* @throws IndexOutOfBounds: When `index + 2` is greater than the bytes size
|
|
419
|
+
*
|
|
401
420
|
* @since v0.3.2
|
|
402
421
|
*/
|
|
403
422
|
@unsafe
|
|
@@ -418,6 +437,9 @@ export let getInt16S = (index: Number, bytes: Bytes) => {
|
|
|
418
437
|
* @param bytes: The byte sequence to access
|
|
419
438
|
* @returns A 32-bit integer representing an unsigned 16-bit integer that starts at the given index
|
|
420
439
|
*
|
|
440
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
441
|
+
* @throws IndexOutOfBounds: When `index + 2` is greater than the bytes size
|
|
442
|
+
*
|
|
421
443
|
* @since v0.3.2
|
|
422
444
|
*/
|
|
423
445
|
@unsafe
|
|
@@ -438,6 +460,9 @@ export let getInt16U = (index: Number, bytes: Bytes) => {
|
|
|
438
460
|
* @param value: The value to set
|
|
439
461
|
* @param bytes: The byte sequence to mutate
|
|
440
462
|
*
|
|
463
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
464
|
+
* @throws IndexOutOfBounds: When `index + 2` is greater than the bytes size
|
|
465
|
+
*
|
|
441
466
|
* @since v0.3.2
|
|
442
467
|
*/
|
|
443
468
|
@unsafe
|
|
@@ -458,6 +483,9 @@ export let setInt16 = (index: Number, value: Int32, bytes: Bytes) => {
|
|
|
458
483
|
* @param bytes: The byte sequence to access
|
|
459
484
|
* @returns A signed 32-bit integer that starts at the given index
|
|
460
485
|
*
|
|
486
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
487
|
+
* @throws IndexOutOfBounds: When `index + 4` is greater than the bytes size
|
|
488
|
+
*
|
|
461
489
|
* @since v0.3.2
|
|
462
490
|
*/
|
|
463
491
|
@unsafe
|
|
@@ -478,6 +506,9 @@ export let getInt32 = (index: Number, bytes: Bytes) => {
|
|
|
478
506
|
* @param value: The value to set
|
|
479
507
|
* @param bytes: The byte sequence to mutate
|
|
480
508
|
*
|
|
509
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
510
|
+
* @throws IndexOutOfBounds: When `index + 4` is greater than the bytes size
|
|
511
|
+
*
|
|
481
512
|
* @since v0.3.2
|
|
482
513
|
*/
|
|
483
514
|
@unsafe
|
|
@@ -498,6 +529,9 @@ export let setInt32 = (index: Number, value: Int32, bytes: Bytes) => {
|
|
|
498
529
|
* @param bytes: The byte sequence to access
|
|
499
530
|
* @returns A 32-bit float that starts at the given index
|
|
500
531
|
*
|
|
532
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
533
|
+
* @throws IndexOutOfBounds: When `index + 4` is greater than the bytes size
|
|
534
|
+
*
|
|
501
535
|
* @since v0.3.2
|
|
502
536
|
*/
|
|
503
537
|
@unsafe
|
|
@@ -518,6 +552,9 @@ export let getFloat32 = (index: Number, bytes: Bytes) => {
|
|
|
518
552
|
* @param value: The value to set
|
|
519
553
|
* @param bytes: The byte sequence to mutate
|
|
520
554
|
*
|
|
555
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
556
|
+
* @throws IndexOutOfBounds: When `index + 4` is greater than the bytes size
|
|
557
|
+
*
|
|
521
558
|
* @since v0.3.2
|
|
522
559
|
*/
|
|
523
560
|
@unsafe
|
|
@@ -538,6 +575,9 @@ export let setFloat32 = (index: Number, value: Float32, bytes: Bytes) => {
|
|
|
538
575
|
* @param bytes: The byte sequence to access
|
|
539
576
|
* @returns A signed 64-bit integer that starts at the given index
|
|
540
577
|
*
|
|
578
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
579
|
+
* @throws IndexOutOfBounds: When `index + 8` is greater than the bytes size
|
|
580
|
+
*
|
|
541
581
|
* @since v0.3.2
|
|
542
582
|
*/
|
|
543
583
|
@unsafe
|
|
@@ -558,6 +598,9 @@ export let getInt64 = (index: Number, bytes: Bytes) => {
|
|
|
558
598
|
* @param value: The value to set
|
|
559
599
|
* @param bytes: The byte sequence to mutate
|
|
560
600
|
*
|
|
601
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
602
|
+
* @throws IndexOutOfBounds: When `index + 8` is greater than the bytes size
|
|
603
|
+
*
|
|
561
604
|
* @since v0.3.2
|
|
562
605
|
*/
|
|
563
606
|
@unsafe
|
|
@@ -578,6 +621,9 @@ export let setInt64 = (index: Number, value: Int64, bytes: Bytes) => {
|
|
|
578
621
|
* @param bytes: The byte sequence to access
|
|
579
622
|
* @returns A 64-bit float that starts at the given index
|
|
580
623
|
*
|
|
624
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
625
|
+
* @throws IndexOutOfBounds: When `index + 8` is greater than the bytes size
|
|
626
|
+
*
|
|
581
627
|
* @since v0.3.2
|
|
582
628
|
*/
|
|
583
629
|
@unsafe
|
|
@@ -598,10 +644,13 @@ export let getFloat64 = (index: Number, bytes: Bytes) => {
|
|
|
598
644
|
* @param value: The value to set
|
|
599
645
|
* @param bytes: The byte sequence to mutate
|
|
600
646
|
*
|
|
647
|
+
* @throws IndexOutOfBounds: When `index` is negative
|
|
648
|
+
* @throws IndexOutOfBounds: When `index + 8` is greater than the bytes size
|
|
649
|
+
*
|
|
601
650
|
* @since v0.3.2
|
|
602
651
|
*/
|
|
603
652
|
@unsafe
|
|
604
|
-
export let
|
|
653
|
+
export let setFloat64 = (index: Number, value: Float64, bytes: Bytes) => {
|
|
605
654
|
let (+) = WasmI32.add
|
|
606
655
|
let ptr = WasmI32.fromGrain(bytes)
|
|
607
656
|
let size = getSize(ptr)
|
package/bytes.md
CHANGED
|
@@ -182,6 +182,12 @@ Returns:
|
|
|
182
182
|
|----|-----------|
|
|
183
183
|
|`Bytes`|A byte sequence with of the copied bytes|
|
|
184
184
|
|
|
185
|
+
Throws:
|
|
186
|
+
|
|
187
|
+
`InvalidArgument(String)`
|
|
188
|
+
|
|
189
|
+
* When `start + length` is greater than the bytes size
|
|
190
|
+
|
|
185
191
|
### Bytes.**resize**
|
|
186
192
|
|
|
187
193
|
<details disabled>
|
|
@@ -211,6 +217,12 @@ Returns:
|
|
|
211
217
|
|----|-----------|
|
|
212
218
|
|`Bytes`|A resized byte sequence|
|
|
213
219
|
|
|
220
|
+
Throws:
|
|
221
|
+
|
|
222
|
+
`InvalidArgument(String)`
|
|
223
|
+
|
|
224
|
+
* When the new size is negative
|
|
225
|
+
|
|
214
226
|
### Bytes.**move**
|
|
215
227
|
|
|
216
228
|
<details disabled>
|
|
@@ -235,6 +247,13 @@ Parameters:
|
|
|
235
247
|
|`src`|`Bytes`|The source byte sequence|
|
|
236
248
|
|`dst`|`Bytes`|The destination byte sequence|
|
|
237
249
|
|
|
250
|
+
Throws:
|
|
251
|
+
|
|
252
|
+
`InvalidArgument(String)`
|
|
253
|
+
|
|
254
|
+
* When `srcIndex + length` is greater than the `src` bytes size
|
|
255
|
+
* When the `dstIndex + length` is greater than the `dst` bytes size
|
|
256
|
+
|
|
238
257
|
### Bytes.**concat**
|
|
239
258
|
|
|
240
259
|
<details disabled>
|
|
@@ -330,6 +349,13 @@ Returns:
|
|
|
330
349
|
|----|-----------|
|
|
331
350
|
|`Int32`|A 32-bit integer representing a signed 8-bit integer that starts at the given index|
|
|
332
351
|
|
|
352
|
+
Throws:
|
|
353
|
+
|
|
354
|
+
`IndexOutOfBounds`
|
|
355
|
+
|
|
356
|
+
* When `index` is negative
|
|
357
|
+
* When `index + 1` is greater than the bytes size
|
|
358
|
+
|
|
333
359
|
### Bytes.**getInt8U**
|
|
334
360
|
|
|
335
361
|
<details disabled>
|
|
@@ -356,6 +382,13 @@ Returns:
|
|
|
356
382
|
|----|-----------|
|
|
357
383
|
|`Int32`|A 32-bit integer representing an unsigned 8-bit integer that starts at the given index|
|
|
358
384
|
|
|
385
|
+
Throws:
|
|
386
|
+
|
|
387
|
+
`IndexOutOfBounds`
|
|
388
|
+
|
|
389
|
+
* When `index` is negative
|
|
390
|
+
* When `index + 1` is greater than the bytes size
|
|
391
|
+
|
|
359
392
|
### Bytes.**setInt8**
|
|
360
393
|
|
|
361
394
|
<details disabled>
|
|
@@ -377,6 +410,13 @@ Parameters:
|
|
|
377
410
|
|`value`|`Int32`|The value to set|
|
|
378
411
|
|`bytes`|`Bytes`|The byte sequence to mutate|
|
|
379
412
|
|
|
413
|
+
Throws:
|
|
414
|
+
|
|
415
|
+
`IndexOutOfBounds`
|
|
416
|
+
|
|
417
|
+
* When `index` is negative
|
|
418
|
+
* When `index + 1` is greater than the bytes size
|
|
419
|
+
|
|
380
420
|
### Bytes.**getInt16S**
|
|
381
421
|
|
|
382
422
|
<details disabled>
|
|
@@ -403,6 +443,13 @@ Returns:
|
|
|
403
443
|
|----|-----------|
|
|
404
444
|
|`Int32`|A 32-bit integer representing a signed 16-bit integer that starts at the given index|
|
|
405
445
|
|
|
446
|
+
Throws:
|
|
447
|
+
|
|
448
|
+
`IndexOutOfBounds`
|
|
449
|
+
|
|
450
|
+
* When `index` is negative
|
|
451
|
+
* When `index + 2` is greater than the bytes size
|
|
452
|
+
|
|
406
453
|
### Bytes.**getInt16U**
|
|
407
454
|
|
|
408
455
|
<details disabled>
|
|
@@ -429,6 +476,13 @@ Returns:
|
|
|
429
476
|
|----|-----------|
|
|
430
477
|
|`Int32`|A 32-bit integer representing an unsigned 16-bit integer that starts at the given index|
|
|
431
478
|
|
|
479
|
+
Throws:
|
|
480
|
+
|
|
481
|
+
`IndexOutOfBounds`
|
|
482
|
+
|
|
483
|
+
* When `index` is negative
|
|
484
|
+
* When `index + 2` is greater than the bytes size
|
|
485
|
+
|
|
432
486
|
### Bytes.**setInt16**
|
|
433
487
|
|
|
434
488
|
<details disabled>
|
|
@@ -450,6 +504,13 @@ Parameters:
|
|
|
450
504
|
|`value`|`Int32`|The value to set|
|
|
451
505
|
|`bytes`|`Bytes`|The byte sequence to mutate|
|
|
452
506
|
|
|
507
|
+
Throws:
|
|
508
|
+
|
|
509
|
+
`IndexOutOfBounds`
|
|
510
|
+
|
|
511
|
+
* When `index` is negative
|
|
512
|
+
* When `index + 2` is greater than the bytes size
|
|
513
|
+
|
|
453
514
|
### Bytes.**getInt32**
|
|
454
515
|
|
|
455
516
|
<details disabled>
|
|
@@ -476,6 +537,13 @@ Returns:
|
|
|
476
537
|
|----|-----------|
|
|
477
538
|
|`Int32`|A signed 32-bit integer that starts at the given index|
|
|
478
539
|
|
|
540
|
+
Throws:
|
|
541
|
+
|
|
542
|
+
`IndexOutOfBounds`
|
|
543
|
+
|
|
544
|
+
* When `index` is negative
|
|
545
|
+
* When `index + 4` is greater than the bytes size
|
|
546
|
+
|
|
479
547
|
### Bytes.**setInt32**
|
|
480
548
|
|
|
481
549
|
<details disabled>
|
|
@@ -497,6 +565,13 @@ Parameters:
|
|
|
497
565
|
|`value`|`Int32`|The value to set|
|
|
498
566
|
|`bytes`|`Bytes`|The byte sequence to mutate|
|
|
499
567
|
|
|
568
|
+
Throws:
|
|
569
|
+
|
|
570
|
+
`IndexOutOfBounds`
|
|
571
|
+
|
|
572
|
+
* When `index` is negative
|
|
573
|
+
* When `index + 4` is greater than the bytes size
|
|
574
|
+
|
|
500
575
|
### Bytes.**getFloat32**
|
|
501
576
|
|
|
502
577
|
<details disabled>
|
|
@@ -523,6 +598,13 @@ Returns:
|
|
|
523
598
|
|----|-----------|
|
|
524
599
|
|`Float32`|A 32-bit float that starts at the given index|
|
|
525
600
|
|
|
601
|
+
Throws:
|
|
602
|
+
|
|
603
|
+
`IndexOutOfBounds`
|
|
604
|
+
|
|
605
|
+
* When `index` is negative
|
|
606
|
+
* When `index + 4` is greater than the bytes size
|
|
607
|
+
|
|
526
608
|
### Bytes.**setFloat32**
|
|
527
609
|
|
|
528
610
|
<details disabled>
|
|
@@ -544,6 +626,13 @@ Parameters:
|
|
|
544
626
|
|`value`|`Float32`|The value to set|
|
|
545
627
|
|`bytes`|`Bytes`|The byte sequence to mutate|
|
|
546
628
|
|
|
629
|
+
Throws:
|
|
630
|
+
|
|
631
|
+
`IndexOutOfBounds`
|
|
632
|
+
|
|
633
|
+
* When `index` is negative
|
|
634
|
+
* When `index + 4` is greater than the bytes size
|
|
635
|
+
|
|
547
636
|
### Bytes.**getInt64**
|
|
548
637
|
|
|
549
638
|
<details disabled>
|
|
@@ -570,6 +659,13 @@ Returns:
|
|
|
570
659
|
|----|-----------|
|
|
571
660
|
|`Int64`|A signed 64-bit integer that starts at the given index|
|
|
572
661
|
|
|
662
|
+
Throws:
|
|
663
|
+
|
|
664
|
+
`IndexOutOfBounds`
|
|
665
|
+
|
|
666
|
+
* When `index` is negative
|
|
667
|
+
* When `index + 8` is greater than the bytes size
|
|
668
|
+
|
|
573
669
|
### Bytes.**setInt64**
|
|
574
670
|
|
|
575
671
|
<details disabled>
|
|
@@ -591,6 +687,13 @@ Parameters:
|
|
|
591
687
|
|`value`|`Int64`|The value to set|
|
|
592
688
|
|`bytes`|`Bytes`|The byte sequence to mutate|
|
|
593
689
|
|
|
690
|
+
Throws:
|
|
691
|
+
|
|
692
|
+
`IndexOutOfBounds`
|
|
693
|
+
|
|
694
|
+
* When `index` is negative
|
|
695
|
+
* When `index + 8` is greater than the bytes size
|
|
696
|
+
|
|
594
697
|
### Bytes.**getFloat64**
|
|
595
698
|
|
|
596
699
|
<details disabled>
|
|
@@ -617,6 +720,13 @@ Returns:
|
|
|
617
720
|
|----|-----------|
|
|
618
721
|
|`Float64`|A 64-bit float that starts at the given index|
|
|
619
722
|
|
|
723
|
+
Throws:
|
|
724
|
+
|
|
725
|
+
`IndexOutOfBounds`
|
|
726
|
+
|
|
727
|
+
* When `index` is negative
|
|
728
|
+
* When `index + 8` is greater than the bytes size
|
|
729
|
+
|
|
620
730
|
### Bytes.**setFloat64**
|
|
621
731
|
|
|
622
732
|
<details disabled>
|
|
@@ -638,3 +748,10 @@ Parameters:
|
|
|
638
748
|
|`value`|`Float64`|The value to set|
|
|
639
749
|
|`bytes`|`Bytes`|The byte sequence to mutate|
|
|
640
750
|
|
|
751
|
+
Throws:
|
|
752
|
+
|
|
753
|
+
`IndexOutOfBounds`
|
|
754
|
+
|
|
755
|
+
* When `index` is negative
|
|
756
|
+
* When `index + 8` is greater than the bytes size
|
|
757
|
+
|