@grain/stdlib 0.4.4 → 0.5.0

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 (97) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/LICENSE +1 -1
  3. package/array.gr +92 -73
  4. package/array.md +18 -18
  5. package/bigint.gr +497 -0
  6. package/bigint.md +811 -0
  7. package/buffer.gr +56 -217
  8. package/buffer.md +24 -17
  9. package/bytes.gr +103 -205
  10. package/bytes.md +19 -0
  11. package/char.gr +152 -166
  12. package/char.md +200 -0
  13. package/exception.md +6 -0
  14. package/float32.gr +159 -82
  15. package/float32.md +315 -0
  16. package/float64.gr +163 -82
  17. package/float64.md +315 -0
  18. package/hash.gr +53 -49
  19. package/int32.gr +479 -230
  20. package/int32.md +937 -0
  21. package/int64.gr +479 -230
  22. package/int64.md +937 -0
  23. package/list.gr +530 -116
  24. package/list.md +1141 -0
  25. package/map.gr +302 -121
  26. package/map.md +525 -0
  27. package/number.gr +51 -57
  28. package/number.md +37 -3
  29. package/option.gr +25 -25
  30. package/option.md +1 -1
  31. package/package.json +3 -3
  32. package/pervasives.gr +504 -52
  33. package/pervasives.md +1116 -0
  34. package/queue.gr +8 -1
  35. package/queue.md +10 -0
  36. package/random.gr +196 -0
  37. package/random.md +179 -0
  38. package/range.gr +26 -26
  39. package/regex.gr +1833 -842
  40. package/regex.md +11 -11
  41. package/result.md +1 -1
  42. package/runtime/bigint.gr +2045 -0
  43. package/runtime/bigint.md +326 -0
  44. package/runtime/dataStructures.gr +99 -279
  45. package/runtime/dataStructures.md +391 -0
  46. package/runtime/debug.gr +0 -1
  47. package/runtime/debug.md +6 -0
  48. package/runtime/equal.gr +40 -37
  49. package/runtime/equal.md +6 -0
  50. package/runtime/exception.gr +28 -15
  51. package/runtime/exception.md +30 -0
  52. package/runtime/gc.gr +50 -20
  53. package/runtime/gc.md +36 -0
  54. package/runtime/malloc.gr +32 -22
  55. package/runtime/malloc.md +55 -0
  56. package/runtime/numberUtils.gr +297 -142
  57. package/runtime/numberUtils.md +54 -0
  58. package/runtime/numbers.gr +1204 -453
  59. package/runtime/numbers.md +300 -0
  60. package/runtime/string.gr +193 -228
  61. package/runtime/string.md +24 -0
  62. package/runtime/stringUtils.gr +62 -38
  63. package/runtime/stringUtils.md +6 -0
  64. package/runtime/unsafe/constants.gr +17 -0
  65. package/runtime/unsafe/constants.md +72 -0
  66. package/runtime/unsafe/conv.gr +10 -10
  67. package/runtime/unsafe/conv.md +71 -0
  68. package/runtime/unsafe/errors.md +204 -0
  69. package/runtime/unsafe/memory.gr +14 -3
  70. package/runtime/unsafe/memory.md +54 -0
  71. package/runtime/unsafe/printWasm.gr +4 -4
  72. package/runtime/unsafe/printWasm.md +24 -0
  73. package/runtime/unsafe/tags.gr +11 -10
  74. package/runtime/unsafe/tags.md +120 -0
  75. package/runtime/unsafe/wasmf32.gr +9 -2
  76. package/runtime/unsafe/wasmf32.md +168 -0
  77. package/runtime/unsafe/wasmf64.gr +9 -2
  78. package/runtime/unsafe/wasmf64.md +168 -0
  79. package/runtime/unsafe/wasmi32.gr +65 -47
  80. package/runtime/unsafe/wasmi32.md +282 -0
  81. package/runtime/unsafe/wasmi64.gr +78 -50
  82. package/runtime/unsafe/wasmi64.md +300 -0
  83. package/runtime/utils/printing.gr +62 -0
  84. package/runtime/utils/printing.md +18 -0
  85. package/runtime/wasi.gr +200 -46
  86. package/runtime/wasi.md +839 -0
  87. package/set.gr +125 -121
  88. package/set.md +24 -21
  89. package/stack.gr +29 -29
  90. package/stack.md +4 -6
  91. package/string.gr +434 -415
  92. package/string.md +3 -3
  93. package/sys/file.gr +477 -482
  94. package/sys/process.gr +33 -47
  95. package/sys/random.gr +48 -20
  96. package/sys/random.md +38 -0
  97. package/sys/time.gr +12 -28
