@grain/stdlib 0.5.13 → 0.6.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 +201 -0
- package/LICENSE +1 -1
- package/README.md +25 -2
- package/array.gr +1512 -199
- package/array.md +2032 -94
- package/bigint.gr +239 -140
- package/bigint.md +450 -106
- package/buffer.gr +595 -102
- package/buffer.md +903 -145
- package/bytes.gr +401 -110
- package/bytes.md +551 -63
- package/char.gr +228 -49
- package/char.md +373 -7
- package/exception.gr +26 -12
- package/exception.md +29 -5
- package/float32.gr +130 -109
- package/float32.md +185 -57
- package/float64.gr +112 -99
- package/float64.md +185 -57
- package/hash.gr +62 -40
- package/hash.md +27 -3
- package/int16.gr +430 -0
- package/int16.md +618 -0
- package/int32.gr +200 -269
- package/int32.md +254 -289
- package/int64.gr +142 -225
- package/int64.md +254 -289
- package/int8.gr +511 -0
- package/int8.md +786 -0
- package/json.gr +2071 -0
- package/json.md +646 -0
- package/list.gr +120 -68
- package/list.md +125 -80
- package/map.gr +560 -57
- package/map.md +672 -56
- package/marshal.gr +239 -227
- package/marshal.md +36 -4
- package/number.gr +626 -676
- package/number.md +738 -153
- package/option.gr +33 -35
- package/option.md +58 -42
- package/package.json +2 -2
- package/path.gr +148 -187
- package/path.md +47 -96
- package/pervasives.gr +75 -416
- package/pervasives.md +85 -180
- package/priorityqueue.gr +433 -74
- package/priorityqueue.md +422 -54
- package/queue.gr +362 -80
- package/queue.md +433 -38
- package/random.gr +67 -75
- package/random.md +68 -40
- package/range.gr +135 -63
- package/range.md +198 -43
- package/rational.gr +284 -0
- package/rational.md +545 -0
- package/regex.gr +933 -1066
- package/regex.md +59 -60
- package/result.gr +23 -25
- package/result.md +54 -39
- package/runtime/atof/common.gr +78 -82
- package/runtime/atof/common.md +22 -10
- package/runtime/atof/decimal.gr +102 -127
- package/runtime/atof/decimal.md +28 -7
- package/runtime/atof/lemire.gr +56 -71
- package/runtime/atof/lemire.md +9 -1
- package/runtime/atof/parse.gr +83 -110
- package/runtime/atof/parse.md +12 -2
- package/runtime/atof/slow.gr +28 -35
- package/runtime/atof/slow.md +9 -1
- package/runtime/atof/table.gr +19 -18
- package/runtime/atof/table.md +10 -2
- package/runtime/atoi/parse.gr +153 -136
- package/runtime/atoi/parse.md +50 -1
- package/runtime/bigint.gr +410 -517
- package/runtime/bigint.md +71 -57
- package/runtime/compare.gr +176 -85
- package/runtime/compare.md +31 -1
- package/runtime/dataStructures.gr +144 -32
- package/runtime/dataStructures.md +267 -31
- package/runtime/debugPrint.gr +34 -15
- package/runtime/debugPrint.md +37 -5
- package/runtime/equal.gr +53 -52
- package/runtime/equal.md +30 -1
- package/runtime/exception.gr +38 -47
- package/runtime/exception.md +10 -8
- package/runtime/gc.gr +23 -152
- package/runtime/gc.md +13 -17
- package/runtime/malloc.gr +31 -31
- package/runtime/malloc.md +11 -3
- package/runtime/numberUtils.gr +193 -174
- package/runtime/numberUtils.md +29 -9
- package/runtime/numbers.gr +1695 -1021
- package/runtime/numbers.md +1098 -134
- package/runtime/string.gr +543 -245
- package/runtime/string.md +76 -6
- package/runtime/unsafe/constants.gr +30 -13
- package/runtime/unsafe/constants.md +80 -0
- package/runtime/unsafe/conv.gr +55 -28
- package/runtime/unsafe/conv.md +41 -9
- package/runtime/unsafe/memory.gr +10 -30
- package/runtime/unsafe/memory.md +15 -19
- package/runtime/unsafe/tags.gr +37 -21
- package/runtime/unsafe/tags.md +88 -8
- package/runtime/unsafe/wasmf32.gr +30 -36
- package/runtime/unsafe/wasmf32.md +64 -56
- package/runtime/unsafe/wasmf64.gr +30 -36
- package/runtime/unsafe/wasmf64.md +64 -56
- package/runtime/unsafe/wasmi32.gr +49 -66
- package/runtime/unsafe/wasmi32.md +102 -94
- package/runtime/unsafe/wasmi64.gr +52 -79
- package/runtime/unsafe/wasmi64.md +108 -100
- package/runtime/utils/printing.gr +13 -15
- package/runtime/utils/printing.md +11 -3
- package/runtime/wasi.gr +294 -295
- package/runtime/wasi.md +62 -42
- package/set.gr +574 -64
- package/set.md +634 -54
- package/stack.gr +181 -64
- package/stack.md +271 -42
- package/string.gr +453 -533
- package/string.md +241 -151
- package/uint16.gr +369 -0
- package/uint16.md +585 -0
- package/uint32.gr +470 -0
- package/uint32.md +737 -0
- package/uint64.gr +471 -0
- package/uint64.md +737 -0
- package/uint8.gr +369 -0
- package/uint8.md +585 -0
- package/uri.gr +1093 -0
- package/uri.md +477 -0
- package/{sys → wasi}/file.gr +914 -500
- package/{sys → wasi}/file.md +454 -50
- package/wasi/process.gr +292 -0
- package/{sys → wasi}/process.md +164 -6
- package/wasi/random.gr +77 -0
- package/wasi/random.md +80 -0
- package/{sys → wasi}/time.gr +15 -22
- package/{sys → wasi}/time.md +5 -5
- package/immutablearray.gr +0 -929
- package/immutablearray.md +0 -1038
- package/immutablemap.gr +0 -493
- package/immutablemap.md +0 -479
- package/immutablepriorityqueue.gr +0 -360
- package/immutablepriorityqueue.md +0 -291
- package/immutableset.gr +0 -498
- package/immutableset.md +0 -449
- package/runtime/debug.gr +0 -2
- package/runtime/debug.md +0 -6
- package/runtime/unsafe/errors.gr +0 -36
- package/runtime/unsafe/errors.md +0 -204
- package/sys/process.gr +0 -254
- package/sys/random.gr +0 -79
- package/sys/random.md +0 -66
package/buffer.md
CHANGED
|
@@ -12,12 +12,26 @@ No other changes yet.
|
|
|
12
12
|
</details>
|
|
13
13
|
|
|
14
14
|
```grain
|
|
15
|
-
|
|
15
|
+
from "buffer" include Buffer
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```grain
|
|
19
|
+
Buffer.make(64)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Types
|
|
23
|
+
|
|
24
|
+
Type declarations included in the Buffer module.
|
|
25
|
+
|
|
26
|
+
### Buffer.**Buffer**
|
|
27
|
+
|
|
28
|
+
```grain
|
|
29
|
+
type Buffer
|
|
16
30
|
```
|
|
17
31
|
|
|
18
32
|
## Values
|
|
19
33
|
|
|
20
|
-
Functions
|
|
34
|
+
Functions and constants included in the Buffer module.
|
|
21
35
|
|
|
22
36
|
### Buffer.**make**
|
|
23
37
|
|
|
@@ -27,7 +41,7 @@ No other changes yet.
|
|
|
27
41
|
</details>
|
|
28
42
|
|
|
29
43
|
```grain
|
|
30
|
-
make : Number
|
|
44
|
+
make : (initialSize: Number) => Buffer
|
|
31
45
|
```
|
|
32
46
|
|
|
33
47
|
Creates a fresh buffer, initially empty.
|
|
@@ -53,6 +67,16 @@ Throws:
|
|
|
53
67
|
|
|
54
68
|
* When the `initialSize` is a negative number
|
|
55
69
|
|
|
70
|
+
Examples:
|
|
71
|
+
|
|
72
|
+
```grain
|
|
73
|
+
Buffer.make(0)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```grain
|
|
77
|
+
Buffer.make(64)
|
|
78
|
+
```
|
|
79
|
+
|
|
56
80
|
### Buffer.**length**
|
|
57
81
|
|
|
58
82
|
<details disabled>
|
|
@@ -61,7 +85,7 @@ No other changes yet.
|
|
|
61
85
|
</details>
|
|
62
86
|
|
|
63
87
|
```grain
|
|
64
|
-
length : Buffer
|
|
88
|
+
length : (buffer: Buffer) => Number
|
|
65
89
|
```
|
|
66
90
|
|
|
67
91
|
Gets the number of bytes currently contained in a buffer.
|
|
@@ -78,6 +102,18 @@ Returns:
|
|
|
78
102
|
|----|-----------|
|
|
79
103
|
|`Number`|The length of the buffer in bytes|
|
|
80
104
|
|
|
105
|
+
Examples:
|
|
106
|
+
|
|
107
|
+
```grain
|
|
108
|
+
Buffer.length(Buffer.make(32)) == 0
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
```grain
|
|
112
|
+
let buf = Buffer.make(32)
|
|
113
|
+
Buffer.addInt32(1l, buf)
|
|
114
|
+
assert Buffer.length(buf) == 4
|
|
115
|
+
```
|
|
116
|
+
|
|
81
117
|
### Buffer.**clear**
|
|
82
118
|
|
|
83
119
|
<details disabled>
|
|
@@ -86,7 +122,7 @@ No other changes yet.
|
|
|
86
122
|
</details>
|
|
87
123
|
|
|
88
124
|
```grain
|
|
89
|
-
clear : Buffer
|
|
125
|
+
clear : (buffer: Buffer) => Void
|
|
90
126
|
```
|
|
91
127
|
|
|
92
128
|
Clears data in the buffer and sets its length to zero.
|
|
@@ -99,6 +135,16 @@ Parameters:
|
|
|
99
135
|
|-----|----|-----------|
|
|
100
136
|
|`buffer`|`Buffer`|The buffer to clear|
|
|
101
137
|
|
|
138
|
+
Examples:
|
|
139
|
+
|
|
140
|
+
```grain
|
|
141
|
+
let buf = Buffer.make(0)
|
|
142
|
+
Buffer.addInt32(1l, buf)
|
|
143
|
+
assert Buffer.length(buf) == 4
|
|
144
|
+
Buffer.clear(buf)
|
|
145
|
+
assert Buffer.length(buf) == 0
|
|
146
|
+
```
|
|
147
|
+
|
|
102
148
|
### Buffer.**reset**
|
|
103
149
|
|
|
104
150
|
<details disabled>
|
|
@@ -107,7 +153,7 @@ No other changes yet.
|
|
|
107
153
|
</details>
|
|
108
154
|
|
|
109
155
|
```grain
|
|
110
|
-
reset : Buffer
|
|
156
|
+
reset : (buffer: Buffer) => Void
|
|
111
157
|
```
|
|
112
158
|
|
|
113
159
|
Empty a buffer and deallocate the internal byte sequence holding the buffer contents.
|
|
@@ -120,6 +166,16 @@ Parameters:
|
|
|
120
166
|
|-----|----|-----------|
|
|
121
167
|
|`buffer`|`Buffer`|The buffer to reset|
|
|
122
168
|
|
|
169
|
+
Examples:
|
|
170
|
+
|
|
171
|
+
```grain
|
|
172
|
+
let buf = Buffer.make(0)
|
|
173
|
+
Buffer.addInt32(1l, buf)
|
|
174
|
+
assert Buffer.length(buf) == 4
|
|
175
|
+
Buffer.reset(buf)
|
|
176
|
+
assert Buffer.length(buf) == 0
|
|
177
|
+
```
|
|
178
|
+
|
|
123
179
|
### Buffer.**truncate**
|
|
124
180
|
|
|
125
181
|
<details disabled>
|
|
@@ -128,7 +184,7 @@ No other changes yet.
|
|
|
128
184
|
</details>
|
|
129
185
|
|
|
130
186
|
```grain
|
|
131
|
-
truncate : (Number, Buffer)
|
|
187
|
+
truncate : (length: Number, buffer: Buffer) => Void
|
|
132
188
|
```
|
|
133
189
|
|
|
134
190
|
Shortens a buffer to the given length.
|
|
@@ -149,6 +205,16 @@ Throws:
|
|
|
149
205
|
* When the `length` is negative
|
|
150
206
|
* When the `length` is greater than the buffer size
|
|
151
207
|
|
|
208
|
+
Examples:
|
|
209
|
+
|
|
210
|
+
```grain
|
|
211
|
+
let buf = Buffer.make(0)
|
|
212
|
+
Buffer.addInt32(1l, buf)
|
|
213
|
+
assert Buffer.length(buf) == 4
|
|
214
|
+
Buffer.truncate(1, buf)
|
|
215
|
+
assert Buffer.length(buf) == 1
|
|
216
|
+
```
|
|
217
|
+
|
|
152
218
|
### Buffer.**toBytes**
|
|
153
219
|
|
|
154
220
|
<details disabled>
|
|
@@ -157,7 +223,7 @@ No other changes yet.
|
|
|
157
223
|
</details>
|
|
158
224
|
|
|
159
225
|
```grain
|
|
160
|
-
toBytes : Buffer
|
|
226
|
+
toBytes : (buffer: Buffer) => Bytes
|
|
161
227
|
```
|
|
162
228
|
|
|
163
229
|
Returns a copy of the current contents of the buffer as a byte sequence.
|
|
@@ -174,6 +240,14 @@ Returns:
|
|
|
174
240
|
|----|-----------|
|
|
175
241
|
|`Bytes`|A byte sequence made from copied buffer data|
|
|
176
242
|
|
|
243
|
+
Examples:
|
|
244
|
+
|
|
245
|
+
```grain
|
|
246
|
+
let buf = Buffer.make(0)
|
|
247
|
+
Buffer.addString("test", buf)
|
|
248
|
+
assert Buffer.toBytes(buf) == b"test"
|
|
249
|
+
```
|
|
250
|
+
|
|
177
251
|
### Buffer.**toBytesSlice**
|
|
178
252
|
|
|
179
253
|
<details disabled>
|
|
@@ -182,7 +256,7 @@ No other changes yet.
|
|
|
182
256
|
</details>
|
|
183
257
|
|
|
184
258
|
```grain
|
|
185
|
-
toBytesSlice : (Number, Number, Buffer)
|
|
259
|
+
toBytesSlice : (start: Number, length: Number, buffer: Buffer) => Bytes
|
|
186
260
|
```
|
|
187
261
|
|
|
188
262
|
Returns a slice of the current contents of the buffer as a byte sequence.
|
|
@@ -209,6 +283,14 @@ Throws:
|
|
|
209
283
|
* When `start` is greater than or equal to the buffer size
|
|
210
284
|
* When `start + length` is greater than the buffer size
|
|
211
285
|
|
|
286
|
+
Examples:
|
|
287
|
+
|
|
288
|
+
```grain
|
|
289
|
+
let buf = Buffer.make(0)
|
|
290
|
+
Buffer.addString("HelloWorld", buf)
|
|
291
|
+
assert Buffer.toBytesSlice(0, 5, buf) == b"Hello"
|
|
292
|
+
```
|
|
293
|
+
|
|
212
294
|
### Buffer.**toString**
|
|
213
295
|
|
|
214
296
|
<details disabled>
|
|
@@ -217,7 +299,7 @@ No other changes yet.
|
|
|
217
299
|
</details>
|
|
218
300
|
|
|
219
301
|
```grain
|
|
220
|
-
toString : Buffer
|
|
302
|
+
toString : (buffer: Buffer) => String
|
|
221
303
|
```
|
|
222
304
|
|
|
223
305
|
Returns a copy of the current contents of the buffer as a string.
|
|
@@ -234,6 +316,14 @@ Returns:
|
|
|
234
316
|
|----|-----------|
|
|
235
317
|
|`String`|A string made with data copied from the buffer|
|
|
236
318
|
|
|
319
|
+
Examples:
|
|
320
|
+
|
|
321
|
+
```grain
|
|
322
|
+
let buf = Buffer.make(0)
|
|
323
|
+
Buffer.addString("HelloWorld", buf)
|
|
324
|
+
assert Buffer.toString(buf) == "HelloWorld"
|
|
325
|
+
```
|
|
326
|
+
|
|
237
327
|
### Buffer.**toStringSlice**
|
|
238
328
|
|
|
239
329
|
<details disabled>
|
|
@@ -242,7 +332,7 @@ No other changes yet.
|
|
|
242
332
|
</details>
|
|
243
333
|
|
|
244
334
|
```grain
|
|
245
|
-
toStringSlice : (Number, Number, Buffer)
|
|
335
|
+
toStringSlice : (start: Number, length: Number, buffer: Buffer) => String
|
|
246
336
|
```
|
|
247
337
|
|
|
248
338
|
Returns a copy of a subset of the current contents of the buffer as a string.
|
|
@@ -261,6 +351,14 @@ Returns:
|
|
|
261
351
|
|----|-----------|
|
|
262
352
|
|`String`|A string made with a subset of data copied from the buffer|
|
|
263
353
|
|
|
354
|
+
Examples:
|
|
355
|
+
|
|
356
|
+
```grain
|
|
357
|
+
let buf = Buffer.make(0)
|
|
358
|
+
Buffer.addString("HelloWorld", buf)
|
|
359
|
+
assert Buffer.toStringSlice(0, 5, buf) == "Hello"
|
|
360
|
+
```
|
|
361
|
+
|
|
264
362
|
### Buffer.**addBytes**
|
|
265
363
|
|
|
266
364
|
<details disabled>
|
|
@@ -269,7 +367,7 @@ No other changes yet.
|
|
|
269
367
|
</details>
|
|
270
368
|
|
|
271
369
|
```grain
|
|
272
|
-
addBytes : (Bytes, Buffer)
|
|
370
|
+
addBytes : (bytes: Bytes, buffer: Buffer) => Void
|
|
273
371
|
```
|
|
274
372
|
|
|
275
373
|
Appends a byte sequence to a buffer.
|
|
@@ -281,6 +379,14 @@ Parameters:
|
|
|
281
379
|
|`bytes`|`Bytes`|The byte sequence to append|
|
|
282
380
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
283
381
|
|
|
382
|
+
Examples:
|
|
383
|
+
|
|
384
|
+
```grain
|
|
385
|
+
let buf = Buffer.make(0)
|
|
386
|
+
Buffer.addBytes(b"test", buf)
|
|
387
|
+
assert Buffer.toBytes(buf) == b"test"
|
|
388
|
+
```
|
|
389
|
+
|
|
284
390
|
### Buffer.**addString**
|
|
285
391
|
|
|
286
392
|
<details disabled>
|
|
@@ -289,7 +395,7 @@ No other changes yet.
|
|
|
289
395
|
</details>
|
|
290
396
|
|
|
291
397
|
```grain
|
|
292
|
-
addString : (String, Buffer)
|
|
398
|
+
addString : (string: String, buffer: Buffer) => Void
|
|
293
399
|
```
|
|
294
400
|
|
|
295
401
|
Appends the bytes of a string to a buffer.
|
|
@@ -301,6 +407,14 @@ Parameters:
|
|
|
301
407
|
|`string`|`String`|The string to append|
|
|
302
408
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
303
409
|
|
|
410
|
+
Examples:
|
|
411
|
+
|
|
412
|
+
```grain
|
|
413
|
+
let buf = Buffer.make(0)
|
|
414
|
+
Buffer.addString("Hello", buf)
|
|
415
|
+
assert Buffer.toString(buf) == "Hello"
|
|
416
|
+
```
|
|
417
|
+
|
|
304
418
|
### Buffer.**addChar**
|
|
305
419
|
|
|
306
420
|
<details disabled>
|
|
@@ -309,10 +423,10 @@ No other changes yet.
|
|
|
309
423
|
</details>
|
|
310
424
|
|
|
311
425
|
```grain
|
|
312
|
-
addChar : (Char, Buffer)
|
|
426
|
+
addChar : (char: Char, buffer: Buffer) => Void
|
|
313
427
|
```
|
|
314
428
|
|
|
315
|
-
Appends the bytes of a
|
|
429
|
+
Appends the bytes of a character to a buffer.
|
|
316
430
|
|
|
317
431
|
Parameters:
|
|
318
432
|
|
|
@@ -321,6 +435,42 @@ Parameters:
|
|
|
321
435
|
|`char`|`Char`|The character to append to the buffer|
|
|
322
436
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
323
437
|
|
|
438
|
+
Examples:
|
|
439
|
+
|
|
440
|
+
```grain
|
|
441
|
+
let buf = Buffer.make(0)
|
|
442
|
+
Buffer.addChar('H', buf)
|
|
443
|
+
assert Buffer.toString(buf) == "H"
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### Buffer.**addCharFromCodePoint**
|
|
447
|
+
|
|
448
|
+
<details disabled>
|
|
449
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
450
|
+
No other changes yet.
|
|
451
|
+
</details>
|
|
452
|
+
|
|
453
|
+
```grain
|
|
454
|
+
addCharFromCodePoint : (codePoint: Number, buffer: Buffer) => Void
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
Appends a character represented by a code point to a buffer.
|
|
458
|
+
|
|
459
|
+
Parameters:
|
|
460
|
+
|
|
461
|
+
|param|type|description|
|
|
462
|
+
|-----|----|-----------|
|
|
463
|
+
|`codePoint`|`Number`|The code point to append to the buffer|
|
|
464
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
465
|
+
|
|
466
|
+
Examples:
|
|
467
|
+
|
|
468
|
+
```grain
|
|
469
|
+
let buf = Buffer.make(0)
|
|
470
|
+
Buffer.addCharFromCodePoint(72, buf)
|
|
471
|
+
assert Buffer.toString(buf) == "H"
|
|
472
|
+
```
|
|
473
|
+
|
|
324
474
|
### Buffer.**addStringSlice**
|
|
325
475
|
|
|
326
476
|
<details>
|
|
@@ -336,7 +486,8 @@ Parameters:
|
|
|
336
486
|
</details>
|
|
337
487
|
|
|
338
488
|
```grain
|
|
339
|
-
addStringSlice :
|
|
489
|
+
addStringSlice :
|
|
490
|
+
(start: Number, end: Number, string: String, buffer: Buffer) => Void
|
|
340
491
|
```
|
|
341
492
|
|
|
342
493
|
Appends the bytes of a subset of a string to a buffer.
|
|
@@ -350,6 +501,14 @@ Parameters:
|
|
|
350
501
|
|`string`|`String`|The string to append|
|
|
351
502
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
352
503
|
|
|
504
|
+
Examples:
|
|
505
|
+
|
|
506
|
+
```grain
|
|
507
|
+
let buf = Buffer.make(0)
|
|
508
|
+
Buffer.addStringSlice(0, 5, "HelloWorld", buf)
|
|
509
|
+
assert Buffer.toString(buf) == "Hello"
|
|
510
|
+
```
|
|
511
|
+
|
|
353
512
|
### Buffer.**addBytesSlice**
|
|
354
513
|
|
|
355
514
|
<details disabled>
|
|
@@ -358,7 +517,8 @@ No other changes yet.
|
|
|
358
517
|
</details>
|
|
359
518
|
|
|
360
519
|
```grain
|
|
361
|
-
addBytesSlice :
|
|
520
|
+
addBytesSlice :
|
|
521
|
+
(start: Number, length: Number, bytes: Bytes, buffer: Buffer) => Void
|
|
362
522
|
```
|
|
363
523
|
|
|
364
524
|
Appends the bytes of a subset of a byte sequence to a buffer.
|
|
@@ -381,6 +541,14 @@ Throws:
|
|
|
381
541
|
* When the `length` is negative
|
|
382
542
|
* When the `length` is greater than the `bytes` length minus `start`
|
|
383
543
|
|
|
544
|
+
Examples:
|
|
545
|
+
|
|
546
|
+
```grain
|
|
547
|
+
let buf = Buffer.make(0)
|
|
548
|
+
Buffer.addBytesSlice(0, 5, b"HelloWorld", buf)
|
|
549
|
+
assert Buffer.toString(buf) == "Hello"
|
|
550
|
+
```
|
|
551
|
+
|
|
384
552
|
### Buffer.**addBuffer**
|
|
385
553
|
|
|
386
554
|
<details disabled>
|
|
@@ -389,7 +557,7 @@ No other changes yet.
|
|
|
389
557
|
</details>
|
|
390
558
|
|
|
391
559
|
```grain
|
|
392
|
-
addBuffer : (Buffer, Buffer)
|
|
560
|
+
addBuffer : (srcBuffer: Buffer, dstBuffer: Buffer) => Void
|
|
393
561
|
```
|
|
394
562
|
|
|
395
563
|
Appends the bytes of a source buffer to destination buffer.
|
|
@@ -403,6 +571,17 @@ Parameters:
|
|
|
403
571
|
|`srcBuffer`|`Buffer`|The buffer to append|
|
|
404
572
|
|`dstBuffer`|`Buffer`|The buffer to mutate|
|
|
405
573
|
|
|
574
|
+
Examples:
|
|
575
|
+
|
|
576
|
+
```grain
|
|
577
|
+
let buf1 = Buffer.make(0)
|
|
578
|
+
Buffer.addString("Hello", buf1)
|
|
579
|
+
let buf2 = Buffer.make(0)
|
|
580
|
+
Buffer.addString("World", buf2)
|
|
581
|
+
Buffer.addBuffer(buf2, buf1)
|
|
582
|
+
assert Buffer.toString(buf1) == "HelloWorld"
|
|
583
|
+
```
|
|
584
|
+
|
|
406
585
|
### Buffer.**addBufferSlice**
|
|
407
586
|
|
|
408
587
|
<details disabled>
|
|
@@ -411,7 +590,9 @@ No other changes yet.
|
|
|
411
590
|
</details>
|
|
412
591
|
|
|
413
592
|
```grain
|
|
414
|
-
addBufferSlice :
|
|
593
|
+
addBufferSlice :
|
|
594
|
+
(start: Number, length: Number, srcBuffer: Buffer, dstBuffer: Buffer) =>
|
|
595
|
+
Void
|
|
415
596
|
```
|
|
416
597
|
|
|
417
598
|
Appends the bytes of a part of a buffer to the end of the buffer
|
|
@@ -427,19 +608,33 @@ Parameters:
|
|
|
427
608
|
|`srcBuffer`|`Buffer`|The buffer to append|
|
|
428
609
|
|`dstBuffer`|`Buffer`|The buffer to mutate|
|
|
429
610
|
|
|
430
|
-
|
|
611
|
+
Examples:
|
|
431
612
|
|
|
432
|
-
|
|
613
|
+
```grain
|
|
614
|
+
let buf1 = Buffer.make(0)
|
|
615
|
+
Buffer.addString("Hello", buf1)
|
|
616
|
+
let buf2 = Buffer.make(0)
|
|
617
|
+
Buffer.addString("HiWorld", buf2)
|
|
618
|
+
Buffer.addBufferSlice(2, 5, buf2, buf1)
|
|
619
|
+
assert Buffer.toString(buf1) == "HelloWorld"
|
|
620
|
+
```
|
|
433
621
|
|
|
434
|
-
### Buffer.**
|
|
622
|
+
### Buffer.**getInt8**
|
|
435
623
|
|
|
436
|
-
<details
|
|
437
|
-
<summary
|
|
438
|
-
|
|
624
|
+
<details>
|
|
625
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
626
|
+
<table>
|
|
627
|
+
<thead>
|
|
628
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
629
|
+
</thead>
|
|
630
|
+
<tbody>
|
|
631
|
+
<tr><td><code>0.4.0</code></td><td>Originally called `getInt8S`, returning an `Int32`</td></tr>
|
|
632
|
+
</tbody>
|
|
633
|
+
</table>
|
|
439
634
|
</details>
|
|
440
635
|
|
|
441
636
|
```grain
|
|
442
|
-
|
|
637
|
+
getInt8 : (index: Number, buffer: Buffer) => Int8
|
|
443
638
|
```
|
|
444
639
|
|
|
445
640
|
Gets a signed 8-bit integer starting at the given byte index.
|
|
@@ -455,7 +650,7 @@ Returns:
|
|
|
455
650
|
|
|
456
651
|
|type|description|
|
|
457
652
|
|----|-----------|
|
|
458
|
-
|`
|
|
653
|
+
|`Int8`|A signed 8-bit integer that starts at the given index|
|
|
459
654
|
|
|
460
655
|
Throws:
|
|
461
656
|
|
|
@@ -465,49 +660,30 @@ Throws:
|
|
|
465
660
|
* When `index` is greater than or equal to the buffer size
|
|
466
661
|
* When `index + 1` is greater than the buffer size
|
|
467
662
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
<details disabled>
|
|
471
|
-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
472
|
-
No other changes yet.
|
|
473
|
-
</details>
|
|
663
|
+
Examples:
|
|
474
664
|
|
|
475
665
|
```grain
|
|
476
|
-
|
|
666
|
+
let buf = Buffer.make(0)
|
|
667
|
+
Buffer.addInt8(1s, buf)
|
|
668
|
+
assert Buffer.getInt8(0, buf) == 1s
|
|
477
669
|
```
|
|
478
670
|
|
|
479
|
-
Gets an unsigned 8-bit integer starting at the given byte index.
|
|
480
|
-
|
|
481
|
-
Parameters:
|
|
482
|
-
|
|
483
|
-
|param|type|description|
|
|
484
|
-
|-----|----|-----------|
|
|
485
|
-
|`index`|`Number`|The byte index to access|
|
|
486
|
-
|`buffer`|`Buffer`|The buffer to access|
|
|
487
|
-
|
|
488
|
-
Returns:
|
|
489
|
-
|
|
490
|
-
|type|description|
|
|
491
|
-
|----|-----------|
|
|
492
|
-
|`Int32`|A 32-bit integer representing an unsigned 8-bit integer that starts at the given index|
|
|
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
|
-
|
|
502
671
|
### Buffer.**setInt8**
|
|
503
672
|
|
|
504
|
-
<details
|
|
505
|
-
<summary
|
|
506
|
-
|
|
673
|
+
<details>
|
|
674
|
+
<summary>Added in <code>0.4.0</code></summary>
|
|
675
|
+
<table>
|
|
676
|
+
<thead>
|
|
677
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
678
|
+
</thead>
|
|
679
|
+
<tbody>
|
|
680
|
+
<tr><td><code>0.6.0</code></td><td>`value` argument type changed to `Int8`</td></tr>
|
|
681
|
+
</tbody>
|
|
682
|
+
</table>
|
|
507
683
|
</details>
|
|
508
684
|
|
|
509
685
|
```grain
|
|
510
|
-
setInt8 : (Number,
|
|
686
|
+
setInt8 : (index: Number, value: Int8, buffer: Buffer) => Void
|
|
511
687
|
```
|
|
512
688
|
|
|
513
689
|
Sets a signed 8-bit integer starting at the given byte index.
|
|
@@ -517,7 +693,7 @@ Parameters:
|
|
|
517
693
|
|param|type|description|
|
|
518
694
|
|-----|----|-----------|
|
|
519
695
|
|`index`|`Number`|The byte index to update|
|
|
520
|
-
|`value`|`
|
|
696
|
+
|`value`|`Int8`|The value to set|
|
|
521
697
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
522
698
|
|
|
523
699
|
Throws:
|
|
@@ -528,15 +704,31 @@ Throws:
|
|
|
528
704
|
* When `index` is greater than or equal to the buffer size
|
|
529
705
|
* When `index + 1` is greater than the buffer size
|
|
530
706
|
|
|
707
|
+
Examples:
|
|
708
|
+
|
|
709
|
+
```grain
|
|
710
|
+
let buf = Buffer.make(32)
|
|
711
|
+
Buffer.addString("Hello World", buf)
|
|
712
|
+
Buffer.setInt8(0, 3s, buf)
|
|
713
|
+
assert Buffer.getInt8(0, buf) == 3s
|
|
714
|
+
```
|
|
715
|
+
|
|
531
716
|
### Buffer.**addInt8**
|
|
532
717
|
|
|
533
|
-
<details
|
|
534
|
-
<summary
|
|
535
|
-
|
|
718
|
+
<details>
|
|
719
|
+
<summary>Added in <code>0.4.0</code></summary>
|
|
720
|
+
<table>
|
|
721
|
+
<thead>
|
|
722
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
723
|
+
</thead>
|
|
724
|
+
<tbody>
|
|
725
|
+
<tr><td><code>0.6.0</code></td><td>`value` argument type changed to `Int8`</td></tr>
|
|
726
|
+
</tbody>
|
|
727
|
+
</table>
|
|
536
728
|
</details>
|
|
537
729
|
|
|
538
730
|
```grain
|
|
539
|
-
addInt8 : (
|
|
731
|
+
addInt8 : (value: Int8, buffer: Buffer) => Void
|
|
540
732
|
```
|
|
541
733
|
|
|
542
734
|
Appends a signed 8-bit integer to a buffer.
|
|
@@ -545,55 +737,36 @@ Parameters:
|
|
|
545
737
|
|
|
546
738
|
|param|type|description|
|
|
547
739
|
|-----|----|-----------|
|
|
548
|
-
|`value`|`
|
|
740
|
+
|`value`|`Int8`|The value to append|
|
|
549
741
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
550
742
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
<details disabled>
|
|
554
|
-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
555
|
-
No other changes yet.
|
|
556
|
-
</details>
|
|
743
|
+
Examples:
|
|
557
744
|
|
|
558
745
|
```grain
|
|
559
|
-
|
|
746
|
+
let buf = Buffer.make(0)
|
|
747
|
+
Buffer.addInt8(2s, buf)
|
|
748
|
+
assert Buffer.getInt8(0, buf) == 2s
|
|
560
749
|
```
|
|
561
750
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
Parameters:
|
|
565
|
-
|
|
566
|
-
|param|type|description|
|
|
567
|
-
|-----|----|-----------|
|
|
568
|
-
|`index`|`Number`|The byte index to access|
|
|
569
|
-
|`buffer`|`Buffer`|The buffer to access|
|
|
570
|
-
|
|
571
|
-
Returns:
|
|
572
|
-
|
|
573
|
-
|type|description|
|
|
574
|
-
|----|-----------|
|
|
575
|
-
|`Int32`|A 32-bit integer representing a signed 16-bit integer that starts at the given index|
|
|
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
|
-
|
|
585
|
-
### Buffer.**getInt16U**
|
|
751
|
+
### Buffer.**getUint8**
|
|
586
752
|
|
|
587
|
-
<details
|
|
588
|
-
<summary
|
|
589
|
-
|
|
753
|
+
<details>
|
|
754
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
755
|
+
<table>
|
|
756
|
+
<thead>
|
|
757
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
758
|
+
</thead>
|
|
759
|
+
<tbody>
|
|
760
|
+
<tr><td><code>0.4.0</code></td><td>Originally called `getInt8U`, returning an `Int32`</td></tr>
|
|
761
|
+
</tbody>
|
|
762
|
+
</table>
|
|
590
763
|
</details>
|
|
591
764
|
|
|
592
765
|
```grain
|
|
593
|
-
|
|
766
|
+
getUint8 : (index: Number, buffer: Buffer) => Uint8
|
|
594
767
|
```
|
|
595
768
|
|
|
596
|
-
Gets an unsigned
|
|
769
|
+
Gets an unsigned 8-bit integer starting at the given byte index.
|
|
597
770
|
|
|
598
771
|
Parameters:
|
|
599
772
|
|
|
@@ -606,7 +779,7 @@ Returns:
|
|
|
606
779
|
|
|
607
780
|
|type|description|
|
|
608
781
|
|----|-----------|
|
|
609
|
-
|`
|
|
782
|
+
|`Uint8`|An unsigned 8-bit integer that starts at the given index|
|
|
610
783
|
|
|
611
784
|
Throws:
|
|
612
785
|
|
|
@@ -614,27 +787,35 @@ Throws:
|
|
|
614
787
|
|
|
615
788
|
* When `index` is negative
|
|
616
789
|
* When `index` is greater than or equal to the buffer size
|
|
617
|
-
* When `index +
|
|
790
|
+
* When `index + 1` is greater than the buffer size
|
|
618
791
|
|
|
619
|
-
|
|
792
|
+
Examples:
|
|
793
|
+
|
|
794
|
+
```grain
|
|
795
|
+
let buf = Buffer.make(32)
|
|
796
|
+
Buffer.addUint8(3us, buf)
|
|
797
|
+
assert Buffer.getUint8(0, buf) == 3us
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
### Buffer.**setUint8**
|
|
620
801
|
|
|
621
802
|
<details disabled>
|
|
622
|
-
<summary tabindex="-1">Added in <code>0.
|
|
803
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
623
804
|
No other changes yet.
|
|
624
805
|
</details>
|
|
625
806
|
|
|
626
807
|
```grain
|
|
627
|
-
|
|
808
|
+
setUint8 : (index: Number, value: Uint8, buffer: Buffer) => Void
|
|
628
809
|
```
|
|
629
810
|
|
|
630
|
-
Sets
|
|
811
|
+
Sets an unsigned 8-bit integer starting at the given byte index.
|
|
631
812
|
|
|
632
813
|
Parameters:
|
|
633
814
|
|
|
634
815
|
|param|type|description|
|
|
635
816
|
|-----|----|-----------|
|
|
636
817
|
|`index`|`Number`|The byte index to update|
|
|
637
|
-
|`value`|`
|
|
818
|
+
|`value`|`Uint8`|The value to set|
|
|
638
819
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
639
820
|
|
|
640
821
|
Throws:
|
|
@@ -643,40 +824,64 @@ Throws:
|
|
|
643
824
|
|
|
644
825
|
* When `index` is negative
|
|
645
826
|
* When `index` is greater than or equal to the buffer size
|
|
646
|
-
* When `index +
|
|
827
|
+
* When `index + 1` is greater than the buffer size
|
|
647
828
|
|
|
648
|
-
|
|
829
|
+
Examples:
|
|
830
|
+
|
|
831
|
+
```grain
|
|
832
|
+
let buf = Buffer.make(32)
|
|
833
|
+
Buffer.addString("Hello World", buf)
|
|
834
|
+
Buffer.setUint8(4us, buf)
|
|
835
|
+
assert Buffer.getUint8(0, buf) == 4us
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
### Buffer.**addUint8**
|
|
649
839
|
|
|
650
840
|
<details disabled>
|
|
651
|
-
<summary tabindex="-1">Added in <code>0.
|
|
841
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
652
842
|
No other changes yet.
|
|
653
843
|
</details>
|
|
654
844
|
|
|
655
845
|
```grain
|
|
656
|
-
|
|
846
|
+
addUint8 : (value: Uint8, buffer: Buffer) => Void
|
|
657
847
|
```
|
|
658
848
|
|
|
659
|
-
Appends
|
|
849
|
+
Appends an unsigned 8-bit integer to a buffer.
|
|
660
850
|
|
|
661
851
|
Parameters:
|
|
662
852
|
|
|
663
853
|
|param|type|description|
|
|
664
854
|
|-----|----|-----------|
|
|
665
|
-
|`value`|`
|
|
855
|
+
|`value`|`Uint8`|The value to append|
|
|
666
856
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
667
857
|
|
|
668
|
-
|
|
858
|
+
Examples:
|
|
669
859
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
860
|
+
```grain
|
|
861
|
+
let buf = Buffer.make(32)
|
|
862
|
+
Buffer.addUint8(0us, buf)
|
|
863
|
+
assert Buffer.getUint8(0, buf) == 0us
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
### Buffer.**getInt16**
|
|
867
|
+
|
|
868
|
+
<details>
|
|
869
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
870
|
+
<table>
|
|
871
|
+
<thead>
|
|
872
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
873
|
+
</thead>
|
|
874
|
+
<tbody>
|
|
875
|
+
<tr><td><code>0.4.0</code></td><td>Originally called `getInt16S`, returning an `Int32`</td></tr>
|
|
876
|
+
</tbody>
|
|
877
|
+
</table>
|
|
673
878
|
</details>
|
|
674
879
|
|
|
675
880
|
```grain
|
|
676
|
-
|
|
881
|
+
getInt16 : (index: Number, buffer: Buffer) => Int16
|
|
677
882
|
```
|
|
678
883
|
|
|
679
|
-
Gets a signed
|
|
884
|
+
Gets a signed 16-bit integer starting at the given byte index.
|
|
680
885
|
|
|
681
886
|
Parameters:
|
|
682
887
|
|
|
@@ -689,7 +894,7 @@ Returns:
|
|
|
689
894
|
|
|
690
895
|
|type|description|
|
|
691
896
|
|----|-----------|
|
|
692
|
-
|`
|
|
897
|
+
|`Int16`|A signed 16-bit integer that starts at the given index|
|
|
693
898
|
|
|
694
899
|
Throws:
|
|
695
900
|
|
|
@@ -697,24 +902,269 @@ Throws:
|
|
|
697
902
|
|
|
698
903
|
* When `index` is negative
|
|
699
904
|
* When `index` is greater than or equal to the buffer size
|
|
700
|
-
* When `index +
|
|
701
|
-
|
|
702
|
-
### Buffer.**setInt32**
|
|
905
|
+
* When `index + 2` is greater than the buffer size
|
|
703
906
|
|
|
704
|
-
|
|
705
|
-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
706
|
-
No other changes yet.
|
|
707
|
-
</details>
|
|
907
|
+
Examples:
|
|
708
908
|
|
|
709
909
|
```grain
|
|
710
|
-
|
|
910
|
+
let buf = Buffer.make(32)
|
|
911
|
+
Buffer.addInt16(1S, buf)
|
|
912
|
+
assert Buffer.getInt16(0, buf) == 1S
|
|
711
913
|
```
|
|
712
914
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
Parameters:
|
|
915
|
+
### Buffer.**setInt16**
|
|
716
916
|
|
|
717
|
-
|
|
917
|
+
<details>
|
|
918
|
+
<summary>Added in <code>0.4.0</code></summary>
|
|
919
|
+
<table>
|
|
920
|
+
<thead>
|
|
921
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
922
|
+
</thead>
|
|
923
|
+
<tbody>
|
|
924
|
+
<tr><td><code>0.6.0</code></td><td>`value` argument type changed to `Int16`</td></tr>
|
|
925
|
+
</tbody>
|
|
926
|
+
</table>
|
|
927
|
+
</details>
|
|
928
|
+
|
|
929
|
+
```grain
|
|
930
|
+
setInt16 : (index: Number, value: Int16, buffer: Buffer) => Void
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
Sets a signed 16-bit integer starting at the given byte index.
|
|
934
|
+
|
|
935
|
+
Parameters:
|
|
936
|
+
|
|
937
|
+
|param|type|description|
|
|
938
|
+
|-----|----|-----------|
|
|
939
|
+
|`index`|`Number`|The byte index to update|
|
|
940
|
+
|`value`|`Int16`|The value to set|
|
|
941
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
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 + 2` is greater than the buffer size
|
|
950
|
+
|
|
951
|
+
Examples:
|
|
952
|
+
|
|
953
|
+
```grain
|
|
954
|
+
let buf = Buffer.make(32)
|
|
955
|
+
Buffer.addString("Hello World", buf)
|
|
956
|
+
Buffer.setInt16(5, 1S, buf)
|
|
957
|
+
assert Buffer.getInt16(5, buf) == 1S
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
### Buffer.**addInt16**
|
|
961
|
+
|
|
962
|
+
<details>
|
|
963
|
+
<summary>Added in <code>0.4.0</code></summary>
|
|
964
|
+
<table>
|
|
965
|
+
<thead>
|
|
966
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
967
|
+
</thead>
|
|
968
|
+
<tbody>
|
|
969
|
+
<tr><td><code>0.6.0</code></td><td>`value` argument type changed to `Int16`</td></tr>
|
|
970
|
+
</tbody>
|
|
971
|
+
</table>
|
|
972
|
+
</details>
|
|
973
|
+
|
|
974
|
+
```grain
|
|
975
|
+
addInt16 : (value: Int16, buffer: Buffer) => Void
|
|
976
|
+
```
|
|
977
|
+
|
|
978
|
+
Appends a signed 16-bit integer to a buffer.
|
|
979
|
+
|
|
980
|
+
Parameters:
|
|
981
|
+
|
|
982
|
+
|param|type|description|
|
|
983
|
+
|-----|----|-----------|
|
|
984
|
+
|`value`|`Int16`|The value to append|
|
|
985
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
986
|
+
|
|
987
|
+
Examples:
|
|
988
|
+
|
|
989
|
+
```grain
|
|
990
|
+
let buf = Buffer.make(0)
|
|
991
|
+
Buffer.addInt16(2S, buf)
|
|
992
|
+
assert Buffer.getInt16(0, buf) == 2S
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
### Buffer.**getUint16**
|
|
996
|
+
|
|
997
|
+
<details>
|
|
998
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
999
|
+
<table>
|
|
1000
|
+
<thead>
|
|
1001
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
1002
|
+
</thead>
|
|
1003
|
+
<tbody>
|
|
1004
|
+
<tr><td><code>0.4.0</code></td><td>Originally called `getInt16U`, returning an `Int32`</td></tr>
|
|
1005
|
+
</tbody>
|
|
1006
|
+
</table>
|
|
1007
|
+
</details>
|
|
1008
|
+
|
|
1009
|
+
```grain
|
|
1010
|
+
getUint16 : (index: Number, buffer: Buffer) => Uint16
|
|
1011
|
+
```
|
|
1012
|
+
|
|
1013
|
+
Gets an unsigned 16-bit integer starting at the given byte index.
|
|
1014
|
+
|
|
1015
|
+
Parameters:
|
|
1016
|
+
|
|
1017
|
+
|param|type|description|
|
|
1018
|
+
|-----|----|-----------|
|
|
1019
|
+
|`index`|`Number`|The byte index to access|
|
|
1020
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
1021
|
+
|
|
1022
|
+
Returns:
|
|
1023
|
+
|
|
1024
|
+
|type|description|
|
|
1025
|
+
|----|-----------|
|
|
1026
|
+
|`Uint16`|An unsigned 16-bit integer that starts at the given index|
|
|
1027
|
+
|
|
1028
|
+
Throws:
|
|
1029
|
+
|
|
1030
|
+
`IndexOutOfBounds`
|
|
1031
|
+
|
|
1032
|
+
* When `index` is negative
|
|
1033
|
+
* When `index` is greater than or equal to the buffer size
|
|
1034
|
+
* When `index + 2` is greater than the buffer size
|
|
1035
|
+
|
|
1036
|
+
Examples:
|
|
1037
|
+
|
|
1038
|
+
```grain
|
|
1039
|
+
let buf = Buffer.make(0)
|
|
1040
|
+
Buffer.addUint16(1uS, buf)
|
|
1041
|
+
assert Buffer.getUint16(0, buf) == 1uS
|
|
1042
|
+
```
|
|
1043
|
+
|
|
1044
|
+
### Buffer.**setUint16**
|
|
1045
|
+
|
|
1046
|
+
<details disabled>
|
|
1047
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
1048
|
+
No other changes yet.
|
|
1049
|
+
</details>
|
|
1050
|
+
|
|
1051
|
+
```grain
|
|
1052
|
+
setUint16 : (index: Number, value: Uint16, buffer: Buffer) => Void
|
|
1053
|
+
```
|
|
1054
|
+
|
|
1055
|
+
Sets an unsigned 16-bit integer starting at the given byte index.
|
|
1056
|
+
|
|
1057
|
+
Parameters:
|
|
1058
|
+
|
|
1059
|
+
|param|type|description|
|
|
1060
|
+
|-----|----|-----------|
|
|
1061
|
+
|`index`|`Number`|The byte index to update|
|
|
1062
|
+
|`value`|`Uint16`|The value to set|
|
|
1063
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
1064
|
+
|
|
1065
|
+
Throws:
|
|
1066
|
+
|
|
1067
|
+
`IndexOutOfBounds`
|
|
1068
|
+
|
|
1069
|
+
* When `index` is negative
|
|
1070
|
+
* When `index` is greater than or equal to the buffer size
|
|
1071
|
+
* When `index + 2` is greater than the buffer size
|
|
1072
|
+
|
|
1073
|
+
Examples:
|
|
1074
|
+
|
|
1075
|
+
```grain
|
|
1076
|
+
let buf = Buffer.make(32)
|
|
1077
|
+
Buffer.addString("Hello World", buf)
|
|
1078
|
+
Buffer.setUint16(0, 1uS, buf)
|
|
1079
|
+
assert Buffer.getUint16(0, buf) == 1uS
|
|
1080
|
+
```
|
|
1081
|
+
|
|
1082
|
+
### Buffer.**addUint16**
|
|
1083
|
+
|
|
1084
|
+
<details disabled>
|
|
1085
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
1086
|
+
No other changes yet.
|
|
1087
|
+
</details>
|
|
1088
|
+
|
|
1089
|
+
```grain
|
|
1090
|
+
addUint16 : (value: Uint16, buffer: Buffer) => Void
|
|
1091
|
+
```
|
|
1092
|
+
|
|
1093
|
+
Appends an unsigned 16-bit integer to a buffer.
|
|
1094
|
+
|
|
1095
|
+
Parameters:
|
|
1096
|
+
|
|
1097
|
+
|param|type|description|
|
|
1098
|
+
|-----|----|-----------|
|
|
1099
|
+
|`value`|`Uint16`|The value to append|
|
|
1100
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
1101
|
+
|
|
1102
|
+
Examples:
|
|
1103
|
+
|
|
1104
|
+
```grain
|
|
1105
|
+
let buf = Buffer.make(0)
|
|
1106
|
+
Buffer.addUint16(0, 2uS, buf)
|
|
1107
|
+
assert Buffer.getUint16(0, buf) == 2uS
|
|
1108
|
+
```
|
|
1109
|
+
|
|
1110
|
+
### Buffer.**getInt32**
|
|
1111
|
+
|
|
1112
|
+
<details disabled>
|
|
1113
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
1114
|
+
No other changes yet.
|
|
1115
|
+
</details>
|
|
1116
|
+
|
|
1117
|
+
```grain
|
|
1118
|
+
getInt32 : (index: Number, buffer: Buffer) => Int32
|
|
1119
|
+
```
|
|
1120
|
+
|
|
1121
|
+
Gets a signed 32-bit integer starting at the given byte index.
|
|
1122
|
+
|
|
1123
|
+
Parameters:
|
|
1124
|
+
|
|
1125
|
+
|param|type|description|
|
|
1126
|
+
|-----|----|-----------|
|
|
1127
|
+
|`index`|`Number`|The byte index to access|
|
|
1128
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
1129
|
+
|
|
1130
|
+
Returns:
|
|
1131
|
+
|
|
1132
|
+
|type|description|
|
|
1133
|
+
|----|-----------|
|
|
1134
|
+
|`Int32`|A signed 32-bit integer that starts at the given index|
|
|
1135
|
+
|
|
1136
|
+
Throws:
|
|
1137
|
+
|
|
1138
|
+
`IndexOutOfBounds`
|
|
1139
|
+
|
|
1140
|
+
* When `index` is negative
|
|
1141
|
+
* When `index` is greater than or equal to the buffer size
|
|
1142
|
+
* When `index + 4` is greater than the buffer size
|
|
1143
|
+
|
|
1144
|
+
Examples:
|
|
1145
|
+
|
|
1146
|
+
```grain
|
|
1147
|
+
let buf = Buffer.make(0)
|
|
1148
|
+
Buffer.addInt32(1l, buf)
|
|
1149
|
+
assert Buffer.getInt32(0, buf) == 1l
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
### Buffer.**setInt32**
|
|
1153
|
+
|
|
1154
|
+
<details disabled>
|
|
1155
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
1156
|
+
No other changes yet.
|
|
1157
|
+
</details>
|
|
1158
|
+
|
|
1159
|
+
```grain
|
|
1160
|
+
setInt32 : (index: Number, value: Int32, buffer: Buffer) => Void
|
|
1161
|
+
```
|
|
1162
|
+
|
|
1163
|
+
Sets a signed 32-bit integer starting at the given byte index.
|
|
1164
|
+
|
|
1165
|
+
Parameters:
|
|
1166
|
+
|
|
1167
|
+
|param|type|description|
|
|
718
1168
|
|-----|----|-----------|
|
|
719
1169
|
|`index`|`Number`|The byte index to update|
|
|
720
1170
|
|`value`|`Int32`|The value to set|
|
|
@@ -728,6 +1178,15 @@ Throws:
|
|
|
728
1178
|
* When `index` is greater than or equal to the buffer size
|
|
729
1179
|
* When `index + 4` is greater than the buffer size
|
|
730
1180
|
|
|
1181
|
+
Examples:
|
|
1182
|
+
|
|
1183
|
+
```grain
|
|
1184
|
+
let buf = Buffer.make(64)
|
|
1185
|
+
Buffer.addString("Hello World", buf)
|
|
1186
|
+
Buffer.setInt32(3, 1l, buf)
|
|
1187
|
+
assert Buffer.getInt32(3, buf) == 1l
|
|
1188
|
+
```
|
|
1189
|
+
|
|
731
1190
|
### Buffer.**addInt32**
|
|
732
1191
|
|
|
733
1192
|
<details disabled>
|
|
@@ -736,7 +1195,7 @@ No other changes yet.
|
|
|
736
1195
|
</details>
|
|
737
1196
|
|
|
738
1197
|
```grain
|
|
739
|
-
addInt32 : (Int32, Buffer)
|
|
1198
|
+
addInt32 : (value: Int32, buffer: Buffer) => Void
|
|
740
1199
|
```
|
|
741
1200
|
|
|
742
1201
|
Appends a signed 32-bit integer to a buffer.
|
|
@@ -748,6 +1207,122 @@ Parameters:
|
|
|
748
1207
|
|`value`|`Int32`|The value to append|
|
|
749
1208
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
750
1209
|
|
|
1210
|
+
Examples:
|
|
1211
|
+
|
|
1212
|
+
```grain
|
|
1213
|
+
let buf = Buffer.make(64)
|
|
1214
|
+
Buffer.addInt32(1l, buf)
|
|
1215
|
+
assert Buffer.getInt32(0, buf) == 1l
|
|
1216
|
+
```
|
|
1217
|
+
|
|
1218
|
+
### Buffer.**getUint32**
|
|
1219
|
+
|
|
1220
|
+
<details disabled>
|
|
1221
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
1222
|
+
No other changes yet.
|
|
1223
|
+
</details>
|
|
1224
|
+
|
|
1225
|
+
```grain
|
|
1226
|
+
getUint32 : (index: Number, buffer: Buffer) => Uint32
|
|
1227
|
+
```
|
|
1228
|
+
|
|
1229
|
+
Gets an unsigned 32-bit integer starting at the given byte index.
|
|
1230
|
+
|
|
1231
|
+
Parameters:
|
|
1232
|
+
|
|
1233
|
+
|param|type|description|
|
|
1234
|
+
|-----|----|-----------|
|
|
1235
|
+
|`index`|`Number`|The byte index to access|
|
|
1236
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
1237
|
+
|
|
1238
|
+
Returns:
|
|
1239
|
+
|
|
1240
|
+
|type|description|
|
|
1241
|
+
|----|-----------|
|
|
1242
|
+
|`Uint32`|An unsigned 32-bit integer that starts at the given index|
|
|
1243
|
+
|
|
1244
|
+
Throws:
|
|
1245
|
+
|
|
1246
|
+
`IndexOutOfBounds`
|
|
1247
|
+
|
|
1248
|
+
* When `index` is negative
|
|
1249
|
+
* When `index` is greater than or equal to the buffer size
|
|
1250
|
+
* When `index + 4` is greater than the buffer size
|
|
1251
|
+
|
|
1252
|
+
Examples:
|
|
1253
|
+
|
|
1254
|
+
```grain
|
|
1255
|
+
let buf = Buffer.make(32)
|
|
1256
|
+
Buffer.addUint32(1ul, buf)
|
|
1257
|
+
assert Buffer.getUint32(0, buf) == 1ul
|
|
1258
|
+
```
|
|
1259
|
+
|
|
1260
|
+
### Buffer.**setUint32**
|
|
1261
|
+
|
|
1262
|
+
<details disabled>
|
|
1263
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
1264
|
+
No other changes yet.
|
|
1265
|
+
</details>
|
|
1266
|
+
|
|
1267
|
+
```grain
|
|
1268
|
+
setUint32 : (index: Number, value: Uint32, buffer: Buffer) => Void
|
|
1269
|
+
```
|
|
1270
|
+
|
|
1271
|
+
Sets an unsigned 32-bit integer starting at the given byte index.
|
|
1272
|
+
|
|
1273
|
+
Parameters:
|
|
1274
|
+
|
|
1275
|
+
|param|type|description|
|
|
1276
|
+
|-----|----|-----------|
|
|
1277
|
+
|`index`|`Number`|The byte index to update|
|
|
1278
|
+
|`value`|`Uint32`|The value to set|
|
|
1279
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
1280
|
+
|
|
1281
|
+
Throws:
|
|
1282
|
+
|
|
1283
|
+
`IndexOutOfBounds`
|
|
1284
|
+
|
|
1285
|
+
* When `index` is negative
|
|
1286
|
+
* When `index` is greater than or equal to the buffer size
|
|
1287
|
+
* When `index + 4` is greater than the buffer size
|
|
1288
|
+
|
|
1289
|
+
Examples:
|
|
1290
|
+
|
|
1291
|
+
```grain
|
|
1292
|
+
let buf = Buffer.make(32)
|
|
1293
|
+
Buffer.addString("Hello World", buf)
|
|
1294
|
+
Buffer.setUint32(0, 1ul, buf)
|
|
1295
|
+
assert Buffer.getUint32(0, buf) == 1ul
|
|
1296
|
+
```
|
|
1297
|
+
|
|
1298
|
+
### Buffer.**addUint32**
|
|
1299
|
+
|
|
1300
|
+
<details disabled>
|
|
1301
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
1302
|
+
No other changes yet.
|
|
1303
|
+
</details>
|
|
1304
|
+
|
|
1305
|
+
```grain
|
|
1306
|
+
addUint32 : (value: Uint32, buffer: Buffer) => Void
|
|
1307
|
+
```
|
|
1308
|
+
|
|
1309
|
+
Appends an unsigned 32-bit integer to a buffer.
|
|
1310
|
+
|
|
1311
|
+
Parameters:
|
|
1312
|
+
|
|
1313
|
+
|param|type|description|
|
|
1314
|
+
|-----|----|-----------|
|
|
1315
|
+
|`value`|`Uint32`|The value to append|
|
|
1316
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
1317
|
+
|
|
1318
|
+
Examples:
|
|
1319
|
+
|
|
1320
|
+
```grain
|
|
1321
|
+
let buf = Buffer.make(32)
|
|
1322
|
+
Buffer.addUint32(1ul, buf)
|
|
1323
|
+
assert Buffer.getUint32(0, buf) == 1ul
|
|
1324
|
+
```
|
|
1325
|
+
|
|
751
1326
|
### Buffer.**getFloat32**
|
|
752
1327
|
|
|
753
1328
|
<details disabled>
|
|
@@ -756,7 +1331,7 @@ No other changes yet.
|
|
|
756
1331
|
</details>
|
|
757
1332
|
|
|
758
1333
|
```grain
|
|
759
|
-
getFloat32 : (Number, Buffer)
|
|
1334
|
+
getFloat32 : (index: Number, buffer: Buffer) => Float32
|
|
760
1335
|
```
|
|
761
1336
|
|
|
762
1337
|
Gets a 32-bit float starting at the given byte index.
|
|
@@ -782,6 +1357,14 @@ Throws:
|
|
|
782
1357
|
* When `index` is greater than or equal to the buffer size
|
|
783
1358
|
* When `index + 4` is greater than the buffer size
|
|
784
1359
|
|
|
1360
|
+
Examples:
|
|
1361
|
+
|
|
1362
|
+
```grain
|
|
1363
|
+
let buf = Buffer.make(32)
|
|
1364
|
+
Buffer.addFloat32(1.0f, buf)
|
|
1365
|
+
assert Buffer.getFloat32(0, buf) == 1.0f
|
|
1366
|
+
```
|
|
1367
|
+
|
|
785
1368
|
### Buffer.**setFloat32**
|
|
786
1369
|
|
|
787
1370
|
<details disabled>
|
|
@@ -790,7 +1373,7 @@ No other changes yet.
|
|
|
790
1373
|
</details>
|
|
791
1374
|
|
|
792
1375
|
```grain
|
|
793
|
-
setFloat32 : (Number, Float32, Buffer)
|
|
1376
|
+
setFloat32 : (index: Number, value: Float32, buffer: Buffer) => Void
|
|
794
1377
|
```
|
|
795
1378
|
|
|
796
1379
|
Sets a 32-bit float starting at the given byte index.
|
|
@@ -811,6 +1394,15 @@ Throws:
|
|
|
811
1394
|
* When `index` is greater than or equal to the buffer size
|
|
812
1395
|
* When `index + 4` is greater than the buffer size
|
|
813
1396
|
|
|
1397
|
+
Examples:
|
|
1398
|
+
|
|
1399
|
+
```grain
|
|
1400
|
+
let buf = Buffer.make(32)
|
|
1401
|
+
Buffer.addString("Hello World", buf)
|
|
1402
|
+
Buffer.setFloat32(0, 1.0f, buf)
|
|
1403
|
+
assert Buffer.getFloat32(0, buf) == 1.0f
|
|
1404
|
+
```
|
|
1405
|
+
|
|
814
1406
|
### Buffer.**addFloat32**
|
|
815
1407
|
|
|
816
1408
|
<details disabled>
|
|
@@ -819,7 +1411,7 @@ No other changes yet.
|
|
|
819
1411
|
</details>
|
|
820
1412
|
|
|
821
1413
|
```grain
|
|
822
|
-
addFloat32 : (Float32, Buffer)
|
|
1414
|
+
addFloat32 : (value: Float32, buffer: Buffer) => Void
|
|
823
1415
|
```
|
|
824
1416
|
|
|
825
1417
|
Appends a 32-bit float to a buffer.
|
|
@@ -831,6 +1423,14 @@ Parameters:
|
|
|
831
1423
|
|`value`|`Float32`|The value to append|
|
|
832
1424
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
833
1425
|
|
|
1426
|
+
Examples:
|
|
1427
|
+
|
|
1428
|
+
```grain
|
|
1429
|
+
let buf = Buffer.make(32)
|
|
1430
|
+
Buffer.addFloat32(1.0f, buf)
|
|
1431
|
+
assert Buffer.getFloat32(0, buf) == 1.0f
|
|
1432
|
+
```
|
|
1433
|
+
|
|
834
1434
|
### Buffer.**getInt64**
|
|
835
1435
|
|
|
836
1436
|
<details disabled>
|
|
@@ -839,7 +1439,7 @@ No other changes yet.
|
|
|
839
1439
|
</details>
|
|
840
1440
|
|
|
841
1441
|
```grain
|
|
842
|
-
getInt64 : (Number, Buffer)
|
|
1442
|
+
getInt64 : (index: Number, buffer: Buffer) => Int64
|
|
843
1443
|
```
|
|
844
1444
|
|
|
845
1445
|
Gets a signed 64-bit integer starting at the given byte index.
|
|
@@ -865,6 +1465,14 @@ Throws:
|
|
|
865
1465
|
* When `index` is greater than or equal to the buffer size
|
|
866
1466
|
* When `index + 8` is greater than the buffer size
|
|
867
1467
|
|
|
1468
|
+
Examples:
|
|
1469
|
+
|
|
1470
|
+
```grain
|
|
1471
|
+
let buf = Buffer.make(32)
|
|
1472
|
+
Buffer.addInt64(1L, buf)
|
|
1473
|
+
assert Buffer.getInt64(0, buf) == 1L
|
|
1474
|
+
```
|
|
1475
|
+
|
|
868
1476
|
### Buffer.**setInt64**
|
|
869
1477
|
|
|
870
1478
|
<details disabled>
|
|
@@ -873,7 +1481,7 @@ No other changes yet.
|
|
|
873
1481
|
</details>
|
|
874
1482
|
|
|
875
1483
|
```grain
|
|
876
|
-
setInt64 : (Number, Int64, Buffer)
|
|
1484
|
+
setInt64 : (index: Number, value: Int64, buffer: Buffer) => Void
|
|
877
1485
|
```
|
|
878
1486
|
|
|
879
1487
|
Sets a signed 64-bit integer starting at the given byte index.
|
|
@@ -894,6 +1502,15 @@ Throws:
|
|
|
894
1502
|
* When `index` is greater than or equal to the buffer size
|
|
895
1503
|
* When `index + 8` is greater than the buffer size
|
|
896
1504
|
|
|
1505
|
+
Examples:
|
|
1506
|
+
|
|
1507
|
+
```grain
|
|
1508
|
+
let buf = Buffer.make(32)
|
|
1509
|
+
Buffer.addString("Hello World", buf)
|
|
1510
|
+
Buffer.setInt64(0, 1L, buf)
|
|
1511
|
+
assert Buffer.getInt64(0, buf) == 1L
|
|
1512
|
+
```
|
|
1513
|
+
|
|
897
1514
|
### Buffer.**addInt64**
|
|
898
1515
|
|
|
899
1516
|
<details disabled>
|
|
@@ -902,7 +1519,7 @@ No other changes yet.
|
|
|
902
1519
|
</details>
|
|
903
1520
|
|
|
904
1521
|
```grain
|
|
905
|
-
addInt64 : (Int64, Buffer)
|
|
1522
|
+
addInt64 : (value: Int64, buffer: Buffer) => Void
|
|
906
1523
|
```
|
|
907
1524
|
|
|
908
1525
|
Appends a signed 64-bit integer to a buffer.
|
|
@@ -914,6 +1531,122 @@ Parameters:
|
|
|
914
1531
|
|`value`|`Int64`|The value to set|
|
|
915
1532
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
916
1533
|
|
|
1534
|
+
Examples:
|
|
1535
|
+
|
|
1536
|
+
```grain
|
|
1537
|
+
let buf = Buffer.make(32)
|
|
1538
|
+
Buffer.addInt64(1L, buf)
|
|
1539
|
+
assert Buffer.getInt64(0, buf) == 1L
|
|
1540
|
+
```
|
|
1541
|
+
|
|
1542
|
+
### Buffer.**getUint64**
|
|
1543
|
+
|
|
1544
|
+
<details disabled>
|
|
1545
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
1546
|
+
No other changes yet.
|
|
1547
|
+
</details>
|
|
1548
|
+
|
|
1549
|
+
```grain
|
|
1550
|
+
getUint64 : (index: Number, buffer: Buffer) => Uint64
|
|
1551
|
+
```
|
|
1552
|
+
|
|
1553
|
+
Gets an unsigned 64-bit integer starting at the given byte index.
|
|
1554
|
+
|
|
1555
|
+
Parameters:
|
|
1556
|
+
|
|
1557
|
+
|param|type|description|
|
|
1558
|
+
|-----|----|-----------|
|
|
1559
|
+
|`index`|`Number`|The byte index to access|
|
|
1560
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
1561
|
+
|
|
1562
|
+
Returns:
|
|
1563
|
+
|
|
1564
|
+
|type|description|
|
|
1565
|
+
|----|-----------|
|
|
1566
|
+
|`Uint64`|An unsigned 64-bit integer that starts at the given index|
|
|
1567
|
+
|
|
1568
|
+
Throws:
|
|
1569
|
+
|
|
1570
|
+
`IndexOutOfBounds`
|
|
1571
|
+
|
|
1572
|
+
* When `index` is negative
|
|
1573
|
+
* When `index` is greater than or equal to the buffer size
|
|
1574
|
+
* When `index + 8` is greater than the buffer size
|
|
1575
|
+
|
|
1576
|
+
Examples:
|
|
1577
|
+
|
|
1578
|
+
```grain
|
|
1579
|
+
let buf = Buffer.make(32)
|
|
1580
|
+
Buffer.addUint64(1uL, buf)
|
|
1581
|
+
assert Buffer.getUint64(0, buf) == 1uL
|
|
1582
|
+
```
|
|
1583
|
+
|
|
1584
|
+
### Buffer.**setUint64**
|
|
1585
|
+
|
|
1586
|
+
<details disabled>
|
|
1587
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
1588
|
+
No other changes yet.
|
|
1589
|
+
</details>
|
|
1590
|
+
|
|
1591
|
+
```grain
|
|
1592
|
+
setUint64 : (index: Number, value: Uint64, buffer: Buffer) => Void
|
|
1593
|
+
```
|
|
1594
|
+
|
|
1595
|
+
Sets an unsigned 64-bit integer starting at the given byte index.
|
|
1596
|
+
|
|
1597
|
+
Parameters:
|
|
1598
|
+
|
|
1599
|
+
|param|type|description|
|
|
1600
|
+
|-----|----|-----------|
|
|
1601
|
+
|`index`|`Number`|The byte index to update|
|
|
1602
|
+
|`value`|`Uint64`|The value to set|
|
|
1603
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
1604
|
+
|
|
1605
|
+
Throws:
|
|
1606
|
+
|
|
1607
|
+
`IndexOutOfBounds`
|
|
1608
|
+
|
|
1609
|
+
* When `index` is negative
|
|
1610
|
+
* When `index` is greater than or equal to the buffer size
|
|
1611
|
+
* When `index + 8` is greater than the buffer size
|
|
1612
|
+
|
|
1613
|
+
Examples:
|
|
1614
|
+
|
|
1615
|
+
```grain
|
|
1616
|
+
let buf = Buffer.make(32)
|
|
1617
|
+
Buffer.addString("Hello World", buf)
|
|
1618
|
+
Buffer.setUint64(0, 1uL, buf)
|
|
1619
|
+
assert Buffer.getUint64(0, buf) == 1uL
|
|
1620
|
+
```
|
|
1621
|
+
|
|
1622
|
+
### Buffer.**addUint64**
|
|
1623
|
+
|
|
1624
|
+
<details disabled>
|
|
1625
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
1626
|
+
No other changes yet.
|
|
1627
|
+
</details>
|
|
1628
|
+
|
|
1629
|
+
```grain
|
|
1630
|
+
addUint64 : (value: Uint64, buffer: Buffer) => Void
|
|
1631
|
+
```
|
|
1632
|
+
|
|
1633
|
+
Appends an unsigned 64-bit integer to a buffer.
|
|
1634
|
+
|
|
1635
|
+
Parameters:
|
|
1636
|
+
|
|
1637
|
+
|param|type|description|
|
|
1638
|
+
|-----|----|-----------|
|
|
1639
|
+
|`value`|`Uint64`|The value to set|
|
|
1640
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
1641
|
+
|
|
1642
|
+
Examples:
|
|
1643
|
+
|
|
1644
|
+
```grain
|
|
1645
|
+
let buf = Buffer.make(32)
|
|
1646
|
+
Buffer.addUint64(1uL, buf)
|
|
1647
|
+
assert Buffer.getUint64(0, buf) == 1uL
|
|
1648
|
+
```
|
|
1649
|
+
|
|
917
1650
|
### Buffer.**getFloat64**
|
|
918
1651
|
|
|
919
1652
|
<details disabled>
|
|
@@ -922,7 +1655,7 @@ No other changes yet.
|
|
|
922
1655
|
</details>
|
|
923
1656
|
|
|
924
1657
|
```grain
|
|
925
|
-
getFloat64 : (Number, Buffer)
|
|
1658
|
+
getFloat64 : (index: Number, buffer: Buffer) => Float64
|
|
926
1659
|
```
|
|
927
1660
|
|
|
928
1661
|
Gets a 64-bit float starting at the given byte index.
|
|
@@ -948,6 +1681,14 @@ Throws:
|
|
|
948
1681
|
* When `index` is greater than or equal to the buffer size
|
|
949
1682
|
* When `index + 8` is greater than the buffer size
|
|
950
1683
|
|
|
1684
|
+
Examples:
|
|
1685
|
+
|
|
1686
|
+
```grain
|
|
1687
|
+
let buf = Buffer.make(32)
|
|
1688
|
+
Buffer.addFloat64(1.0F, buf)
|
|
1689
|
+
assert Buffer.getFloat64(0, buf) == 1.0F
|
|
1690
|
+
```
|
|
1691
|
+
|
|
951
1692
|
### Buffer.**setFloat64**
|
|
952
1693
|
|
|
953
1694
|
<details disabled>
|
|
@@ -956,7 +1697,7 @@ No other changes yet.
|
|
|
956
1697
|
</details>
|
|
957
1698
|
|
|
958
1699
|
```grain
|
|
959
|
-
setFloat64 : (Number, Float64, Buffer)
|
|
1700
|
+
setFloat64 : (index: Number, value: Float64, buffer: Buffer) => Void
|
|
960
1701
|
```
|
|
961
1702
|
|
|
962
1703
|
Sets a 64-bit float starting at the given byte index.
|
|
@@ -977,6 +1718,15 @@ Throws:
|
|
|
977
1718
|
* When `index` is greater than or equal to the buffer size
|
|
978
1719
|
* When `index + 8` is greater than the buffer size
|
|
979
1720
|
|
|
1721
|
+
Examples:
|
|
1722
|
+
|
|
1723
|
+
```grain
|
|
1724
|
+
let buf = Buffer.make(32)
|
|
1725
|
+
Buffer.addString("Hello World", buf)
|
|
1726
|
+
Buffer.setFloat64(0, 1.0F, buf)
|
|
1727
|
+
assert Buffer.getFloat64(0, buf) == 1.0F
|
|
1728
|
+
```
|
|
1729
|
+
|
|
980
1730
|
### Buffer.**addFloat64**
|
|
981
1731
|
|
|
982
1732
|
<details disabled>
|
|
@@ -985,7 +1735,7 @@ No other changes yet.
|
|
|
985
1735
|
</details>
|
|
986
1736
|
|
|
987
1737
|
```grain
|
|
988
|
-
addFloat64 : (Float64, Buffer)
|
|
1738
|
+
addFloat64 : (value: Float64, buffer: Buffer) => Void
|
|
989
1739
|
```
|
|
990
1740
|
|
|
991
1741
|
Appends a 64-bit float to a buffer.
|
|
@@ -997,3 +1747,11 @@ Parameters:
|
|
|
997
1747
|
|`value`|`Float64`|The value to append|
|
|
998
1748
|
|`buffer`|`Buffer`|The buffer to mutate|
|
|
999
1749
|
|
|
1750
|
+
Examples:
|
|
1751
|
+
|
|
1752
|
+
```grain
|
|
1753
|
+
let buf = Buffer.make(32)
|
|
1754
|
+
Buffer.addFloat64(1.0F, buf)
|
|
1755
|
+
assert Buffer.getFloat64(0, buf) == 1.0F
|
|
1756
|
+
```
|
|
1757
|
+
|