@grain/stdlib 0.4.0 → 0.4.4
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 +65 -0
- package/LICENSE +21 -0
- package/README.md +34 -0
- package/array.gr +136 -44
- package/array.md +97 -21
- package/buffer.gr +495 -424
- package/buffer.md +850 -0
- package/bytes.gr +512 -407
- package/bytes.md +621 -0
- package/char.gr +11 -3
- package/hash.gr +26 -3
- package/hash.md +44 -0
- package/list.gr +54 -0
- package/number.gr +24 -6
- package/number.md +49 -17
- package/option.gr +244 -37
- package/option.md +579 -0
- package/package.json +33 -29
- package/queue.gr +98 -29
- package/queue.md +191 -0
- package/range.md +1 -1
- package/regex.gr +3055 -0
- package/regex.md +449 -0
- package/result.gr +216 -70
- package/result.md +446 -0
- package/runtime/gc.gr +2 -2
- package/runtime/string.gr +56 -24
- package/runtime/stringUtils.gr +172 -0
- package/runtime/unsafe/conv.gr +43 -0
- package/set.gr +172 -5
- package/set.md +502 -0
- package/stack.md +143 -0
- package/string.gr +444 -230
- package/string.md +815 -0
- package/sys/file.gr +3 -2
- package/sys/file.md +2 -2
package/buffer.md
ADDED
|
@@ -0,0 +1,850 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Buffer
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Utilities for working with buffers.
|
|
6
|
+
|
|
7
|
+
Buffers are data structures that automatically expand as more data is appended. They are useful for storing and operating on an unknown number of bytes. All set or append operations mutate the buffer.
|
|
8
|
+
|
|
9
|
+
<details disabled>
|
|
10
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
11
|
+
No other changes yet.
|
|
12
|
+
</details>
|
|
13
|
+
|
|
14
|
+
```grain
|
|
15
|
+
import Buffer from "buffer"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Values
|
|
19
|
+
|
|
20
|
+
Functions for working with the Buffer data type.
|
|
21
|
+
|
|
22
|
+
### Buffer.**make**
|
|
23
|
+
|
|
24
|
+
<details disabled>
|
|
25
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
26
|
+
No other changes yet.
|
|
27
|
+
</details>
|
|
28
|
+
|
|
29
|
+
```grain
|
|
30
|
+
make : Number -> Buffer
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Creates a fresh buffer, initially empty.
|
|
34
|
+
|
|
35
|
+
The `initialSize` parameter is the initial size of the internal byte sequence that holds the buffer contents.
|
|
36
|
+
That byte sequence is automatically reallocated when more than `initialSize` bytes are stored in the buffer, but shrinks back to `initialSize` characters when reset is called.
|
|
37
|
+
|
|
38
|
+
Parameters:
|
|
39
|
+
|
|
40
|
+
|param|type|description|
|
|
41
|
+
|-----|----|-----------|
|
|
42
|
+
|`initialSize`|`Number`|The initial size of the buffer|
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
|
|
46
|
+
|type|description|
|
|
47
|
+
|----|-----------|
|
|
48
|
+
|`Buffer`|The new buffer|
|
|
49
|
+
|
|
50
|
+
### Buffer.**length**
|
|
51
|
+
|
|
52
|
+
<details disabled>
|
|
53
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
54
|
+
No other changes yet.
|
|
55
|
+
</details>
|
|
56
|
+
|
|
57
|
+
```grain
|
|
58
|
+
length : Buffer -> Number
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Gets the number of bytes currently contained in a buffer.
|
|
62
|
+
|
|
63
|
+
Parameters:
|
|
64
|
+
|
|
65
|
+
|param|type|description|
|
|
66
|
+
|-----|----|-----------|
|
|
67
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
|
|
71
|
+
|type|description|
|
|
72
|
+
|----|-----------|
|
|
73
|
+
|`Number`|The length of the buffer in bytes|
|
|
74
|
+
|
|
75
|
+
### Buffer.**clear**
|
|
76
|
+
|
|
77
|
+
<details disabled>
|
|
78
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
79
|
+
No other changes yet.
|
|
80
|
+
</details>
|
|
81
|
+
|
|
82
|
+
```grain
|
|
83
|
+
clear : Buffer -> Void
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Clears data in the buffer and sets its length to zero.
|
|
87
|
+
|
|
88
|
+
This operation does not resize the underlying byte sequence.
|
|
89
|
+
|
|
90
|
+
Parameters:
|
|
91
|
+
|
|
92
|
+
|param|type|description|
|
|
93
|
+
|-----|----|-----------|
|
|
94
|
+
|`buffer`|`Buffer`|The buffer to clear|
|
|
95
|
+
|
|
96
|
+
### Buffer.**reset**
|
|
97
|
+
|
|
98
|
+
<details disabled>
|
|
99
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
100
|
+
No other changes yet.
|
|
101
|
+
</details>
|
|
102
|
+
|
|
103
|
+
```grain
|
|
104
|
+
reset : Buffer -> Void
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Empty a buffer and deallocate the internal byte sequence holding the buffer contents.
|
|
108
|
+
|
|
109
|
+
This operation resizes the underlying byte sequence to the initial size of the buffer.
|
|
110
|
+
|
|
111
|
+
Parameters:
|
|
112
|
+
|
|
113
|
+
|param|type|description|
|
|
114
|
+
|-----|----|-----------|
|
|
115
|
+
|`buffer`|`Buffer`|The buffer to reset|
|
|
116
|
+
|
|
117
|
+
### Buffer.**truncate**
|
|
118
|
+
|
|
119
|
+
<details disabled>
|
|
120
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
121
|
+
No other changes yet.
|
|
122
|
+
</details>
|
|
123
|
+
|
|
124
|
+
```grain
|
|
125
|
+
truncate : (Number, Buffer) -> Void
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Shortens a buffer to the given length.
|
|
129
|
+
|
|
130
|
+
This operation does not resize the underlying byte sequence.
|
|
131
|
+
|
|
132
|
+
Parameters:
|
|
133
|
+
|
|
134
|
+
|param|type|description|
|
|
135
|
+
|-----|----|-----------|
|
|
136
|
+
|`length`|`Number`|The number of bytes to truncate the buffer to|
|
|
137
|
+
|`buffer`|`Buffer`|The buffer to truncate|
|
|
138
|
+
|
|
139
|
+
### Buffer.**toBytes**
|
|
140
|
+
|
|
141
|
+
<details disabled>
|
|
142
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
143
|
+
No other changes yet.
|
|
144
|
+
</details>
|
|
145
|
+
|
|
146
|
+
```grain
|
|
147
|
+
toBytes : Buffer -> Bytes
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Returns a copy of the current contents of the buffer as a byte sequence.
|
|
151
|
+
|
|
152
|
+
Parameters:
|
|
153
|
+
|
|
154
|
+
|param|type|description|
|
|
155
|
+
|-----|----|-----------|
|
|
156
|
+
|`buffer`|`Buffer`|The buffer to copy into a byte sequence|
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
|
|
160
|
+
|type|description|
|
|
161
|
+
|----|-----------|
|
|
162
|
+
|`Bytes`|A byte sequence made from copied buffer data|
|
|
163
|
+
|
|
164
|
+
### Buffer.**toBytesSlice**
|
|
165
|
+
|
|
166
|
+
<details disabled>
|
|
167
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
168
|
+
No other changes yet.
|
|
169
|
+
</details>
|
|
170
|
+
|
|
171
|
+
```grain
|
|
172
|
+
toBytesSlice : (Number, Number, Buffer) -> Bytes
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Returns a slice of the current contents of the buffer as a byte sequence.
|
|
176
|
+
|
|
177
|
+
Parameters:
|
|
178
|
+
|
|
179
|
+
|param|type|description|
|
|
180
|
+
|-----|----|-----------|
|
|
181
|
+
|`start`|`Number`|The start index|
|
|
182
|
+
|`length`|`Number`|The number of bytes to include after the starting index|
|
|
183
|
+
|`buffer`|`Buffer`|The buffer to copy from|
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
|
|
187
|
+
|type|description|
|
|
188
|
+
|----|-----------|
|
|
189
|
+
|`Bytes`|A byte sequence with bytes copied from the buffer|
|
|
190
|
+
|
|
191
|
+
### Buffer.**toString**
|
|
192
|
+
|
|
193
|
+
<details disabled>
|
|
194
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
195
|
+
No other changes yet.
|
|
196
|
+
</details>
|
|
197
|
+
|
|
198
|
+
```grain
|
|
199
|
+
toString : Buffer -> String
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Returns a copy of the current contents of the buffer as a string.
|
|
203
|
+
|
|
204
|
+
Parameters:
|
|
205
|
+
|
|
206
|
+
|param|type|description|
|
|
207
|
+
|-----|----|-----------|
|
|
208
|
+
|`buffer`|`Buffer`|The buffer to stringify|
|
|
209
|
+
|
|
210
|
+
Returns:
|
|
211
|
+
|
|
212
|
+
|type|description|
|
|
213
|
+
|----|-----------|
|
|
214
|
+
|`String`|A string made with data copied from the buffer|
|
|
215
|
+
|
|
216
|
+
### Buffer.**toStringSlice**
|
|
217
|
+
|
|
218
|
+
<details disabled>
|
|
219
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
220
|
+
No other changes yet.
|
|
221
|
+
</details>
|
|
222
|
+
|
|
223
|
+
```grain
|
|
224
|
+
toStringSlice : (Number, Number, Buffer) -> String
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Returns a copy of a subset of the current contents of the buffer as a string.
|
|
228
|
+
|
|
229
|
+
Parameters:
|
|
230
|
+
|
|
231
|
+
|param|type|description|
|
|
232
|
+
|-----|----|-----------|
|
|
233
|
+
|`start`|`Number`|The start index|
|
|
234
|
+
|`length`|`Number`|The number of bytes to include after the starting index|
|
|
235
|
+
|`buffer`|`Buffer`|The buffer to copy from|
|
|
236
|
+
|
|
237
|
+
Returns:
|
|
238
|
+
|
|
239
|
+
|type|description|
|
|
240
|
+
|----|-----------|
|
|
241
|
+
|`String`|A string made with a subset of data copied from the buffer|
|
|
242
|
+
|
|
243
|
+
### Buffer.**addChar**
|
|
244
|
+
|
|
245
|
+
<details disabled>
|
|
246
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
247
|
+
No other changes yet.
|
|
248
|
+
</details>
|
|
249
|
+
|
|
250
|
+
```grain
|
|
251
|
+
addChar : (Char, Buffer) -> Void
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Appends the bytes of a char to a buffer.
|
|
255
|
+
|
|
256
|
+
Parameters:
|
|
257
|
+
|
|
258
|
+
|param|type|description|
|
|
259
|
+
|-----|----|-----------|
|
|
260
|
+
|`char`|`Char`|The character to append to the buffer|
|
|
261
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
262
|
+
|
|
263
|
+
### Buffer.**addBytes**
|
|
264
|
+
|
|
265
|
+
<details disabled>
|
|
266
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
267
|
+
No other changes yet.
|
|
268
|
+
</details>
|
|
269
|
+
|
|
270
|
+
```grain
|
|
271
|
+
addBytes : (Bytes, Buffer) -> Void
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Appends a byte sequence to a buffer.
|
|
275
|
+
|
|
276
|
+
Parameters:
|
|
277
|
+
|
|
278
|
+
|param|type|description|
|
|
279
|
+
|-----|----|-----------|
|
|
280
|
+
|`bytes`|`Bytes`|The byte sequence to append|
|
|
281
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
282
|
+
|
|
283
|
+
### Buffer.**addString**
|
|
284
|
+
|
|
285
|
+
<details disabled>
|
|
286
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
287
|
+
No other changes yet.
|
|
288
|
+
</details>
|
|
289
|
+
|
|
290
|
+
```grain
|
|
291
|
+
addString : (String, Buffer) -> Void
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Appends the bytes of a string to a buffer.
|
|
295
|
+
|
|
296
|
+
Parameters:
|
|
297
|
+
|
|
298
|
+
|param|type|description|
|
|
299
|
+
|-----|----|-----------|
|
|
300
|
+
|`string`|`String`|The string to append|
|
|
301
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
302
|
+
|
|
303
|
+
### Buffer.**addStringSlice**
|
|
304
|
+
|
|
305
|
+
<details disabled>
|
|
306
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
307
|
+
No other changes yet.
|
|
308
|
+
</details>
|
|
309
|
+
|
|
310
|
+
```grain
|
|
311
|
+
addStringSlice : (Number, Number, String, Buffer) -> Void
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Appends the bytes of a subset of a string to a buffer.
|
|
315
|
+
|
|
316
|
+
Parameters:
|
|
317
|
+
|
|
318
|
+
|param|type|description|
|
|
319
|
+
|-----|----|-----------|
|
|
320
|
+
|`start`|`Number`|The char offset into the string|
|
|
321
|
+
|`length`|`Number`|The number of bytes to append|
|
|
322
|
+
|`string`|`String`|The string to append|
|
|
323
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
324
|
+
|
|
325
|
+
### Buffer.**addBytesSlice**
|
|
326
|
+
|
|
327
|
+
<details disabled>
|
|
328
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
329
|
+
No other changes yet.
|
|
330
|
+
</details>
|
|
331
|
+
|
|
332
|
+
```grain
|
|
333
|
+
addBytesSlice : (Number, Number, Bytes, Buffer) -> Void
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
Appends the bytes of a subset of a byte seuqnece to a buffer.
|
|
337
|
+
|
|
338
|
+
Parameters:
|
|
339
|
+
|
|
340
|
+
|param|type|description|
|
|
341
|
+
|-----|----|-----------|
|
|
342
|
+
|`start`|`Number`|The byte offset into the byte sequence|
|
|
343
|
+
|`length`|`Number`|The number of bytes to append|
|
|
344
|
+
|`bytes`|`Bytes`|The byte sequence to append|
|
|
345
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
346
|
+
|
|
347
|
+
### Buffer.**addBuffer**
|
|
348
|
+
|
|
349
|
+
<details disabled>
|
|
350
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
351
|
+
No other changes yet.
|
|
352
|
+
</details>
|
|
353
|
+
|
|
354
|
+
```grain
|
|
355
|
+
addBuffer : (Buffer, Buffer) -> Void
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Appends the bytes of a source buffer to destination buffer.
|
|
359
|
+
|
|
360
|
+
The source buffer is not mutated by this operation. The destination buffer, however, is mutated.
|
|
361
|
+
|
|
362
|
+
Parameters:
|
|
363
|
+
|
|
364
|
+
|param|type|description|
|
|
365
|
+
|-----|----|-----------|
|
|
366
|
+
|`srcBuffer`|`Buffer`|The buffer to append|
|
|
367
|
+
|`dstBuffer`|`Buffer`|The buffer to mutate|
|
|
368
|
+
|
|
369
|
+
### Buffer.**addBufferSlice**
|
|
370
|
+
|
|
371
|
+
<details disabled>
|
|
372
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
373
|
+
No other changes yet.
|
|
374
|
+
</details>
|
|
375
|
+
|
|
376
|
+
```grain
|
|
377
|
+
addBufferSlice : (Number, Number, Buffer, Buffer) -> Void
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
Appends the bytes of a part of a buffer to the end of the buffer
|
|
381
|
+
|
|
382
|
+
The source buffer is not mutated by this operation. The destination buffer, however, is mutated.
|
|
383
|
+
|
|
384
|
+
Parameters:
|
|
385
|
+
|
|
386
|
+
|param|type|description|
|
|
387
|
+
|-----|----|-----------|
|
|
388
|
+
|`start`|`Number`|The byte offset into the buffer|
|
|
389
|
+
|`length`|`Number`|The number of bytes to append|
|
|
390
|
+
|`srcBuffer`|`Buffer`|The buffer to append|
|
|
391
|
+
|`dstBuffer`|`Buffer`|The buffer to mutate|
|
|
392
|
+
|
|
393
|
+
## Binary operations on integers
|
|
394
|
+
|
|
395
|
+
Functions for encoding and decoding integers stored in a buffer.
|
|
396
|
+
|
|
397
|
+
### Buffer.**getInt8S**
|
|
398
|
+
|
|
399
|
+
<details disabled>
|
|
400
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
401
|
+
No other changes yet.
|
|
402
|
+
</details>
|
|
403
|
+
|
|
404
|
+
```grain
|
|
405
|
+
getInt8S : (Number, Buffer) -> Int32
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
Gets a signed 8-bit integer starting at the given byte index.
|
|
409
|
+
|
|
410
|
+
Parameters:
|
|
411
|
+
|
|
412
|
+
|param|type|description|
|
|
413
|
+
|-----|----|-----------|
|
|
414
|
+
|`index`|`Number`|The byte index to access|
|
|
415
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
416
|
+
|
|
417
|
+
Returns:
|
|
418
|
+
|
|
419
|
+
|type|description|
|
|
420
|
+
|----|-----------|
|
|
421
|
+
|`Int32`|A 32-bit integer representing a signed 8-bit integer that starts at the given index|
|
|
422
|
+
|
|
423
|
+
### Buffer.**getInt8U**
|
|
424
|
+
|
|
425
|
+
<details disabled>
|
|
426
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
427
|
+
No other changes yet.
|
|
428
|
+
</details>
|
|
429
|
+
|
|
430
|
+
```grain
|
|
431
|
+
getInt8U : (Number, Buffer) -> Int32
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Gets an unsigned 8-bit integer starting at the given byte index.
|
|
435
|
+
|
|
436
|
+
Parameters:
|
|
437
|
+
|
|
438
|
+
|param|type|description|
|
|
439
|
+
|-----|----|-----------|
|
|
440
|
+
|`index`|`Number`|The byte index to access|
|
|
441
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
442
|
+
|
|
443
|
+
Returns:
|
|
444
|
+
|
|
445
|
+
|type|description|
|
|
446
|
+
|----|-----------|
|
|
447
|
+
|`Int32`|A 32-bit integer representing an unsigned 8-bit integer that starts at the given index|
|
|
448
|
+
|
|
449
|
+
### Buffer.**setInt8**
|
|
450
|
+
|
|
451
|
+
<details disabled>
|
|
452
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
453
|
+
No other changes yet.
|
|
454
|
+
</details>
|
|
455
|
+
|
|
456
|
+
```grain
|
|
457
|
+
setInt8 : (Number, Int32, Buffer) -> Void
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Sets a signed 8-bit integer starting at the given byte index.
|
|
461
|
+
|
|
462
|
+
Parameters:
|
|
463
|
+
|
|
464
|
+
|param|type|description|
|
|
465
|
+
|-----|----|-----------|
|
|
466
|
+
|`index`|`Number`|The byte index to update|
|
|
467
|
+
|`value`|`Int32`|The value to set|
|
|
468
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
469
|
+
|
|
470
|
+
### Buffer.**addInt8**
|
|
471
|
+
|
|
472
|
+
<details disabled>
|
|
473
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
474
|
+
No other changes yet.
|
|
475
|
+
</details>
|
|
476
|
+
|
|
477
|
+
```grain
|
|
478
|
+
addInt8 : (Int32, Buffer) -> Void
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
Appends a signed 8-bit integer to a buffer.
|
|
482
|
+
|
|
483
|
+
Parameters:
|
|
484
|
+
|
|
485
|
+
|param|type|description|
|
|
486
|
+
|-----|----|-----------|
|
|
487
|
+
|`value`|`Int32`|The value to append|
|
|
488
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
489
|
+
|
|
490
|
+
### Buffer.**getInt16S**
|
|
491
|
+
|
|
492
|
+
<details disabled>
|
|
493
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
494
|
+
No other changes yet.
|
|
495
|
+
</details>
|
|
496
|
+
|
|
497
|
+
```grain
|
|
498
|
+
getInt16S : (Number, Buffer) -> Int32
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
Gets a signed 16-bit integer starting at the given byte index.
|
|
502
|
+
|
|
503
|
+
Parameters:
|
|
504
|
+
|
|
505
|
+
|param|type|description|
|
|
506
|
+
|-----|----|-----------|
|
|
507
|
+
|`index`|`Number`|The byte index to access|
|
|
508
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
509
|
+
|
|
510
|
+
Returns:
|
|
511
|
+
|
|
512
|
+
|type|description|
|
|
513
|
+
|----|-----------|
|
|
514
|
+
|`Int32`|A 32-bit integer representing a signed 16-bit integer that starts at the given index|
|
|
515
|
+
|
|
516
|
+
### Buffer.**getInt16U**
|
|
517
|
+
|
|
518
|
+
<details disabled>
|
|
519
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
520
|
+
No other changes yet.
|
|
521
|
+
</details>
|
|
522
|
+
|
|
523
|
+
```grain
|
|
524
|
+
getInt16U : (Number, Buffer) -> Int32
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
Gets an unsigned 16-bit integer starting at the given byte index.
|
|
528
|
+
|
|
529
|
+
Parameters:
|
|
530
|
+
|
|
531
|
+
|param|type|description|
|
|
532
|
+
|-----|----|-----------|
|
|
533
|
+
|`index`|`Number`|The byte index to access|
|
|
534
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
535
|
+
|
|
536
|
+
Returns:
|
|
537
|
+
|
|
538
|
+
|type|description|
|
|
539
|
+
|----|-----------|
|
|
540
|
+
|`Int32`|A 32-bit integer representing an unsigned 16-bit integer that starts at the given index|
|
|
541
|
+
|
|
542
|
+
### Buffer.**setInt16**
|
|
543
|
+
|
|
544
|
+
<details disabled>
|
|
545
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
546
|
+
No other changes yet.
|
|
547
|
+
</details>
|
|
548
|
+
|
|
549
|
+
```grain
|
|
550
|
+
setInt16 : (Number, Int32, Buffer) -> Void
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
Sets a signed 16-bit integer starting at the given byte index.
|
|
554
|
+
|
|
555
|
+
Parameters:
|
|
556
|
+
|
|
557
|
+
|param|type|description|
|
|
558
|
+
|-----|----|-----------|
|
|
559
|
+
|`index`|`Number`|The byte index to update|
|
|
560
|
+
|`value`|`Int32`|The value to set|
|
|
561
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
562
|
+
|
|
563
|
+
### Buffer.**addInt16**
|
|
564
|
+
|
|
565
|
+
<details disabled>
|
|
566
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
567
|
+
No other changes yet.
|
|
568
|
+
</details>
|
|
569
|
+
|
|
570
|
+
```grain
|
|
571
|
+
addInt16 : (Int32, Buffer) -> Void
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
Appends a signed 16-bit integer to a buffer.
|
|
575
|
+
|
|
576
|
+
Parameters:
|
|
577
|
+
|
|
578
|
+
|param|type|description|
|
|
579
|
+
|-----|----|-----------|
|
|
580
|
+
|`value`|`Int32`|The value to append|
|
|
581
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
582
|
+
|
|
583
|
+
### Buffer.**getInt32**
|
|
584
|
+
|
|
585
|
+
<details disabled>
|
|
586
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
587
|
+
No other changes yet.
|
|
588
|
+
</details>
|
|
589
|
+
|
|
590
|
+
```grain
|
|
591
|
+
getInt32 : (Number, Buffer) -> Int32
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
Gets a signed 32-bit integer starting at the given byte index.
|
|
595
|
+
|
|
596
|
+
Parameters:
|
|
597
|
+
|
|
598
|
+
|param|type|description|
|
|
599
|
+
|-----|----|-----------|
|
|
600
|
+
|`index`|`Number`|The byte index to access|
|
|
601
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
602
|
+
|
|
603
|
+
Returns:
|
|
604
|
+
|
|
605
|
+
|type|description|
|
|
606
|
+
|----|-----------|
|
|
607
|
+
|`Int32`|A signed 32-bit integer that starts at the given index|
|
|
608
|
+
|
|
609
|
+
### Buffer.**setInt32**
|
|
610
|
+
|
|
611
|
+
<details disabled>
|
|
612
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
613
|
+
No other changes yet.
|
|
614
|
+
</details>
|
|
615
|
+
|
|
616
|
+
```grain
|
|
617
|
+
setInt32 : (Number, Int32, Buffer) -> Void
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
Sets a signed 32-bit integer starting at the given byte index.
|
|
621
|
+
|
|
622
|
+
Parameters:
|
|
623
|
+
|
|
624
|
+
|param|type|description|
|
|
625
|
+
|-----|----|-----------|
|
|
626
|
+
|`index`|`Number`|The byte index to update|
|
|
627
|
+
|`value`|`Int32`|The value to set|
|
|
628
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
629
|
+
|
|
630
|
+
### Buffer.**addInt32**
|
|
631
|
+
|
|
632
|
+
<details disabled>
|
|
633
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
634
|
+
No other changes yet.
|
|
635
|
+
</details>
|
|
636
|
+
|
|
637
|
+
```grain
|
|
638
|
+
addInt32 : (Int32, Buffer) -> Void
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
Appends a signed 32-bit integer to a buffer.
|
|
642
|
+
|
|
643
|
+
Parameters:
|
|
644
|
+
|
|
645
|
+
|param|type|description|
|
|
646
|
+
|-----|----|-----------|
|
|
647
|
+
|`value`|`Int32`|The value to append|
|
|
648
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
649
|
+
|
|
650
|
+
### Buffer.**getFloat32**
|
|
651
|
+
|
|
652
|
+
<details disabled>
|
|
653
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
654
|
+
No other changes yet.
|
|
655
|
+
</details>
|
|
656
|
+
|
|
657
|
+
```grain
|
|
658
|
+
getFloat32 : (Number, Buffer) -> Float32
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
Gets a 32-bit float starting at the given byte index.
|
|
662
|
+
|
|
663
|
+
Parameters:
|
|
664
|
+
|
|
665
|
+
|param|type|description|
|
|
666
|
+
|-----|----|-----------|
|
|
667
|
+
|`index`|`Number`|The byte index to access|
|
|
668
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
669
|
+
|
|
670
|
+
Returns:
|
|
671
|
+
|
|
672
|
+
|type|description|
|
|
673
|
+
|----|-----------|
|
|
674
|
+
|`Float32`|A 32-bit float that starts at the given index|
|
|
675
|
+
|
|
676
|
+
### Buffer.**setFloat32**
|
|
677
|
+
|
|
678
|
+
<details disabled>
|
|
679
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
680
|
+
No other changes yet.
|
|
681
|
+
</details>
|
|
682
|
+
|
|
683
|
+
```grain
|
|
684
|
+
setFloat32 : (Number, Float32, Buffer) -> Void
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
Sets a 32-bit float starting at the given byte index.
|
|
688
|
+
|
|
689
|
+
Parameters:
|
|
690
|
+
|
|
691
|
+
|param|type|description|
|
|
692
|
+
|-----|----|-----------|
|
|
693
|
+
|`index`|`Number`|The byte index to update|
|
|
694
|
+
|`value`|`Float32`|The value to set|
|
|
695
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
696
|
+
|
|
697
|
+
### Buffer.**addFloat32**
|
|
698
|
+
|
|
699
|
+
<details disabled>
|
|
700
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
701
|
+
No other changes yet.
|
|
702
|
+
</details>
|
|
703
|
+
|
|
704
|
+
```grain
|
|
705
|
+
addFloat32 : (Float32, Buffer) -> Void
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
Appends a 32-bit float to a buffer.
|
|
709
|
+
|
|
710
|
+
Parameters:
|
|
711
|
+
|
|
712
|
+
|param|type|description|
|
|
713
|
+
|-----|----|-----------|
|
|
714
|
+
|`value`|`Float32`|The value to append|
|
|
715
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
716
|
+
|
|
717
|
+
### Buffer.**getInt64**
|
|
718
|
+
|
|
719
|
+
<details disabled>
|
|
720
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
721
|
+
No other changes yet.
|
|
722
|
+
</details>
|
|
723
|
+
|
|
724
|
+
```grain
|
|
725
|
+
getInt64 : (Number, Buffer) -> Int64
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
Gets a signed 64-bit integer starting at the given byte index.
|
|
729
|
+
|
|
730
|
+
Parameters:
|
|
731
|
+
|
|
732
|
+
|param|type|description|
|
|
733
|
+
|-----|----|-----------|
|
|
734
|
+
|`index`|`Number`|The byte index to access|
|
|
735
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
736
|
+
|
|
737
|
+
Returns:
|
|
738
|
+
|
|
739
|
+
|type|description|
|
|
740
|
+
|----|-----------|
|
|
741
|
+
|`Int64`|A signed 64-bit integer that starts at the given index|
|
|
742
|
+
|
|
743
|
+
### Buffer.**setInt64**
|
|
744
|
+
|
|
745
|
+
<details disabled>
|
|
746
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
747
|
+
No other changes yet.
|
|
748
|
+
</details>
|
|
749
|
+
|
|
750
|
+
```grain
|
|
751
|
+
setInt64 : (Number, Int64, Buffer) -> Void
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
Sets a signed 64-bit integer starting at the given byte index.
|
|
755
|
+
|
|
756
|
+
Parameters:
|
|
757
|
+
|
|
758
|
+
|param|type|description|
|
|
759
|
+
|-----|----|-----------|
|
|
760
|
+
|`index`|`Number`|The byte index to update|
|
|
761
|
+
|`value`|`Int64`|The value to set|
|
|
762
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
763
|
+
|
|
764
|
+
### Buffer.**addInt64**
|
|
765
|
+
|
|
766
|
+
<details disabled>
|
|
767
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
768
|
+
No other changes yet.
|
|
769
|
+
</details>
|
|
770
|
+
|
|
771
|
+
```grain
|
|
772
|
+
addInt64 : (Int64, Buffer) -> Void
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
Appends a signed 64-bit integer to a buffer.
|
|
776
|
+
|
|
777
|
+
Parameters:
|
|
778
|
+
|
|
779
|
+
|param|type|description|
|
|
780
|
+
|-----|----|-----------|
|
|
781
|
+
|`value`|`Int64`|The value to set|
|
|
782
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
783
|
+
|
|
784
|
+
### Buffer.**getFloat64**
|
|
785
|
+
|
|
786
|
+
<details disabled>
|
|
787
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
788
|
+
No other changes yet.
|
|
789
|
+
</details>
|
|
790
|
+
|
|
791
|
+
```grain
|
|
792
|
+
getFloat64 : (Number, Buffer) -> Float64
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
Gets a 64-bit float starting at the given byte index.
|
|
796
|
+
|
|
797
|
+
Parameters:
|
|
798
|
+
|
|
799
|
+
|param|type|description|
|
|
800
|
+
|-----|----|-----------|
|
|
801
|
+
|`index`|`Number`|The byte index to access|
|
|
802
|
+
|`buffer`|`Buffer`|The buffer to access|
|
|
803
|
+
|
|
804
|
+
Returns:
|
|
805
|
+
|
|
806
|
+
|type|description|
|
|
807
|
+
|----|-----------|
|
|
808
|
+
|`Float64`|A 64-bit float that starts at the given index|
|
|
809
|
+
|
|
810
|
+
### Buffer.**setFloat64**
|
|
811
|
+
|
|
812
|
+
<details disabled>
|
|
813
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
814
|
+
No other changes yet.
|
|
815
|
+
</details>
|
|
816
|
+
|
|
817
|
+
```grain
|
|
818
|
+
setFloat64 : (Number, Float64, Buffer) -> Void
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
Sets a 64-bit float starting at the given byte index.
|
|
822
|
+
|
|
823
|
+
Parameters:
|
|
824
|
+
|
|
825
|
+
|param|type|description|
|
|
826
|
+
|-----|----|-----------|
|
|
827
|
+
|`index`|`Number`|The byte index to update|
|
|
828
|
+
|`value`|`Float64`|The value to set|
|
|
829
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
830
|
+
|
|
831
|
+
### Buffer.**addFloat64**
|
|
832
|
+
|
|
833
|
+
<details disabled>
|
|
834
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
835
|
+
No other changes yet.
|
|
836
|
+
</details>
|
|
837
|
+
|
|
838
|
+
```grain
|
|
839
|
+
addFloat64 : (Float64, Buffer) -> Void
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
Appends a 64-bit float to a buffer.
|
|
843
|
+
|
|
844
|
+
Parameters:
|
|
845
|
+
|
|
846
|
+
|param|type|description|
|
|
847
|
+
|-----|----|-----------|
|
|
848
|
+
|`value`|`Float64`|The value to append|
|
|
849
|
+
|`buffer`|`Buffer`|The buffer to mutate|
|
|
850
|
+
|