@grain/stdlib 0.4.6 → 0.5.2

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/array.gr +18 -18
  3. package/array.md +18 -18
  4. package/bigint.gr +497 -0
  5. package/bigint.md +811 -0
  6. package/buffer.gr +59 -223
  7. package/buffer.md +24 -17
  8. package/bytes.gr +100 -202
  9. package/bytes.md +19 -0
  10. package/char.gr +63 -133
  11. package/exception.gr +28 -2
  12. package/exception.md +43 -0
  13. package/float32.gr +76 -95
  14. package/float32.md +69 -30
  15. package/float64.gr +81 -95
  16. package/float64.md +69 -30
  17. package/hash.gr +37 -37
  18. package/int32.gr +152 -198
  19. package/int32.md +104 -0
  20. package/int64.gr +151 -197
  21. package/int64.md +104 -0
  22. package/list.gr +467 -70
  23. package/list.md +1141 -0
  24. package/map.gr +192 -7
  25. package/map.md +525 -0
  26. package/number.gr +111 -54
  27. package/number.md +100 -3
  28. package/option.md +1 -1
  29. package/package.json +3 -3
  30. package/pervasives.gr +499 -59
  31. package/pervasives.md +1116 -0
  32. package/queue.gr +4 -0
  33. package/queue.md +10 -0
  34. package/random.gr +196 -0
  35. package/random.md +179 -0
  36. package/regex.gr +1833 -842
  37. package/regex.md +11 -11
  38. package/result.md +1 -1
  39. package/runtime/bigint.gr +2045 -0
  40. package/runtime/bigint.md +326 -0
  41. package/runtime/dataStructures.gr +99 -278
  42. package/runtime/dataStructures.md +391 -0
  43. package/runtime/debug.md +6 -0
  44. package/runtime/equal.gr +5 -23
  45. package/runtime/equal.md +6 -0
  46. package/runtime/exception.md +30 -0
  47. package/runtime/gc.gr +20 -3
  48. package/runtime/gc.md +36 -0
  49. package/runtime/malloc.gr +13 -11
  50. package/runtime/malloc.md +55 -0
  51. package/runtime/numberUtils.gr +91 -41
  52. package/runtime/numberUtils.md +54 -0
  53. package/runtime/numbers.gr +1049 -391
  54. package/runtime/numbers.md +300 -0
  55. package/runtime/string.gr +136 -230
  56. package/runtime/string.md +24 -0
  57. package/runtime/stringUtils.gr +58 -38
  58. package/runtime/stringUtils.md +6 -0
  59. package/runtime/unsafe/constants.gr +17 -0
  60. package/runtime/unsafe/constants.md +72 -0
  61. package/runtime/unsafe/conv.md +71 -0
  62. package/runtime/unsafe/errors.md +204 -0
  63. package/runtime/unsafe/memory.md +54 -0
  64. package/runtime/unsafe/printWasm.md +24 -0
  65. package/runtime/unsafe/tags.gr +9 -8
  66. package/runtime/unsafe/tags.md +120 -0
  67. package/runtime/unsafe/wasmf32.md +168 -0
  68. package/runtime/unsafe/wasmf64.md +168 -0
  69. package/runtime/unsafe/wasmi32.md +282 -0
  70. package/runtime/unsafe/wasmi64.md +300 -0
  71. package/runtime/utils/printing.gr +62 -0
  72. package/runtime/utils/printing.md +18 -0
  73. package/runtime/wasi.gr +1 -1
  74. package/runtime/wasi.md +839 -0
  75. package/set.gr +17 -8
  76. package/set.md +24 -21
  77. package/stack.gr +3 -3
  78. package/stack.md +4 -6
  79. package/string.gr +194 -329
  80. package/string.md +3 -3
  81. package/sys/file.gr +245 -429
  82. package/sys/process.gr +27 -45
  83. package/sys/random.gr +47 -16
  84. package/sys/random.md +38 -0
  85. package/sys/time.gr +11 -27
package/buffer.gr CHANGED
@@ -14,6 +14,7 @@ import Exception from "runtime/exception"
14
14
  import Int32 from "int32"
15
15
  import Bytes from "bytes"
16
16
  import String from "string"
