@grain/stdlib 0.6.6 → 0.7.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/CHANGELOG.md +67 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/array.gr +55 -7
- package/array.md +606 -560
- package/bigint.md +228 -228
- package/buffer.gr +85 -53
- package/buffer.md +442 -319
- package/bytes.gr +112 -35
- package/bytes.md +299 -219
- package/char.gr +201 -99
- package/char.md +447 -120
- package/exception.gr +11 -11
- package/exception.md +29 -4
- package/float32.gr +327 -3
- package/float32.md +698 -111
- package/float64.gr +320 -3
- package/float64.md +698 -111
- package/fs.gr +1082 -0
- package/fs.md +630 -0
- package/hash.gr +142 -88
- package/hash.md +105 -17
- package/int16.md +178 -178
- package/int32.gr +26 -5
- package/int32.md +266 -231
- package/int64.gr +27 -2
- package/int64.md +266 -231
- package/int8.md +178 -178
- package/json.gr +366 -51
- package/json.md +431 -15
- package/list.gr +328 -31
- package/list.md +759 -336
- package/map.gr +20 -12
- package/map.md +266 -260
- package/marshal.gr +41 -40
- package/marshal.md +14 -14
- package/number.gr +278 -35
- package/number.md +688 -269
- package/option.md +162 -162
- package/package.json +5 -3
- package/path.gr +48 -0
- package/path.md +180 -89
- package/pervasives.gr +2 -2
- package/pervasives.md +275 -275
- package/priorityqueue.gr +7 -7
- package/priorityqueue.md +131 -131
- package/queue.gr +183 -29
- package/queue.md +404 -148
- package/random.md +43 -43
- package/range.gr +4 -4
- package/range.md +42 -42
- package/rational.md +123 -123
- package/regex.gr +52 -51
- package/regex.md +102 -102
- package/result.md +118 -118
- package/runtime/atof/common.md +39 -39
- package/runtime/atof/decimal.gr +6 -6
- package/runtime/atof/decimal.md +14 -14
- package/runtime/atof/lemire.gr +5 -5
- package/runtime/atof/lemire.md +1 -1
- package/runtime/atof/parse.gr +16 -16
- package/runtime/atof/parse.md +2 -2
- package/runtime/atof/slow.md +1 -1
- package/runtime/atof/table.md +2 -2
- package/runtime/atoi/parse.gr +3 -3
- package/runtime/atoi/parse.md +1 -1
- package/runtime/bigint.gr +15 -47
- package/runtime/bigint.md +54 -60
- package/runtime/compare.gr +2 -2
- package/runtime/compare.md +8 -8
- package/runtime/dataStructures.md +211 -211
- package/runtime/debugPrint.gr +4 -1
- package/runtime/debugPrint.md +9 -9
- package/runtime/equal.gr +99 -77
- package/runtime/equal.md +8 -8
- package/runtime/exception.gr +62 -82
- package/runtime/exception.md +62 -11
- package/runtime/gc.gr +39 -45
- package/runtime/gc.md +4 -4
- package/runtime/malloc.gr +7 -7
- package/runtime/malloc.md +13 -13
- package/runtime/math/kernel/cos.gr +70 -0
- package/runtime/math/kernel/cos.md +14 -0
- package/runtime/math/kernel/sin.gr +65 -0
- package/runtime/math/kernel/sin.md +14 -0
- package/runtime/math/kernel/tan.gr +136 -0
- package/runtime/math/kernel/tan.md +14 -0
- package/runtime/math/rempio2.gr +244 -0
- package/runtime/math/rempio2.md +14 -0
- package/runtime/math/trig.gr +130 -0
- package/runtime/math/trig.md +28 -0
- package/runtime/math/umuldi.gr +26 -0
- package/runtime/math/umuldi.md +14 -0
- package/runtime/numberUtils.gr +29 -29
- package/runtime/numberUtils.md +12 -12
- package/runtime/numbers.gr +373 -381
- package/runtime/numbers.md +348 -342
- package/runtime/string.gr +37 -105
- package/runtime/string.md +20 -26
- package/runtime/unsafe/constants.md +24 -24
- package/runtime/unsafe/conv.md +19 -19
- package/runtime/unsafe/memory.gr +24 -20
- package/runtime/unsafe/memory.md +27 -7
- package/runtime/unsafe/offsets.gr +36 -0
- package/runtime/unsafe/offsets.md +88 -0
- package/runtime/unsafe/panic.gr +28 -0
- package/runtime/unsafe/panic.md +14 -0
- package/runtime/unsafe/tags.md +32 -32
- package/runtime/unsafe/wasmf32.md +28 -28
- package/runtime/unsafe/wasmf64.md +28 -28
- package/runtime/unsafe/wasmi32.md +47 -47
- package/runtime/unsafe/wasmi64.md +50 -50
- package/runtime/utf8.gr +189 -0
- package/runtime/utf8.md +117 -0
- package/runtime/wasi.gr +4 -2
- package/runtime/wasi.md +147 -147
- package/set.gr +18 -11
- package/set.md +253 -247
- package/stack.gr +171 -2
- package/stack.md +371 -89
- package/string.gr +352 -557
- package/string.md +298 -255
- package/uint16.md +170 -170
- package/uint32.gr +25 -4
- package/uint32.md +249 -214
- package/uint64.gr +25 -5
- package/uint64.md +249 -214
- package/uint8.md +170 -170
- package/uri.gr +57 -53
- package/uri.md +88 -89
- package/wasi/file.gr +67 -59
- package/wasi/file.md +308 -308
- package/wasi/process.md +26 -26
- package/wasi/random.md +12 -12
- package/wasi/time.md +16 -16
- package/runtime/utils/printing.gr +0 -60
- package/runtime/utils/printing.md +0 -26
package/bytes.md
CHANGED
|
@@ -33,22 +33,22 @@ No other changes yet.
|
|
|
33
33
|
</details>
|
|
34
34
|
|
|
35
35
|
```grain
|
|
36
|
-
make
|
|
36
|
+
make: (size: Number) => Bytes
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
Creates a new byte sequence of the input size.
|
|
40
40
|
|
|
41
41
|
Parameters:
|
|
42
42
|
|
|
43
|
-
|param|type|description|
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
| param | type | description |
|
|
44
|
+
| ------ | -------- | ---------------------------- |
|
|
45
|
+
| `size` | `Number` | The number of bytes to store |
|
|
46
46
|
|
|
47
47
|
Returns:
|
|
48
48
|
|
|
49
|
-
|type|description|
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
| type | description |
|
|
50
|
+
| ------- | --------------------- |
|
|
51
|
+
| `Bytes` | The new byte sequence |
|
|
52
52
|
|
|
53
53
|
Examples:
|
|
54
54
|
|
|
@@ -68,7 +68,7 @@ No other changes yet.
|
|
|
68
68
|
</details>
|
|
69
69
|
|
|
70
70
|
```grain
|
|
71
|
-
empty
|
|
71
|
+
empty: Bytes
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
An empty byte sequence.
|
|
@@ -87,22 +87,22 @@ No other changes yet.
|
|
|
87
87
|
</details>
|
|
88
88
|
|
|
89
89
|
```grain
|
|
90
|
-
fromString
|
|
90
|
+
fromString: (string: String) => Bytes
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
Creates a new byte sequence from the input string.
|
|
94
94
|
|
|
95
95
|
Parameters:
|
|
96
96
|
|
|
97
|
-
|param|type|description|
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
| param | type | description |
|
|
98
|
+
| -------- | -------- | --------------------------------------- |
|
|
99
|
+
| `string` | `String` | The string to copy into a byte sequence |
|
|
100
100
|
|
|
101
101
|
Returns:
|
|
102
102
|
|
|
103
|
-
|type|description|
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
| type | description |
|
|
104
|
+
| ------- | --------------------- |
|
|
105
|
+
| `Bytes` | The new byte sequence |
|
|
106
106
|
|
|
107
107
|
Examples:
|
|
108
108
|
|
|
@@ -118,22 +118,22 @@ No other changes yet.
|
|
|
118
118
|
</details>
|
|
119
119
|
|
|
120
120
|
```grain
|
|
121
|
-
toString
|
|
121
|
+
toString: (bytes: Bytes) => String
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
Creates a new string from the input bytes.
|
|
125
125
|
|
|
126
126
|
Parameters:
|
|
127
127
|
|
|
128
|
-
|param|type|description|
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
| param | type | description |
|
|
129
|
+
| ------- | ------- | ------------------------ |
|
|
130
|
+
| `bytes` | `Bytes` | The source byte sequence |
|
|
131
131
|
|
|
132
132
|
Returns:
|
|
133
133
|
|
|
134
|
-
|type|description|
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
| type | description |
|
|
135
|
+
| -------- | -------------------------------------- |
|
|
136
|
+
| `String` | The string representation of the bytes |
|
|
137
137
|
|
|
138
138
|
Examples:
|
|
139
139
|
|
|
@@ -153,22 +153,22 @@ No other changes yet.
|
|
|
153
153
|
</details>
|
|
154
154
|
|
|
155
155
|
```grain
|
|
156
|
-
length
|
|
156
|
+
length: (bytes: Bytes) => Number
|
|
157
157
|
```
|
|
158
158
|
|
|
159
159
|
Returns the length of a byte sequence.
|
|
160
160
|
|
|
161
161
|
Parameters:
|
|
162
162
|
|
|
163
|
-
|param|type|description|
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
| param | type | description |
|
|
164
|
+
| ------- | ------- | ---------------------------- |
|
|
165
|
+
| `bytes` | `Bytes` | The byte sequence to inspect |
|
|
166
166
|
|
|
167
167
|
Returns:
|
|
168
168
|
|
|
169
|
-
|type|description|
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
| type | description |
|
|
170
|
+
| -------- | ------------------- |
|
|
171
|
+
| `Number` | The number of bytes |
|
|
172
172
|
|
|
173
173
|
Examples:
|
|
174
174
|
|
|
@@ -188,22 +188,22 @@ No other changes yet.
|
|
|
188
188
|
</details>
|
|
189
189
|
|
|
190
190
|
```grain
|
|
191
|
-
copy
|
|
191
|
+
copy: (bytes: Bytes) => Bytes
|
|
192
192
|
```
|
|
193
193
|
|
|
194
194
|
Creates a new byte sequence that contains the same bytes as the input byte sequence.
|
|
195
195
|
|
|
196
196
|
Parameters:
|
|
197
197
|
|
|
198
|
-
|param|type|description|
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
| param | type | description |
|
|
199
|
+
| ------- | ------- | ------------------------- |
|
|
200
|
+
| `bytes` | `Bytes` | The byte sequence to copy |
|
|
201
201
|
|
|
202
202
|
Returns:
|
|
203
203
|
|
|
204
|
-
|type|description|
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
| type | description |
|
|
205
|
+
| ------- | --------------------- |
|
|
206
|
+
| `Bytes` | The new byte sequence |
|
|
207
207
|
|
|
208
208
|
Examples:
|
|
209
209
|
|
|
@@ -219,24 +219,24 @@ No other changes yet.
|
|
|
219
219
|
</details>
|
|
220
220
|
|
|
221
221
|
```grain
|
|
222
|
-
slice
|
|
222
|
+
slice: (start: Number, length: Number, bytes: Bytes) => Bytes
|
|
223
223
|
```
|
|
224
224
|
|
|
225
225
|
Returns a copy of a subset of the input byte sequence.
|
|
226
226
|
|
|
227
227
|
Parameters:
|
|
228
228
|
|
|
229
|
-
|param|type|description|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
| param | type | description |
|
|
230
|
+
| -------- | -------- | ------------------------------------------------------- |
|
|
231
|
+
| `start` | `Number` | The start index |
|
|
232
|
+
| `length` | `Number` | The number of bytes to include after the starting index |
|
|
233
|
+
| `bytes` | `Bytes` | The byte sequence to copy from |
|
|
234
234
|
|
|
235
235
|
Returns:
|
|
236
236
|
|
|
237
|
-
|type|description|
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
| type | description |
|
|
238
|
+
| ------- | ---------------------------------------- |
|
|
239
|
+
| `Bytes` | A byte sequence with of the copied bytes |
|
|
240
240
|
|
|
241
241
|
Throws:
|
|
242
242
|
|
|
@@ -260,7 +260,7 @@ No other changes yet.
|
|
|
260
260
|
</details>
|
|
261
261
|
|
|
262
262
|
```grain
|
|
263
|
-
resize
|
|
263
|
+
resize: (left: Number, right: Number, bytes: Bytes) => Bytes
|
|
264
264
|
```
|
|
265
265
|
|
|
266
266
|
Returns a copy of a byte sequence with bytes added or removed from the beginning and/or end.
|
|
@@ -269,17 +269,17 @@ A positive number represents bytes to add, while a negative number represents by
|
|
|
269
269
|
|
|
270
270
|
Parameters:
|
|
271
271
|
|
|
272
|
-
|param|type|description|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
272
|
+
| param | type | description |
|
|
273
|
+
| ------- | -------- | -------------------------------------------- |
|
|
274
|
+
| `left` | `Number` | The number of uninitialized bytes to prepend |
|
|
275
|
+
| `right` | `Number` | The number of uninitialized bytes to append |
|
|
276
|
+
| `bytes` | `Bytes` | The byte sequence get a subset of bytes from |
|
|
277
277
|
|
|
278
278
|
Returns:
|
|
279
279
|
|
|
280
|
-
|type|description|
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
| type | description |
|
|
281
|
+
| ------- | ----------------------- |
|
|
282
|
+
| `Bytes` | A resized byte sequence |
|
|
283
283
|
|
|
284
284
|
Throws:
|
|
285
285
|
|
|
@@ -301,7 +301,7 @@ No other changes yet.
|
|
|
301
301
|
</details>
|
|
302
302
|
|
|
303
303
|
```grain
|
|
304
|
-
move
|
|
304
|
+
move:
|
|
305
305
|
(srcIndex: Number, dstIndex: Number, length: Number, src: Bytes, dst: Bytes) =>
|
|
306
306
|
Void
|
|
307
307
|
```
|
|
@@ -311,13 +311,13 @@ in a destination byte sequence.
|
|
|
311
311
|
|
|
312
312
|
Parameters:
|
|
313
313
|
|
|
314
|
-
|param|type|description|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
314
|
+
| param | type | description |
|
|
315
|
+
| ---------- | -------- | --------------------------------------------------------- |
|
|
316
|
+
| `srcIndex` | `Number` | The starting index to copy bytes from |
|
|
317
|
+
| `dstIndex` | `Number` | The starting index to copy bytes into |
|
|
318
|
+
| `length` | `Number` | The amount of bytes to copy from the source byte sequence |
|
|
319
|
+
| `src` | `Bytes` | The source byte sequence |
|
|
320
|
+
| `dst` | `Bytes` | The destination byte sequence |
|
|
321
321
|
|
|
322
322
|
Throws:
|
|
323
323
|
|
|
@@ -342,23 +342,23 @@ No other changes yet.
|
|
|
342
342
|
</details>
|
|
343
343
|
|
|
344
344
|
```grain
|
|
345
|
-
concat
|
|
345
|
+
concat: (bytes1: Bytes, bytes2: Bytes) => Bytes
|
|
346
346
|
```
|
|
347
347
|
|
|
348
348
|
Creates a new byte sequence that contains the bytes of both byte sequences.
|
|
349
349
|
|
|
350
350
|
Parameters:
|
|
351
351
|
|
|
352
|
-
|param|type|description|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
352
|
+
| param | type | description |
|
|
353
|
+
| -------- | ------- | --------------------------- |
|
|
354
|
+
| `bytes1` | `Bytes` | The beginning byte sequence |
|
|
355
|
+
| `bytes2` | `Bytes` | The ending byte sequence |
|
|
356
356
|
|
|
357
357
|
Returns:
|
|
358
358
|
|
|
359
|
-
|type|description|
|
|
360
|
-
|
|
361
|
-
|
|
359
|
+
| type | description |
|
|
360
|
+
| ------- | --------------------- |
|
|
361
|
+
| `Bytes` | The new byte sequence |
|
|
362
362
|
|
|
363
363
|
Examples:
|
|
364
364
|
|
|
@@ -383,17 +383,17 @@ assert Bytes.toString(Bytes.concat(helloBytes, worldBytes)) == "Hello World"
|
|
|
383
383
|
</details>
|
|
384
384
|
|
|
385
385
|
```grain
|
|
386
|
-
fill
|
|
386
|
+
fill: (value: Uint8, bytes: Bytes) => Void
|
|
387
387
|
```
|
|
388
388
|
|
|
389
389
|
Replaces all bytes in a byte sequnce with the new value provided.
|
|
390
390
|
|
|
391
391
|
Parameters:
|
|
392
392
|
|
|
393
|
-
|param|type|description|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
393
|
+
| param | type | description |
|
|
394
|
+
| ------- | ------- | ----------------------------- |
|
|
395
|
+
| `value` | `Uint8` | The value replacing each byte |
|
|
396
|
+
| `bytes` | `Bytes` | The byte sequence to update |
|
|
397
397
|
|
|
398
398
|
Examples:
|
|
399
399
|
|
|
@@ -411,16 +411,16 @@ No other changes yet.
|
|
|
411
411
|
</details>
|
|
412
412
|
|
|
413
413
|
```grain
|
|
414
|
-
clear
|
|
414
|
+
clear: (bytes: Bytes) => Void
|
|
415
415
|
```
|
|
416
416
|
|
|
417
417
|
Replaces all bytes in a byte sequence with zeroes.
|
|
418
418
|
|
|
419
419
|
Parameters:
|
|
420
420
|
|
|
421
|
-
|param|type|description|
|
|
422
|
-
|
|
423
|
-
|
|
421
|
+
| param | type | description |
|
|
422
|
+
| ------- | ------- | -------------------------- |
|
|
423
|
+
| `bytes` | `Bytes` | The byte sequence to clear |
|
|
424
424
|
|
|
425
425
|
Examples:
|
|
426
426
|
|
|
@@ -431,6 +431,86 @@ Bytes.clear(bytes)
|
|
|
431
431
|
assert bytes == b"\x00\x00\x00\x00\x00"
|
|
432
432
|
```
|
|
433
433
|
|
|
434
|
+
### Bytes.**getChar**
|
|
435
|
+
|
|
436
|
+
<details disabled>
|
|
437
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
438
|
+
No other changes yet.
|
|
439
|
+
</details>
|
|
440
|
+
|
|
441
|
+
```grain
|
|
442
|
+
getChar: (index: Number, bytes: Bytes) => Char
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
Gets the UTF-8 encoded character at the given byte index.
|
|
446
|
+
|
|
447
|
+
Parameters:
|
|
448
|
+
|
|
449
|
+
| param | type | description |
|
|
450
|
+
| ------- | -------- | --------------------------- |
|
|
451
|
+
| `index` | `Number` | The byte index to access |
|
|
452
|
+
| `bytes` | `Bytes` | The byte sequence to access |
|
|
453
|
+
|
|
454
|
+
Returns:
|
|
455
|
+
|
|
456
|
+
| type | description |
|
|
457
|
+
| ------ | -------------------------------------------- |
|
|
458
|
+
| `Char` | The character that starts at the given index |
|
|
459
|
+
|
|
460
|
+
Throws:
|
|
461
|
+
|
|
462
|
+
`IndexOutOfBounds`
|
|
463
|
+
|
|
464
|
+
* When `index` is negative
|
|
465
|
+
* When `index + 1` is greater than the bytes size
|
|
466
|
+
|
|
467
|
+
`MalformedUnicode`
|
|
468
|
+
|
|
469
|
+
* When the requested character is not a valid UTF-8 sequence
|
|
470
|
+
|
|
471
|
+
Examples:
|
|
472
|
+
|
|
473
|
+
```grain
|
|
474
|
+
let bytes = Bytes.fromString("Hello")
|
|
475
|
+
assert Bytes.getChar(0, bytes) == 'H'
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### Bytes.**setChar**
|
|
479
|
+
|
|
480
|
+
<details disabled>
|
|
481
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
482
|
+
No other changes yet.
|
|
483
|
+
</details>
|
|
484
|
+
|
|
485
|
+
```grain
|
|
486
|
+
setChar: (index: Number, value: Char, bytes: Bytes) => Void
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
UTF-8 encodes a character starting at the given byte index.
|
|
490
|
+
|
|
491
|
+
Parameters:
|
|
492
|
+
|
|
493
|
+
| param | type | description |
|
|
494
|
+
| ------- | -------- | --------------------------- |
|
|
495
|
+
| `index` | `Number` | The byte index to update |
|
|
496
|
+
| `value` | `Char` | The value to set |
|
|
497
|
+
| `bytes` | `Bytes` | The byte sequence to mutate |
|
|
498
|
+
|
|
499
|
+
Throws:
|
|
500
|
+
|
|
501
|
+
`IndexOutOfBounds`
|
|
502
|
+
|
|
503
|
+
* When `index` is negative
|
|
504
|
+
* When `index + charSize` is greater than the bytes size, `charSize` is the number of bytes in the character ranging from 1 to 4
|
|
505
|
+
|
|
506
|
+
Examples:
|
|
507
|
+
|
|
508
|
+
```grain
|
|
509
|
+
let bytes = Bytes.make(1)
|
|
510
|
+
Bytes.setChar(0, 'a', bytes)
|
|
511
|
+
assert Bytes.getChar(0, bytes) == 'a'
|
|
512
|
+
```
|
|
513
|
+
|
|
434
514
|
### Bytes.**getInt8**
|
|
435
515
|
|
|
436
516
|
<details>
|
|
@@ -446,23 +526,23 @@ assert bytes == b"\x00\x00\x00\x00\x00"
|
|
|
446
526
|
</details>
|
|
447
527
|
|
|
448
528
|
```grain
|
|
449
|
-
getInt8
|
|
529
|
+
getInt8: (index: Number, bytes: Bytes) => Int8
|
|
450
530
|
```
|
|
451
531
|
|
|
452
532
|
Gets a signed 8-bit integer starting at the given byte index.
|
|
453
533
|
|
|
454
534
|
Parameters:
|
|
455
535
|
|
|
456
|
-
|param|type|description|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
536
|
+
| param | type | description |
|
|
537
|
+
| ------- | -------- | --------------------------- |
|
|
538
|
+
| `index` | `Number` | The byte index to access |
|
|
539
|
+
| `bytes` | `Bytes` | The byte sequence to access |
|
|
460
540
|
|
|
461
541
|
Returns:
|
|
462
542
|
|
|
463
|
-
|type|description|
|
|
464
|
-
|
|
465
|
-
|
|
543
|
+
| type | description |
|
|
544
|
+
| ------ | ----------------------------------------------------- |
|
|
545
|
+
| `Int8` | A signed 8-bit integer that starts at the given index |
|
|
466
546
|
|
|
467
547
|
Throws:
|
|
468
548
|
|
|
@@ -494,18 +574,18 @@ assert Bytes.getInt8(0, bytes) == 1s
|
|
|
494
574
|
</details>
|
|
495
575
|
|
|
496
576
|
```grain
|
|
497
|
-
setInt8
|
|
577
|
+
setInt8: (index: Number, value: Int8, bytes: Bytes) => Void
|
|
498
578
|
```
|
|
499
579
|
|
|
500
580
|
Sets a signed 8-bit integer starting at the given byte index.
|
|
501
581
|
|
|
502
582
|
Parameters:
|
|
503
583
|
|
|
504
|
-
|param|type|description|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
584
|
+
| param | type | description |
|
|
585
|
+
| ------- | -------- | --------------------------- |
|
|
586
|
+
| `index` | `Number` | The byte index to update |
|
|
587
|
+
| `value` | `Int8` | The value to set |
|
|
588
|
+
| `bytes` | `Bytes` | The byte sequence to mutate |
|
|
509
589
|
|
|
510
590
|
Throws:
|
|
511
591
|
|
|
@@ -537,23 +617,23 @@ assert Bytes.getInt8(0, bytes) == 2s
|
|
|
537
617
|
</details>
|
|
538
618
|
|
|
539
619
|
```grain
|
|
540
|
-
getUint8
|
|
620
|
+
getUint8: (index: Number, bytes: Bytes) => Uint8
|
|
541
621
|
```
|
|
542
622
|
|
|
543
623
|
Gets an unsigned 8-bit integer starting at the given byte index.
|
|
544
624
|
|
|
545
625
|
Parameters:
|
|
546
626
|
|
|
547
|
-
|param|type|description|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
627
|
+
| param | type | description |
|
|
628
|
+
| ------- | -------- | --------------------------- |
|
|
629
|
+
| `index` | `Number` | The byte index to access |
|
|
630
|
+
| `bytes` | `Bytes` | The byte sequence to access |
|
|
551
631
|
|
|
552
632
|
Returns:
|
|
553
633
|
|
|
554
|
-
|type|description|
|
|
555
|
-
|
|
556
|
-
|
|
634
|
+
| type | description |
|
|
635
|
+
| ------- | -------------------------------------------------------- |
|
|
636
|
+
| `Uint8` | An unsigned 8-bit integer that starts at the given index |
|
|
557
637
|
|
|
558
638
|
Throws:
|
|
559
639
|
|
|
@@ -578,18 +658,18 @@ No other changes yet.
|
|
|
578
658
|
</details>
|
|
579
659
|
|
|
580
660
|
```grain
|
|
581
|
-
setUint8
|
|
661
|
+
setUint8: (index: Number, value: Uint8, bytes: Bytes) => Void
|
|
582
662
|
```
|
|
583
663
|
|
|
584
664
|
Sets an unsigned 8-bit integer starting at the given byte index.
|
|
585
665
|
|
|
586
666
|
Parameters:
|
|
587
667
|
|
|
588
|
-
|param|type|description|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
668
|
+
| param | type | description |
|
|
669
|
+
| ------- | -------- | --------------------------- |
|
|
670
|
+
| `index` | `Number` | The byte index to update |
|
|
671
|
+
| `value` | `Uint8` | The value to set |
|
|
672
|
+
| `bytes` | `Bytes` | The byte sequence to mutate |
|
|
593
673
|
|
|
594
674
|
Throws:
|
|
595
675
|
|
|
@@ -621,23 +701,23 @@ assert Bytes.getUint8(1, bytes) == 2us
|
|
|
621
701
|
</details>
|
|
622
702
|
|
|
623
703
|
```grain
|
|
624
|
-
getInt16
|
|
704
|
+
getInt16: (index: Number, bytes: Bytes) => Int16
|
|
625
705
|
```
|
|
626
706
|
|
|
627
707
|
Gets a signed 16-bit integer starting at the given byte index.
|
|
628
708
|
|
|
629
709
|
Parameters:
|
|
630
710
|
|
|
631
|
-
|param|type|description|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
711
|
+
| param | type | description |
|
|
712
|
+
| ------- | -------- | --------------------------- |
|
|
713
|
+
| `index` | `Number` | The byte index to access |
|
|
714
|
+
| `bytes` | `Bytes` | The byte sequence to access |
|
|
635
715
|
|
|
636
716
|
Returns:
|
|
637
717
|
|
|
638
|
-
|type|description|
|
|
639
|
-
|
|
640
|
-
|
|
718
|
+
| type | description |
|
|
719
|
+
| ------- | ------------------------------------------------------ |
|
|
720
|
+
| `Int16` | A signed 16-bit integer that starts at the given index |
|
|
641
721
|
|
|
642
722
|
Throws:
|
|
643
723
|
|
|
@@ -669,18 +749,18 @@ assert Bytes.getInt16(0, bytes) == -2S
|
|
|
669
749
|
</details>
|
|
670
750
|
|
|
671
751
|
```grain
|
|
672
|
-
setInt16
|
|
752
|
+
setInt16: (index: Number, value: Int16, bytes: Bytes) => Void
|
|
673
753
|
```
|
|
674
754
|
|
|
675
755
|
Sets a signed 16-bit integer starting at the given byte index.
|
|
676
756
|
|
|
677
757
|
Parameters:
|
|
678
758
|
|
|
679
|
-
|param|type|description|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
759
|
+
| param | type | description |
|
|
760
|
+
| ------- | -------- | --------------------------- |
|
|
761
|
+
| `index` | `Number` | The byte index to update |
|
|
762
|
+
| `value` | `Int16` | The value to set |
|
|
763
|
+
| `bytes` | `Bytes` | The byte sequence to mutate |
|
|
684
764
|
|
|
685
765
|
Throws:
|
|
686
766
|
|
|
@@ -712,23 +792,23 @@ assert Bytes.getInt16(0, bytes) == -1S
|
|
|
712
792
|
</details>
|
|
713
793
|
|
|
714
794
|
```grain
|
|
715
|
-
getUint16
|
|
795
|
+
getUint16: (index: Number, bytes: Bytes) => Uint16
|
|
716
796
|
```
|
|
717
797
|
|
|
718
798
|
Gets an unsigned 16-bit integer starting at the given byte index.
|
|
719
799
|
|
|
720
800
|
Parameters:
|
|
721
801
|
|
|
722
|
-
|param|type|description|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
802
|
+
| param | type | description |
|
|
803
|
+
| ------- | -------- | --------------------------- |
|
|
804
|
+
| `index` | `Number` | The byte index to access |
|
|
805
|
+
| `bytes` | `Bytes` | The byte sequence to access |
|
|
726
806
|
|
|
727
807
|
Returns:
|
|
728
808
|
|
|
729
|
-
|type|description|
|
|
730
|
-
|
|
731
|
-
|
|
809
|
+
| type | description |
|
|
810
|
+
| -------- | --------------------------------------------------------- |
|
|
811
|
+
| `Uint16` | An unsigned 16-bit integer that starts at the given index |
|
|
732
812
|
|
|
733
813
|
Throws:
|
|
734
814
|
|
|
@@ -753,18 +833,18 @@ No other changes yet.
|
|
|
753
833
|
</details>
|
|
754
834
|
|
|
755
835
|
```grain
|
|
756
|
-
setUint16
|
|
836
|
+
setUint16: (index: Number, value: Uint16, bytes: Bytes) => Void
|
|
757
837
|
```
|
|
758
838
|
|
|
759
839
|
Sets an unsigned 16-bit integer starting at the given byte index.
|
|
760
840
|
|
|
761
841
|
Parameters:
|
|
762
842
|
|
|
763
|
-
|param|type|description|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
843
|
+
| param | type | description |
|
|
844
|
+
| ------- | -------- | --------------------------- |
|
|
845
|
+
| `index` | `Number` | The byte index to update |
|
|
846
|
+
| `value` | `Uint16` | The value to set |
|
|
847
|
+
| `bytes` | `Bytes` | The byte sequence to mutate |
|
|
768
848
|
|
|
769
849
|
Throws:
|
|
770
850
|
|
|
@@ -789,23 +869,23 @@ No other changes yet.
|
|
|
789
869
|
</details>
|
|
790
870
|
|
|
791
871
|
```grain
|
|
792
|
-
getInt32
|
|
872
|
+
getInt32: (index: Number, bytes: Bytes) => Int32
|
|
793
873
|
```
|
|
794
874
|
|
|
795
875
|
Gets a signed 32-bit integer starting at the given byte index.
|
|
796
876
|
|
|
797
877
|
Parameters:
|
|
798
878
|
|
|
799
|
-
|param|type|description|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
879
|
+
| param | type | description |
|
|
880
|
+
| ------- | -------- | --------------------------- |
|
|
881
|
+
| `index` | `Number` | The byte index to access |
|
|
882
|
+
| `bytes` | `Bytes` | The byte sequence to access |
|
|
803
883
|
|
|
804
884
|
Returns:
|
|
805
885
|
|
|
806
|
-
|type|description|
|
|
807
|
-
|
|
808
|
-
|
|
886
|
+
| type | description |
|
|
887
|
+
| ------- | ------------------------------------------------------ |
|
|
888
|
+
| `Int32` | A signed 32-bit integer that starts at the given index |
|
|
809
889
|
|
|
810
890
|
Throws:
|
|
811
891
|
|
|
@@ -830,18 +910,18 @@ No other changes yet.
|
|
|
830
910
|
</details>
|
|
831
911
|
|
|
832
912
|
```grain
|
|
833
|
-
setInt32
|
|
913
|
+
setInt32: (index: Number, value: Int32, bytes: Bytes) => Void
|
|
834
914
|
```
|
|
835
915
|
|
|
836
916
|
Sets a signed 32-bit integer starting at the given byte index.
|
|
837
917
|
|
|
838
918
|
Parameters:
|
|
839
919
|
|
|
840
|
-
|param|type|description|
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
920
|
+
| param | type | description |
|
|
921
|
+
| ------- | -------- | --------------------------- |
|
|
922
|
+
| `index` | `Number` | The byte index to update |
|
|
923
|
+
| `value` | `Int32` | The value to set |
|
|
924
|
+
| `bytes` | `Bytes` | The byte sequence to mutate |
|
|
845
925
|
|
|
846
926
|
Throws:
|
|
847
927
|
|
|
@@ -866,23 +946,23 @@ No other changes yet.
|
|
|
866
946
|
</details>
|
|
867
947
|
|
|
868
948
|
```grain
|
|
869
|
-
getUint32
|
|
949
|
+
getUint32: (index: Number, bytes: Bytes) => Uint32
|
|
870
950
|
```
|
|
871
951
|
|
|
872
952
|
Gets an unsigned 32-bit integer starting at the given byte index.
|
|
873
953
|
|
|
874
954
|
Parameters:
|
|
875
955
|
|
|
876
|
-
|param|type|description|
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
956
|
+
| param | type | description |
|
|
957
|
+
| ------- | -------- | --------------------------- |
|
|
958
|
+
| `index` | `Number` | The byte index to access |
|
|
959
|
+
| `bytes` | `Bytes` | The byte sequence to access |
|
|
880
960
|
|
|
881
961
|
Returns:
|
|
882
962
|
|
|
883
|
-
|type|description|
|
|
884
|
-
|
|
885
|
-
|
|
963
|
+
| type | description |
|
|
964
|
+
| -------- | --------------------------------------------------------- |
|
|
965
|
+
| `Uint32` | An unsigned 32-bit integer that starts at the given index |
|
|
886
966
|
|
|
887
967
|
Throws:
|
|
888
968
|
|
|
@@ -907,18 +987,18 @@ No other changes yet.
|
|
|
907
987
|
</details>
|
|
908
988
|
|
|
909
989
|
```grain
|
|
910
|
-
setUint32
|
|
990
|
+
setUint32: (index: Number, value: Uint32, bytes: Bytes) => Void
|
|
911
991
|
```
|
|
912
992
|
|
|
913
993
|
Sets an unsigned 32-bit integer starting at the given byte index.
|
|
914
994
|
|
|
915
995
|
Parameters:
|
|
916
996
|
|
|
917
|
-
|param|type|description|
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
997
|
+
| param | type | description |
|
|
998
|
+
| ------- | -------- | --------------------------- |
|
|
999
|
+
| `index` | `Number` | The byte index to update |
|
|
1000
|
+
| `value` | `Uint32` | The value to set |
|
|
1001
|
+
| `bytes` | `Bytes` | The byte sequence to mutate |
|
|
922
1002
|
|
|
923
1003
|
Throws:
|
|
924
1004
|
|
|
@@ -943,23 +1023,23 @@ No other changes yet.
|
|
|
943
1023
|
</details>
|
|
944
1024
|
|
|
945
1025
|
```grain
|
|
946
|
-
getFloat32
|
|
1026
|
+
getFloat32: (index: Number, bytes: Bytes) => Float32
|
|
947
1027
|
```
|
|
948
1028
|
|
|
949
1029
|
Gets a 32-bit float starting at the given byte index.
|
|
950
1030
|
|
|
951
1031
|
Parameters:
|
|
952
1032
|
|
|
953
|
-
|param|type|description|
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
1033
|
+
| param | type | description |
|
|
1034
|
+
| ------- | -------- | --------------------------- |
|
|
1035
|
+
| `index` | `Number` | The byte index to access |
|
|
1036
|
+
| `bytes` | `Bytes` | The byte sequence to access |
|
|
957
1037
|
|
|
958
1038
|
Returns:
|
|
959
1039
|
|
|
960
|
-
|type|description|
|
|
961
|
-
|
|
962
|
-
|
|
1040
|
+
| type | description |
|
|
1041
|
+
| --------- | --------------------------------------------- |
|
|
1042
|
+
| `Float32` | A 32-bit float that starts at the given index |
|
|
963
1043
|
|
|
964
1044
|
Throws:
|
|
965
1045
|
|
|
@@ -984,18 +1064,18 @@ No other changes yet.
|
|
|
984
1064
|
</details>
|
|
985
1065
|
|
|
986
1066
|
```grain
|
|
987
|
-
setFloat32
|
|
1067
|
+
setFloat32: (index: Number, value: Float32, bytes: Bytes) => Void
|
|
988
1068
|
```
|
|
989
1069
|
|
|
990
1070
|
Sets a 32-bit float starting at the given byte index.
|
|
991
1071
|
|
|
992
1072
|
Parameters:
|
|
993
1073
|
|
|
994
|
-
|param|type|description|
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1074
|
+
| param | type | description |
|
|
1075
|
+
| ------- | --------- | --------------------------- |
|
|
1076
|
+
| `index` | `Number` | The byte index to update |
|
|
1077
|
+
| `value` | `Float32` | The value to set |
|
|
1078
|
+
| `bytes` | `Bytes` | The byte sequence to mutate |
|
|
999
1079
|
|
|
1000
1080
|
Throws:
|
|
1001
1081
|
|
|
@@ -1020,23 +1100,23 @@ No other changes yet.
|
|
|
1020
1100
|
</details>
|
|
1021
1101
|
|
|
1022
1102
|
```grain
|
|
1023
|
-
getInt64
|
|
1103
|
+
getInt64: (index: Number, bytes: Bytes) => Int64
|
|
1024
1104
|
```
|
|
1025
1105
|
|
|
1026
1106
|
Gets a signed 64-bit integer starting at the given byte index.
|
|
1027
1107
|
|
|
1028
1108
|
Parameters:
|
|
1029
1109
|
|
|
1030
|
-
|param|type|description|
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1110
|
+
| param | type | description |
|
|
1111
|
+
| ------- | -------- | --------------------------- |
|
|
1112
|
+
| `index` | `Number` | The byte index to access |
|
|
1113
|
+
| `bytes` | `Bytes` | The byte sequence to access |
|
|
1034
1114
|
|
|
1035
1115
|
Returns:
|
|
1036
1116
|
|
|
1037
|
-
|type|description|
|
|
1038
|
-
|
|
1039
|
-
|
|
1117
|
+
| type | description |
|
|
1118
|
+
| ------- | ------------------------------------------------------ |
|
|
1119
|
+
| `Int64` | A signed 64-bit integer that starts at the given index |
|
|
1040
1120
|
|
|
1041
1121
|
Throws:
|
|
1042
1122
|
|
|
@@ -1061,18 +1141,18 @@ No other changes yet.
|
|
|
1061
1141
|
</details>
|
|
1062
1142
|
|
|
1063
1143
|
```grain
|
|
1064
|
-
setInt64
|
|
1144
|
+
setInt64: (index: Number, value: Int64, bytes: Bytes) => Void
|
|
1065
1145
|
```
|
|
1066
1146
|
|
|
1067
1147
|
Sets a signed 64-bit integer starting at the given byte index.
|
|
1068
1148
|
|
|
1069
1149
|
Parameters:
|
|
1070
1150
|
|
|
1071
|
-
|param|type|description|
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1151
|
+
| param | type | description |
|
|
1152
|
+
| ------- | -------- | --------------------------- |
|
|
1153
|
+
| `index` | `Number` | The byte index to update |
|
|
1154
|
+
| `value` | `Int64` | The value to set |
|
|
1155
|
+
| `bytes` | `Bytes` | The byte sequence to mutate |
|
|
1076
1156
|
|
|
1077
1157
|
Throws:
|
|
1078
1158
|
|
|
@@ -1097,23 +1177,23 @@ No other changes yet.
|
|
|
1097
1177
|
</details>
|
|
1098
1178
|
|
|
1099
1179
|
```grain
|
|
1100
|
-
getUint64
|
|
1180
|
+
getUint64: (index: Number, bytes: Bytes) => Uint64
|
|
1101
1181
|
```
|
|
1102
1182
|
|
|
1103
1183
|
Gets an unsigned 64-bit integer starting at the given byte index.
|
|
1104
1184
|
|
|
1105
1185
|
Parameters:
|
|
1106
1186
|
|
|
1107
|
-
|param|type|description|
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1187
|
+
| param | type | description |
|
|
1188
|
+
| ------- | -------- | --------------------------- |
|
|
1189
|
+
| `index` | `Number` | The byte index to access |
|
|
1190
|
+
| `bytes` | `Bytes` | The byte sequence to access |
|
|
1111
1191
|
|
|
1112
1192
|
Returns:
|
|
1113
1193
|
|
|
1114
|
-
|type|description|
|
|
1115
|
-
|
|
1116
|
-
|
|
1194
|
+
| type | description |
|
|
1195
|
+
| -------- | --------------------------------------------------------- |
|
|
1196
|
+
| `Uint64` | An unsigned 64-bit integer that starts at the given index |
|
|
1117
1197
|
|
|
1118
1198
|
Throws:
|
|
1119
1199
|
|
|
@@ -1138,18 +1218,18 @@ No other changes yet.
|
|
|
1138
1218
|
</details>
|
|
1139
1219
|
|
|
1140
1220
|
```grain
|
|
1141
|
-
setUint64
|
|
1221
|
+
setUint64: (index: Number, value: Uint64, bytes: Bytes) => Void
|
|
1142
1222
|
```
|
|
1143
1223
|
|
|
1144
1224
|
Sets an unsigned 64-bit integer starting at the given byte index.
|
|
1145
1225
|
|
|
1146
1226
|
Parameters:
|
|
1147
1227
|
|
|
1148
|
-
|param|type|description|
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1228
|
+
| param | type | description |
|
|
1229
|
+
| ------- | -------- | --------------------------- |
|
|
1230
|
+
| `index` | `Number` | The byte index to update |
|
|
1231
|
+
| `value` | `Uint64` | The value to set |
|
|
1232
|
+
| `bytes` | `Bytes` | The byte sequence to mutate |
|
|
1153
1233
|
|
|
1154
1234
|
Throws:
|
|
1155
1235
|
|
|
@@ -1174,23 +1254,23 @@ No other changes yet.
|
|
|
1174
1254
|
</details>
|
|
1175
1255
|
|
|
1176
1256
|
```grain
|
|
1177
|
-
getFloat64
|
|
1257
|
+
getFloat64: (index: Number, bytes: Bytes) => Float64
|
|
1178
1258
|
```
|
|
1179
1259
|
|
|
1180
1260
|
Gets a 64-bit float starting at the given byte index.
|
|
1181
1261
|
|
|
1182
1262
|
Parameters:
|
|
1183
1263
|
|
|
1184
|
-
|param|type|description|
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1264
|
+
| param | type | description |
|
|
1265
|
+
| ------- | -------- | --------------------------- |
|
|
1266
|
+
| `index` | `Number` | The byte index to access |
|
|
1267
|
+
| `bytes` | `Bytes` | The byte sequence to access |
|
|
1188
1268
|
|
|
1189
1269
|
Returns:
|
|
1190
1270
|
|
|
1191
|
-
|type|description|
|
|
1192
|
-
|
|
1193
|
-
|
|
1271
|
+
| type | description |
|
|
1272
|
+
| --------- | --------------------------------------------- |
|
|
1273
|
+
| `Float64` | A 64-bit float that starts at the given index |
|
|
1194
1274
|
|
|
1195
1275
|
Throws:
|
|
1196
1276
|
|
|
@@ -1215,18 +1295,18 @@ No other changes yet.
|
|
|
1215
1295
|
</details>
|
|
1216
1296
|
|
|
1217
1297
|
```grain
|
|
1218
|
-
setFloat64
|
|
1298
|
+
setFloat64: (index: Number, value: Float64, bytes: Bytes) => Void
|
|
1219
1299
|
```
|
|
1220
1300
|
|
|
1221
1301
|
Sets a 64-bit float starting at the given byte index.
|
|
1222
1302
|
|
|
1223
1303
|
Parameters:
|
|
1224
1304
|
|
|
1225
|
-
|param|type|description|
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1305
|
+
| param | type | description |
|
|
1306
|
+
| ------- | --------- | --------------------------- |
|
|
1307
|
+
| `index` | `Number` | The byte index to update |
|
|
1308
|
+
| `value` | `Float64` | The value to set |
|
|
1309
|
+
| `bytes` | `Bytes` | The byte sequence to mutate |
|
|
1230
1310
|
|
|
1231
1311
|
Throws:
|
|
1232
1312
|
|