package/buffer.gr CHANGED
@@ -14,22 +14,20 @@ 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
- record Buffer { mut len: Number, initialSize: Number, mut data: Bytes }
20
-
21
- @disableGC
22
- let mut _SIZE_OFFSET = 1n
20
+ record Buffer {
21
+ mut len: Number,
22
+ initialSize: Number,
23
+ mut data: Bytes,
24
+ }
23
25
 
24
- @disableGC
25
- let mut _VALUE_OFFSET = 1n
26
+ @unsafe
27
+ let mut _SIZE_OFFSET = 4n
26
28
 
27
- @disableGC
28
- let initOffsets = () => {
29
- _SIZE_OFFSET = 4n
30
- _VALUE_OFFSET = 8n
31
- }
32
- initOffsets()
29
+ @unsafe
30
+ let mut _VALUE_OFFSET = 8n
33
31
 
34
32
  let _8BIT_LEN = 1
35
33
 
@@ -40,45 +38,34 @@ let _32BIT_LEN = 4
40
38
  let _64BIT_LEN = 8
41
39
 
42
40
  /* Gets the size of a Bytes via its ptr */
43
- @disableGC
41
+ @unsafe
44
42
  let getSize = ptr => WasmI32.load(ptr, _SIZE_OFFSET)
45
43
 
46
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 */
47
45
  let autogrow = (len, buf) => {
48
- while (buf.len + len > Bytes.length(buf.data)) {
49
- let mut n = Bytes.length(buf.data)
50
- if (n == 0) n = 4
51
- // Make sure bytes of 0 length grow too
52
- buf.data = Bytes.resize(0, n, buf.data)
53
- }
54
- }
46
+ let requiredMinimumSize = buf.len + len
47
+ let currentSize = Bytes.length(buf.data)
55
48
 
56
- /* Gets the pointer for a char's bytes following the char's tag */
57
- @disableGC
58
- let rec getCharAsWasmI32 = char => {
59
- let c = WasmI32.fromGrain(char)
60
- WasmI32.load(c, 4n)
61
- }
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
+ }
62
56
 
63
- /* Gets the UTF-8 byte length of a char */
64
- @disableGC
65
- let rec getCharByteLength = byte => {
66
- let (+) = WasmI32.add
67
- let (&) = WasmI32.and
68
- let (==) = WasmI32.eq
69
- if ((byte & 0x80n) == 0x00n) {
70
- 1n
71
- } else if ((byte & 0xF0n) == 0xF0n) {
72
- 4n
73
- } else if ((byte & 0xE0n) == 0xE0n) {
74
- 3n
75
- } else {
76
- 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)
77
64
  }
78
65
  }
79
66
 
80
67
  /* Memcopies bytes from a source byte sequence to a destination byte sequence via pointers */