17
+ import Char from "char"
17
18
  import { coerceNumberToWasmI32 } from "runtime/numbers"
18
19
 
19
20
  record Buffer {
@@ -22,18 +23,11 @@ record Buffer {
22
23
  mut data: Bytes,
23
24
  }
24
25
 
25
- @disableGC
26
- let mut _SIZE_OFFSET = 1n
26
+ @unsafe
27
+ let mut _SIZE_OFFSET = 4n
27
28
 
28
- @disableGC
29
- let mut _VALUE_OFFSET = 1n
30
-
31
- @disableGC
32
- let initOffsets = () => {
33
- _SIZE_OFFSET = 4n
34
- _VALUE_OFFSET = 8n
35
- }
36
- initOffsets()
29
+ @unsafe
30
+ let mut _VALUE_OFFSET = 8n
37
31
 
38
32
  let _8BIT_LEN = 1
39
33
 
@@ -44,45 +38,34 @@ let _32BIT_LEN = 4
44
38
  let _64BIT_LEN = 8
45
39
 
46
40
  /* Gets the size of a Bytes via its ptr */
47
- @disableGC
41
+ @unsafe
48
42
  let getSize = ptr => WasmI32.load(ptr, _SIZE_OFFSET)
49
43
 
50
44
  /* Doubles the size of buffer's underlying byte sequence, if the given size is larger than the size of a buffer's underlying byte sequence */
51
45
  let autogrow = (len, buf) => {
52
- while (buf.len + len > Bytes.length(buf.data)) {
53
- let mut n = Bytes.length(buf.data)
54
- if (n == 0) n = 4
55
- // Make sure bytes of 0 length grow too
56
- buf.data = Bytes.resize(0, n, buf.data)
57
- }
58
- }
46
+ let requiredMinimumSize = buf.len + len
47
+ let currentSize = Bytes.length(buf.data)
59
48
 
60
- /* Gets the pointer for a char's bytes following the char's tag */
61
- @disableGC
62
- let rec getCharAsWasmI32 = char => {
63
- let c = WasmI32.fromGrain(char)
64
- WasmI32.load(c, 4n)
65
- }
49
+ if (requiredMinimumSize > currentSize) {
50
+ let mut newSize = if (currentSize > 0) {
51
+ currentSize
52
+ } else {
53
+ // Make sure bytes of 0 length grow too
54
+ 4
55
+ }
66
56
 
67
- /* Gets the UTF-8 byte length of a char */
68
- @disableGC
69
- let rec getCharByteLength = byte => {
70
- let (+) = WasmI32.add
71
- let (&) = WasmI32.and
72
- let (==) = WasmI32.eq
73
- if ((byte & 0x80n) == 0x00n) {
74
- 1n
75
- } else if ((byte & 0xF0n) == 0xF0n) {
76
- 4n
77
- } else if ((byte & 0xE0n) == 0xE0n) {
78
- 3n
79
- } else {
80
- 2n
57
+ while (newSize < requiredMinimumSize) {
58
+ newSize *= 2
59
+ }
60
+
61
+ let growBy = newSize - currentSize
62
+
63
+ buf.data = Bytes.resize(0, growBy, buf.data)
81
64
  }
82
65
  }
83
66
 
84
67
  /* Memcopies bytes from a source byte sequence to a destination byte sequence via pointers */
85
- @disableGC
68
+ @unsafe
86
69
  let rec appendBytes = (srcOff, dstOff, len, src, dst) => {
87
70
  let (+) = WasmI32.add
88
71
  Memory.copy(dst + _VALUE_OFFSET + dstOff, src + _VALUE_OFFSET + srcOff, len)
@@ -100,21 +83,21 @@ let checkIsIndexInBounds = (i, len, buf) => {
100
83
  let addInt8help = (value, buffer) => {
101
84
  autogrow(_8BIT_LEN, buffer)
102
85
  let index = buffer.len
103
- buffer.len = buffer.len + _8BIT_LEN
86
+ buffer.len += _8BIT_LEN
104
87
  Bytes.setInt8(index, value, buffer.data)
105
88
  }
106
89
 
107
90
  let addInt16help = (value, buffer) => {
108
91
  autogrow(_16BIT_LEN, buffer)
109
92
  let index = buffer.len
110
- buffer.len = buffer.len + _16BIT_LEN
93
+ buffer.len += _16BIT_LEN
111
94
  Bytes.setInt16(index, value, buffer.data)
112
95
  }
113
96
 
114
97
  let addInt32help = (value, buffer) => {
115
98
  autogrow(_32BIT_LEN, buffer)
116
99
  let index = buffer.len
117
- buffer.len = buffer.len + _32BIT_LEN
100
+ buffer.len += _32BIT_LEN
118
101
  Bytes.setInt32(index, value, buffer.data)
119
102
  }
120
103
 
@@ -159,7 +142,7 @@ export let length = buffer => buffer.len
159
142
  * @since v0.4.0
160
143
  */
161
144
  export let clear = buffer => {
162
- Bytes.fill(0x0l, buffer.data)
145
+ Bytes.clear(buffer.data)
163
146
  buffer.len = 0
164
147
  }
165
148
 
@@ -187,10 +170,8 @@ export let reset = buffer => {
187
170
  *
188
171
  * @since v0.4.0
189
172
  */
190
- @disableGC
191
- export let rec truncate = (length, buffer) => {
192
- Memory.incRef(WasmI32.fromGrain((<)))
193
- Memory.incRef(WasmI32.fromGrain((>)))
173
+ @unsafe
174
+ export let truncate = (length, buffer) => {
194
175
  if (length < 0 || length > buffer.len) throw Exception.IndexOutOfBounds
195
176
 
196
177
  let (+) = WasmI32.add
@@ -199,11 +180,6 @@ export let rec truncate = (length, buffer) => {
199
180
  let off = coerceNumberToWasmI32(length)
200
181
  let ret = Memory.fill(src + _VALUE_OFFSET + off, 0n, size)
201
182
  buffer.len = length
202
-
203
- Memory.decRef(WasmI32.fromGrain(length))
204
- Memory.decRef(WasmI32.fromGrain(buffer))
205
- Memory.decRef(WasmI32.fromGrain(truncate))
206
- void
207
183
  }
208
184
 
209
185
  /**
@@ -215,12 +191,7 @@ export let rec truncate = (length, buffer) => {
215
191
  * @since v0.4.0
216
192
  */
217
193
  export let toBytes = buffer => {
218
- let len = Bytes.length(buffer.data)
219
- if (buffer.len == len) {
220
- buffer.data
221
- } else {
222
- Bytes.slice(0, buffer.len, buffer.data)
223
- }
194
+ Bytes.slice(0, buffer.len, buffer.data)
224
195
  }
225
196
 
226
197
  /**
@@ -264,70 +235,6 @@ export let toStringSlice = (start, length, buffer) => {
264
235
  Bytes.toString(toBytesSlice(start, length, buffer))
265
236
  }
266
237
 
267
- /**
268
- * Appends the bytes of a char to a buffer.
269
- *
270
- * @param char: The character to append to the buffer
271
- * @param buffer: The buffer to mutate
272
- *
273
- * @since v0.4.0
274
- */
275
- @disableGC
276
- export let rec addChar = (char: Char, buffer: Buffer) => {
277
- let n = getCharAsWasmI32(char)
278
- let bytelen = getCharByteLength(n)
279
- match (bytelen) {
280
- 1n => {
281
- let c = Conv.toInt32(n)
282
- Memory.incRef(WasmI32.fromGrain(addInt8help))
283
- Memory.incRef(WasmI32.fromGrain(c))
284
- Memory.incRef(WasmI32.fromGrain(buffer))
285
- addInt8help(c, buffer)
286
- Memory.decRef(WasmI32.fromGrain(c))
287
- void
288
- },
289
- 2n => {
290
- let c = Conv.toInt32(n)
291
- Memory.incRef(WasmI32.fromGrain(addInt16help))
292
- Memory.incRef(WasmI32.fromGrain(c))
293
- Memory.incRef(WasmI32.fromGrain(buffer))
294
- addInt16help(c, buffer)
295
- Memory.decRef(WasmI32.fromGrain(c))
296
- void
297
- },
298
- 3n => {
299
- let (<) = WasmI32.ltU
300
- let (+) = WasmI32.add
301
- let (*) = WasmI32.mul
302
- let (&) = WasmI32.and
303
- let (>>) = WasmI32.shrU
304
- for (let mut i = 0n; i < 3n; i += 1n) {
305
- let c = Conv.toInt32(n >> i * 8n & 0xffn)
306
- Memory.incRef(WasmI32.fromGrain(addInt8help))
307
- Memory.incRef(WasmI32.fromGrain(c))
308
- Memory.incRef(WasmI32.fromGrain(buffer))
309
- addInt8help(c, buffer)
310
- Memory.decRef(WasmI32.fromGrain(c))
311
- void
312
- }
313
- },
314
- _ => {
315
- let c = Conv.toInt32(n)
316
- Memory.incRef(WasmI32.fromGrain(addInt32help))
317
- Memory.incRef(WasmI32.fromGrain(c))
318
- Memory.incRef(WasmI32.fromGrain(buffer))
319
- addInt32help(c, buffer)
320
- Memory.decRef(WasmI32.fromGrain(c))
321
- void
322
- },
323
- }
324
-
325
- Memory.decRef(WasmI32.fromGrain(char))
326
- Memory.decRef(WasmI32.fromGrain(buffer))
327
- Memory.decRef(WasmI32.fromGrain(addChar))
328
- void
329
- }
330
-
331
238
  /**
332
239
  * Appends a byte sequence to a buffer.
333
240
  *
@@ -336,15 +243,10 @@ export let rec addChar = (char: Char, buffer: Buffer) => {
336
243
  *
337
244
  * @since v0.4.0
338
245
  */
339
- @disableGC
340
- export let rec addBytes = (bytes, buffer) => {
341
- Memory.incRef(WasmI32.fromGrain(Bytes.length))
342
- Memory.incRef(WasmI32.fromGrain(bytes))
246
+ @unsafe
247
+ export let addBytes = (bytes, buffer) => {
343
248
  let bytelen = Bytes.length(bytes)
344
249
 
345
- Memory.incRef(WasmI32.fromGrain(autogrow))
346
- Memory.incRef(WasmI32.fromGrain(bytelen))
347
- Memory.incRef(WasmI32.fromGrain(buffer))
348
250
  autogrow(bytelen, buffer)
349
251
 
350
252
  let off = coerceNumberToWasmI32(buffer.len)
@@ -353,15 +255,7 @@ export let rec addBytes = (bytes, buffer) => {
353
255
  let dst = WasmI32.fromGrain(buffer.data)
354
256
  appendBytes(0n, off, len, src, dst)
355
257
 
356
- Memory.incRef(WasmI32.fromGrain((+)))
357
- Memory.incRef(WasmI32.fromGrain(buffer.len))
358
- Memory.incRef(WasmI32.fromGrain(bytelen))
359
- buffer.len = buffer.len + bytelen
360
-
361
- Memory.decRef(WasmI32.fromGrain(bytes))
362
- Memory.decRef(WasmI32.fromGrain(buffer))
363
- Memory.decRef(WasmI32.fromGrain(addBytes))
364
- void
258
+ buffer.len += bytelen
365
259
  }
366
260
 
367
261
  /**
@@ -372,15 +266,10 @@ export let rec addBytes = (bytes, buffer) => {
372
266
  *
373
267
  * @since v0.4.0
374
268
  */
375
- @disableGC
376
- export let rec addString = (string, buffer) => {
377
- Memory.incRef(WasmI32.fromGrain(String.byteLength))
378
- Memory.incRef(WasmI32.fromGrain(string))
269
+ @unsafe
270
+ export let addString = (string, buffer) => {
379
271
  let bytelen = String.byteLength(string)
380
272
 
381
- Memory.incRef(WasmI32.fromGrain(autogrow))
382
- Memory.incRef(WasmI32.fromGrain(bytelen))
383
- Memory.incRef(WasmI32.fromGrain(buffer))
384
273
  autogrow(bytelen, buffer)
385
274
 
386
275
  let off = coerceNumberToWasmI32(buffer.len)
@@ -389,66 +278,38 @@ export let rec addString = (string, buffer) => {
389
278
  let dst = WasmI32.fromGrain(buffer.data)
390
279
  appendBytes(0n, off, len, src, dst)
391
280
 
392
- Memory.incRef(WasmI32.fromGrain((+)))
393
- Memory.incRef(WasmI32.fromGrain(buffer.len))
394
- Memory.incRef(WasmI32.fromGrain(bytelen))
395
- buffer.len = buffer.len + bytelen
281
+ buffer.len += bytelen
282
+ }
396
283
 
397
- Memory.decRef(WasmI32.fromGrain(string))
398
- Memory.decRef(WasmI32.fromGrain(buffer))
399
- Memory.decRef(WasmI32.fromGrain(addString))
400
- void
284
+ /**
285
+ * Appends the bytes of a char to a buffer.
286
+ *
287
+ * @param char: The character to append to the buffer
288
+ * @param buffer: The buffer to mutate
289
+ *
290
+ * @since v0.4.0
291
+ */
292
+ export let addChar = (char, buffer) => {
293
+ addString(Char.toString(char), buffer)
401
294
  }
402
295
 
403
296
  /**
404
297
  * Appends the bytes of a subset of a string to a buffer.
405
298
  *
406
299
  * @param start: The char offset into the string
407
- * @param length: The number of bytes to append
300
+ * @param end: The end offset into the string
408
301
  * @param string: The string to append
409
302
  * @param buffer: The buffer to mutate
410
303
  *
411
304
  * @since v0.4.0
305
+ * @history v0.5.0: Now takes the end offset instead of length
412
306
  */
413
- @disableGC
414
- export let rec addStringSlice = (start: Number, length, string, buffer) => {
415
- // Handle negative start index (needed before #1071 is fixed)
416
- let start = {
417
- // this is a block to avoid making all of these operators
418
- // overriden in the whole function
419
- let (<<) = WasmI32.shl
420
- let (>>) = WasmI32.shrS
421
- let (+) = WasmI32.add
422
- let (!=) = WasmI32.ne
423
- let (&) = WasmI32.and
424
- Memory.incRef(WasmI32.fromGrain(String.length))
425
- Memory.incRef(WasmI32.fromGrain(string))
426
- let strlen = WasmI32.fromGrain(String.length(string)) >> 1n
427
- let mut startW = WasmI32.fromGrain(start)
428
- if ((startW & 1n) != 1n) {
429
- throw InvalidArgument("Invalid start index")
430
- }
431
- startW = startW >> 1n
432
- if (WasmI32.ltS(startW, 0n)) {
433
- WasmI32.toGrain(WasmI32.shl(startW + strlen, 1n) + 1n)
434
- } else {
435
- start
436
- }
437
- }
438
- let end = start + length
439
- Memory.incRef(WasmI32.fromGrain(String.slice))
440
- // no incref for start since we know it's a simple num. Add back for good measure after #1071 is fixed!
441
- Memory.incRef(WasmI32.fromGrain(end))
442
- Memory.incRef(WasmI32.fromGrain(string))
307
+ @unsafe
308
+ export let addStringSlice = (start: Number, end, string, buffer) => {
443
309
  let slice = String.slice(start, end, string)
444
310
 
445
- Memory.incRef(WasmI32.fromGrain(String.byteLength))
446
- Memory.incRef(WasmI32.fromGrain(slice))
447
311
  let bytelen = String.byteLength(slice)
448
312
 
449
- Memory.incRef(WasmI32.fromGrain(autogrow))
450
- Memory.incRef(WasmI32.fromGrain(bytelen))
451
- Memory.incRef(WasmI32.fromGrain(buffer))
452
313
  autogrow(bytelen, buffer)
453
314
 
454
315
  let srcOff = 0n
@@ -456,24 +317,12 @@ export let rec addStringSlice = (start: Number, length, string, buffer) => {
456
317
  let src = WasmI32.fromGrain(slice)
457
318
  let dst = WasmI32.fromGrain(buffer.data)
458
319
  appendBytes(srcOff, dstOff, coerceNumberToWasmI32(bytelen), src, dst)
459
- Memory.decRef(WasmI32.fromGrain(slice))
460
320
 
461
- Memory.incRef(WasmI32.fromGrain((+)))
462
- Memory.incRef(WasmI32.fromGrain(buffer.len))
463
- Memory.incRef(WasmI32.fromGrain(bytelen))
464
- buffer.len = buffer.len + bytelen
465
- Memory.decRef(WasmI32.fromGrain(bytelen))
466
-
467
- Memory.decRef(WasmI32.fromGrain(start))
468
- Memory.decRef(WasmI32.fromGrain(length))
469
- Memory.decRef(WasmI32.fromGrain(string))
470
- Memory.decRef(WasmI32.fromGrain(buffer))
471
- Memory.decRef(WasmI32.fromGrain(addStringSlice))
472
- void
321
+ buffer.len += bytelen
473
322
  }
474
323
 
475
324
  /**
476
- * Appends the bytes of a subset of a byte seuqnece to a buffer.
325
+ * Appends the bytes of a subset of a byte sequence to a buffer.
477
326
  *
478
327
  * @param start: The byte offset into the byte sequence
479
328
  * @param length: The number of bytes to append
@@ -482,8 +331,8 @@ export let rec addStringSlice = (start: Number, length, string, buffer) => {
482
331
  *
483
332
  * @since v0.4.0
484
333
  */
485
- @disableGC
486
- export let rec addBytesSlice =
334
+ @unsafe
335
+ export let addBytesSlice =
487
336
  (
488
337
  start: Number,
489
338
  length: Number,
@@ -508,9 +357,6 @@ export let rec addBytesSlice =
508
357
  throw Exception.IndexOutOfBounds
509
358
  }
510
359
 
511
- Memory.incRef(WasmI32.fromGrain(autogrow))
512
- Memory.incRef(WasmI32.fromGrain(length))
513
- Memory.incRef(WasmI32.fromGrain(buffer))
514
360
  autogrow(length, buffer)
515
361
 
516
362
  let dstOff = coerceNumberToWasmI32(buffer.len)
@@ -518,17 +364,7 @@ export let rec addBytesSlice =
518
364
  let dst = WasmI32.fromGrain(buffer.data)
519
365
  appendBytes(srcOff, dstOff, len, src, dst)
520
366
 
521
- Memory.incRef(WasmI32.fromGrain((+)))
522
- Memory.incRef(WasmI32.fromGrain(buffer.len))
523
- Memory.incRef(WasmI32.fromGrain(length))
524
- buffer.len = buffer.len + length
525
-
526
- Memory.decRef(WasmI32.fromGrain(start))
527
- Memory.decRef(WasmI32.fromGrain(length))
528
- Memory.decRef(WasmI32.fromGrain(bytes))
529
- Memory.decRef(WasmI32.fromGrain(buffer))
530
- Memory.decRef(WasmI32.fromGrain(addBytesSlice))
531
- void
367
+ buffer.len += length
532
368
  }
533
369
 
534
370
  /**
@@ -752,7 +588,7 @@ export let setFloat32 = (index, value, buffer) => {
752
588
  export let addFloat32 = (value, buffer) => {
753
589
  autogrow(_32BIT_LEN, buffer)
754
590
  let index = buffer.len
755
- buffer.len = buffer.len + _32BIT_LEN
591
+ buffer.len += _32BIT_LEN
756
592
  setFloat32(index, value, buffer)
757
593
  }
758
594
 
@@ -795,7 +631,7 @@ export let setInt64 = (index, value, buffer) => {
795
631
  export let addInt64 = (value, buffer) => {
796
632
  autogrow(_64BIT_LEN, buffer)
797
633
  let index = buffer.len
798
- buffer.len = buffer.len + _64BIT_LEN
634
+ buffer.len += _64BIT_LEN
799
635
  setInt64(index, value, buffer)
800
636
  }
801
637
 
@@ -838,6 +674,6 @@ export let setFloat64 = (index, value, buffer) => {
838
674
  export let addFloat64 = (value, buffer) => {
839
675
  autogrow(_64BIT_LEN, buffer)
840
676
  let index = buffer.len
841
- buffer.len = buffer.len + _64BIT_LEN
677
+ buffer.len += _64BIT_LEN
842
678
  setFloat64(index, value, buffer)
843
679
  }
package/buffer.md CHANGED
@@ -240,7 +240,7 @@ Returns:
240
240
  |----|-----------|
241
241
  |`String`|A string made with a subset of data copied from the buffer|
242
242
 
243
- ### Buffer.**addChar**
243
+ ### Buffer.**addBytes**
244
244
 
245
245
  <details disabled>
246
246
  <summary tabindex="-1">Added in <code>0.4.0</code></summary>
@@ -248,19 +248,19 @@ No other changes yet.
248
248
  </details>
249
249
 
250
250
  ```grain
251
- addChar : (Char, Buffer) -> Void
251
+ addBytes : (Bytes, Buffer) -> Void
252
252
  ```
253
253
 
254
- Appends the bytes of a char to a buffer.
254
+ Appends a byte sequence to a buffer.
255
255
 
256
256
  Parameters:
257
257
 
258
258
  |param|type|description|
259
259
  |-----|----|-----------|
260
- |`char`|`Char`|The character to append to the buffer|
260
+ |`bytes`|`Bytes`|The byte sequence to append|
261
261
  |`buffer`|`Buffer`|The buffer to mutate|
262
262
 
263
- ### Buffer.**addBytes**
263
+ ### Buffer.**addString**
264
264
 
265
265
  <details disabled>
266
266
  <summary tabindex="-1">Added in <code>0.4.0</code></summary>
@@ -268,19 +268,19 @@ No other changes yet.
268
268
  </details>
269
269
 
270
270
  ```grain
271
- addBytes : (Bytes, Buffer) -> Void
271
+ addString : (String, Buffer) -> Void
272
272
  ```
273
273
 
274
- Appends a byte sequence to a buffer.
274
+ Appends the bytes of a string to a buffer.
275
275
 
276
276
  Parameters:
277
277
 
278
278
  |param|type|description|
279
279
  |-----|----|-----------|
280
- |`bytes`|`Bytes`|The byte sequence to append|
280
+ |`string`|`String`|The string to append|
281
281
  |`buffer`|`Buffer`|The buffer to mutate|
282
282
 
283
- ### Buffer.**addString**
283
+ ### Buffer.**addChar**
284
284
 
285
285
  <details disabled>
286
286
  <summary tabindex="-1">Added in <code>0.4.0</code></summary>
@@ -288,23 +288,30 @@ No other changes yet.
288
288
  </details>
289
289
 
290
290
  ```grain
291
- addString : (String, Buffer) -> Void
291
+ addChar : (Char, Buffer) -> Void
292
292
  ```
293
293
 
294
- Appends the bytes of a string to a buffer.
294
+ Appends the bytes of a char to a buffer.
295
295
 
296
296
  Parameters:
297
297
 
298
298
  |param|type|description|
299
299
  |-----|----|-----------|
300
- |`string`|`String`|The string to append|
300
+ |`char`|`Char`|The character to append to the buffer|
301
301
  |`buffer`|`Buffer`|The buffer to mutate|
302
302
 
303
303
  ### Buffer.**addStringSlice**
304
304
 
305
- <details disabled>
306
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
307
- No other changes yet.
305
+ <details>
306
+ <summary>Added in <code>0.4.0</code></summary>
307
+ <table>
308
+ <thead>
309
+ <tr><th>version</th><th>changes</th></tr>
310
+ </thead>
311
+ <tbody>
312
+ <tr><td><code>0.5.0</code></td><td>Now takes the end offset instead of length</td></tr>
313
+ </tbody>
314
+ </table>
308
315
  </details>
309
316
 
310
317
  ```grain
@@ -318,7 +325,7 @@ Parameters:
318
325
  |param|type|description|
319
326
  |-----|----|-----------|
320
327
  |`start`|`Number`|The char offset into the string|
321
- |`length`|`Number`|The number of bytes to append|
328
+ |`end`|`Number`|The end offset into the string|
322
329
  |`string`|`String`|The string to append|
323
330
  |`buffer`|`Buffer`|The buffer to mutate|
324
331
 
@@ -333,7 +340,7 @@ No other changes yet.
333
340
  addBytesSlice : (Number, Number, Bytes, Buffer) -> Void
334
341
  ```
335
342
 
336
- Appends the bytes of a subset of a byte seuqnece to a buffer.
343
+ Appends the bytes of a subset of a byte sequence to a buffer.
337
344
 
338
345
  Parameters:
339
346