81
- @disableGC
68
+ @unsafe
82
69
  let rec appendBytes = (srcOff, dstOff, len, src, dst) => {
83
70
  let (+) = WasmI32.add
84
71
  Memory.copy(dst + _VALUE_OFFSET + dstOff, src + _VALUE_OFFSET + srcOff, len)
@@ -130,9 +117,8 @@ let addInt32help = (value, buffer) => {
130
117
  * @since v0.4.0
131
118
  */
132
119
  export let make = initialSize => {
133
- if (initialSize < 0) throw Exception.InvalidArgument(
134
- "Buffers size must be >= 0",
135
- )
120
+ if (initialSize < 0)
121
+ throw Exception.InvalidArgument("Buffers size must be >= 0")
136
122
  { len: 0, initialSize, data: Bytes.make(initialSize) }
137
123
  }
138
124
 
@@ -156,7 +142,7 @@ export let length = buffer => buffer.len
156
142
  * @since v0.4.0
157
143
  */
158
144
  export let clear = buffer => {
159
- Bytes.fill(0x0l, buffer.data)
145
+ Bytes.clear(buffer.data)
160
146
  buffer.len = 0
161
147
  }
162
148
 
@@ -184,10 +170,8 @@ export let reset = buffer => {
184
170
  *
185
171
  * @since v0.4.0
186
172
  */
187
- @disableGC
188
- export let rec truncate = (length, buffer) => {
189
- Memory.incRef(WasmI32.fromGrain((<)))
190
- Memory.incRef(WasmI32.fromGrain((>)))
173
+ @unsafe
174
+ export let truncate = (length, buffer) => {
191
175
  if (length < 0 || length > buffer.len) throw Exception.IndexOutOfBounds
192
176
 
193
177
  let (+) = WasmI32.add
@@ -196,11 +180,6 @@ export let rec truncate = (length, buffer) => {
196
180
  let off = coerceNumberToWasmI32(length)
197
181
  let ret = Memory.fill(src + _VALUE_OFFSET + off, 0n, size)
198
182
  buffer.len = length
199
-
200
- Memory.decRef(WasmI32.fromGrain(length))
201
- Memory.decRef(WasmI32.fromGrain(buffer))
202
- Memory.decRef(WasmI32.fromGrain(truncate))
203
- void
204
183
  }
205
184
 
206
185
  /**
@@ -212,12 +191,7 @@ export let rec truncate = (length, buffer) => {
212
191
  * @since v0.4.0
213
192
  */
214
193
  export let toBytes = buffer => {
215
- let len = Bytes.length(buffer.data)
216
- if (buffer.len == len) {
217
- buffer.data
218
- } else {
219
- Bytes.slice(0, buffer.len, buffer.data)
220
- }
194
+ Bytes.slice(0, buffer.len, buffer.data)
221
195
  }
222
196
 
223
197
  /**
@@ -261,70 +235,6 @@ export let toStringSlice = (start, length, buffer) => {
261
235
  Bytes.toString(toBytesSlice(start, length, buffer))
262
236
  }
263
237
 
264
- /**
265
- * Appends the bytes of a char to a buffer.
266
- *
267
- * @param char: The character to append to the buffer
268
- * @param buffer: The buffer to mutate
269
- *
270
- * @since v0.4.0
271
- */
272
- @disableGC
273
- export let rec addChar = (char: Char, buffer: Buffer) => {
274
- let n = getCharAsWasmI32(char)
275
- let bytelen = getCharByteLength(n)
276
- match (bytelen) {
277
- 1n => {
278
- let c = Conv.toInt32(n)
279
- Memory.incRef(WasmI32.fromGrain(addInt8help))
280
- Memory.incRef(WasmI32.fromGrain(c))
281
- Memory.incRef(WasmI32.fromGrain(buffer))
282
- addInt8help(c, buffer)
283
- Memory.decRef(WasmI32.fromGrain(c))
284
- void
285
- },
286
- 2n => {
287
- let c = Conv.toInt32(n)
288
- Memory.incRef(WasmI32.fromGrain(addInt16help))
289
- Memory.incRef(WasmI32.fromGrain(c))
290
- Memory.incRef(WasmI32.fromGrain(buffer))
291
- addInt16help(c, buffer)
292
- Memory.decRef(WasmI32.fromGrain(c))
293
- void
294
- },
295
- 3n => {
296
- let (<) = WasmI32.ltU
297
- let (+) = WasmI32.add
298
- let (*) = WasmI32.mul
299
- let (&) = WasmI32.and
300
- let (>>) = WasmI32.shrU
301
- for (let mut i = 0n; i < 3n; i += 1n) {
302
- let c = Conv.toInt32(n >> i * 8n & 0xffn)
303
- Memory.incRef(WasmI32.fromGrain(addInt8help))
304
- Memory.incRef(WasmI32.fromGrain(c))
305
- Memory.incRef(WasmI32.fromGrain(buffer))
306
- addInt8help(c, buffer)
307
- Memory.decRef(WasmI32.fromGrain(c))
308
- void
309
- }
310
- },
311
- _ => {
312
- let c = Conv.toInt32(n)
313
- Memory.incRef(WasmI32.fromGrain(addInt32help))
314
- Memory.incRef(WasmI32.fromGrain(c))
315
- Memory.incRef(WasmI32.fromGrain(buffer))
316
- addInt32help(c, buffer)
317
- Memory.decRef(WasmI32.fromGrain(c))
318
- void
319
- },
320
- }
321
-
322
- Memory.decRef(WasmI32.fromGrain(char))
323
- Memory.decRef(WasmI32.fromGrain(buffer))
324
- Memory.decRef(WasmI32.fromGrain(addChar))
325
- void
326
- }
327
-
328
238
  /**
329
239
  * Appends a byte sequence to a buffer.
330
240
  *
@@ -333,15 +243,10 @@ export let rec addChar = (char: Char, buffer: Buffer) => {
333
243
  *
334
244
  * @since v0.4.0
335
245
  */
336
- @disableGC
337
- export let rec addBytes = (bytes, buffer) => {
338
- Memory.incRef(WasmI32.fromGrain(Bytes.length))
339
- Memory.incRef(WasmI32.fromGrain(bytes))
246
+ @unsafe
247
+ export let addBytes = (bytes, buffer) => {
340
248
  let bytelen = Bytes.length(bytes)
341
249
 
342
- Memory.incRef(WasmI32.fromGrain(autogrow))
343
- Memory.incRef(WasmI32.fromGrain(bytelen))
344
- Memory.incRef(WasmI32.fromGrain(buffer))
345
250
  autogrow(bytelen, buffer)
346
251
 
347
252
  let off = coerceNumberToWasmI32(buffer.len)
@@ -350,15 +255,7 @@ export let rec addBytes = (bytes, buffer) => {
350
255
  let dst = WasmI32.fromGrain(buffer.data)
351
256
  appendBytes(0n, off, len, src, dst)
352
257
 
353
- Memory.incRef(WasmI32.fromGrain((+)))
354
- Memory.incRef(WasmI32.fromGrain(buffer.len))
355
- Memory.incRef(WasmI32.fromGrain(bytelen))
356
258
  buffer.len = buffer.len + bytelen
357
-
358
- Memory.decRef(WasmI32.fromGrain(bytes))
359
- Memory.decRef(WasmI32.fromGrain(buffer))
360
- Memory.decRef(WasmI32.fromGrain(addBytes))
361
- void
362
259
  }
363
260
 
364
261
  /**
@@ -369,15 +266,10 @@ export let rec addBytes = (bytes, buffer) => {
369
266
  *
370
267
  * @since v0.4.0
371
268
  */
372
- @disableGC
373
- export let rec addString = (string, buffer) => {
374
- Memory.incRef(WasmI32.fromGrain(String.byteLength))
375
- Memory.incRef(WasmI32.fromGrain(string))
269
+ @unsafe
270
+ export let addString = (string, buffer) => {
376
271
  let bytelen = String.byteLength(string)
377
272
 
378
- Memory.incRef(WasmI32.fromGrain(autogrow))
379
- Memory.incRef(WasmI32.fromGrain(bytelen))
380
- Memory.incRef(WasmI32.fromGrain(buffer))
381
273
  autogrow(bytelen, buffer)
382
274
 
383
275
  let off = coerceNumberToWasmI32(buffer.len)
@@ -386,66 +278,38 @@ export let rec addString = (string, buffer) => {
386
278
  let dst = WasmI32.fromGrain(buffer.data)
387
279
  appendBytes(0n, off, len, src, dst)
388
280
 
389
- Memory.incRef(WasmI32.fromGrain((+)))
390
- Memory.incRef(WasmI32.fromGrain(buffer.len))
391
- Memory.incRef(WasmI32.fromGrain(bytelen))
392
281
  buffer.len = buffer.len + bytelen
282
+ }
393
283
 
394
- Memory.decRef(WasmI32.fromGrain(string))
395
- Memory.decRef(WasmI32.fromGrain(buffer))
396
- Memory.decRef(WasmI32.fromGrain(addString))
397
- 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)
398
294
  }
399
295
 
400
296
  /**
401
297
  * Appends the bytes of a subset of a string to a buffer.
402
298
  *
403
299
  * @param start: The char offset into the string
404
- * @param length: The number of bytes to append
300
+ * @param end: The end offset into the string
405
301
  * @param string: The string to append
406
302
  * @param buffer: The buffer to mutate
407
303
  *
408
304
  * @since v0.4.0
305
+ * @history v0.5.0: Now takes the end offset instead of length
409
306
  */
410
- @disableGC
411
- export let rec addStringSlice = (start: Number, length, string, buffer) => {
412
- // Handle negative start index (needed before #1071 is fixed)
413
- let start = {
414
- // this is a block to avoid making all of these operators
415
- // overriden in the whole function
416
- let (<<) = WasmI32.shl
417
- let (>>) = WasmI32.shrS
418
- let (+) = WasmI32.add
419
- let (!=) = WasmI32.ne
420
- let (&) = WasmI32.and
421
- Memory.incRef(WasmI32.fromGrain(String.length))
422
- Memory.incRef(WasmI32.fromGrain(string))
423
- let strlen = WasmI32.fromGrain(String.length(string)) >> 1n
424
- let mut startW = WasmI32.fromGrain(start)
425
- if ((startW & 1n) != 1n) {
426
- throw InvalidArgument("Invalid start index")
427
- }
428
- startW = startW >> 1n
429
- if (WasmI32.ltS(startW, 0n)) {
430
- WasmI32.toGrain(WasmI32.shl(startW + strlen, 1n) + 1n)
431
- } else {
432
- start
433
- }
434
- }
435
- let end = start + length
436
- Memory.incRef(WasmI32.fromGrain(String.slice))
437
- // no incref for start since we know it's a simple num. Add back for good measure after #1071 is fixed!
438
- Memory.incRef(WasmI32.fromGrain(end))
439
- Memory.incRef(WasmI32.fromGrain(string))
307
+ @unsafe
308
+ export let addStringSlice = (start: Number, end, string, buffer) => {
440
309
  let slice = String.slice(start, end, string)
441
310
 
442
- Memory.incRef(WasmI32.fromGrain(String.byteLength))
443
- Memory.incRef(WasmI32.fromGrain(slice))
444
311
  let bytelen = String.byteLength(slice)
445
312
 
446
- Memory.incRef(WasmI32.fromGrain(autogrow))
447
- Memory.incRef(WasmI32.fromGrain(bytelen))
448
- Memory.incRef(WasmI32.fromGrain(buffer))
449
313
  autogrow(bytelen, buffer)
450
314
 
451
315
  let srcOff = 0n
@@ -453,24 +317,12 @@ export let rec addStringSlice = (start: Number, length, string, buffer) => {
453
317
  let src = WasmI32.fromGrain(slice)
454
318
  let dst = WasmI32.fromGrain(buffer.data)
455
319
  appendBytes(srcOff, dstOff, coerceNumberToWasmI32(bytelen), src, dst)
456
- Memory.decRef(WasmI32.fromGrain(slice))
457
320
 
458
- Memory.incRef(WasmI32.fromGrain((+)))
459
- Memory.incRef(WasmI32.fromGrain(buffer.len))
460
- Memory.incRef(WasmI32.fromGrain(bytelen))
461
321
  buffer.len = buffer.len + bytelen
462
- Memory.decRef(WasmI32.fromGrain(bytelen))
463
-
464
- Memory.decRef(WasmI32.fromGrain(start))
465
- Memory.decRef(WasmI32.fromGrain(length))
466
- Memory.decRef(WasmI32.fromGrain(string))
467
- Memory.decRef(WasmI32.fromGrain(buffer))
468
- Memory.decRef(WasmI32.fromGrain(addStringSlice))
469
- void
470
322
  }
471
323
 
472
324
  /**
473
- * 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.
474
326
  *
475
327
  * @param start: The byte offset into the byte sequence
476
328
  * @param length: The number of bytes to append
@@ -479,8 +331,8 @@ export let rec addStringSlice = (start: Number, length, string, buffer) => {
479
331
  *
480
332
  * @since v0.4.0
481
333
  */
482
- @disableGC
483
- export let rec addBytesSlice =
334
+ @unsafe
335
+ export let addBytesSlice =
484
336
  (
485
337
  start: Number,
486
338
  length: Number,
@@ -505,9 +357,6 @@ export let rec addBytesSlice =
505
357
  throw Exception.IndexOutOfBounds
506
358
  }
507
359
 
508
- Memory.incRef(WasmI32.fromGrain(autogrow))
509
- Memory.incRef(WasmI32.fromGrain(length))
510
- Memory.incRef(WasmI32.fromGrain(buffer))
511
360
  autogrow(length, buffer)
512
361
 
513
362
  let dstOff = coerceNumberToWasmI32(buffer.len)
@@ -515,17 +364,7 @@ export let rec addBytesSlice =
515
364
  let dst = WasmI32.fromGrain(buffer.data)
516
365
  appendBytes(srcOff, dstOff, len, src, dst)
517
366
 
518
- Memory.incRef(WasmI32.fromGrain((+)))
519
- Memory.incRef(WasmI32.fromGrain(buffer.len))
520
- Memory.incRef(WasmI32.fromGrain(length))
521
367
  buffer.len = buffer.len + length
522
-
523
- Memory.decRef(WasmI32.fromGrain(start))
524
- Memory.decRef(WasmI32.fromGrain(length))
525
- Memory.decRef(WasmI32.fromGrain(bytes))
526
- Memory.decRef(WasmI32.fromGrain(buffer))
527
- Memory.decRef(WasmI32.fromGrain(addBytesSlice))
528
- void
529
368
  }
530
369
 
531
370
  /**
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>next</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