@grain/stdlib 0.5.13 → 0.6.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 (155) hide show
  1. package/CHANGELOG.md +193 -0
  2. package/LICENSE +1 -1
  3. package/README.md +25 -2
  4. package/array.gr +1512 -199
  5. package/array.md +2032 -94
  6. package/bigint.gr +239 -140
  7. package/bigint.md +450 -106
  8. package/buffer.gr +595 -102
  9. package/buffer.md +903 -145
  10. package/bytes.gr +401 -110
  11. package/bytes.md +551 -63
  12. package/char.gr +228 -49
  13. package/char.md +373 -7
  14. package/exception.gr +26 -12
  15. package/exception.md +29 -5
  16. package/float32.gr +130 -109
  17. package/float32.md +185 -57
  18. package/float64.gr +112 -99
  19. package/float64.md +185 -57
  20. package/hash.gr +47 -37
  21. package/hash.md +21 -3
  22. package/int16.gr +430 -0
  23. package/int16.md +618 -0
  24. package/int32.gr +200 -269
  25. package/int32.md +254 -289
  26. package/int64.gr +142 -225
  27. package/int64.md +254 -289
  28. package/int8.gr +511 -0
  29. package/int8.md +786 -0
  30. package/json.gr +2084 -0
  31. package/json.md +608 -0
  32. package/list.gr +120 -68
  33. package/list.md +125 -80
  34. package/map.gr +560 -57
  35. package/map.md +672 -56
  36. package/marshal.gr +239 -227
  37. package/marshal.md +36 -4
  38. package/number.gr +626 -676
  39. package/number.md +738 -153
  40. package/option.gr +33 -35
  41. package/option.md +58 -42
  42. package/package.json +2 -2
  43. package/path.gr +148 -187
  44. package/path.md +47 -96
  45. package/pervasives.gr +75 -416
  46. package/pervasives.md +85 -180
  47. package/priorityqueue.gr +433 -74
  48. package/priorityqueue.md +422 -54
  49. package/queue.gr +362 -80
  50. package/queue.md +433 -38
  51. package/random.gr +67 -75
  52. package/random.md +68 -40
  53. package/range.gr +135 -63
  54. package/range.md +198 -43
  55. package/rational.gr +284 -0
  56. package/rational.md +545 -0
  57. package/regex.gr +933 -1066
  58. package/regex.md +59 -60
  59. package/result.gr +23 -25
  60. package/result.md +54 -39
  61. package/runtime/atof/common.gr +78 -82
  62. package/runtime/atof/common.md +22 -10
  63. package/runtime/atof/decimal.gr +102 -127
  64. package/runtime/atof/decimal.md +28 -7
  65. package/runtime/atof/lemire.gr +56 -71
  66. package/runtime/atof/lemire.md +9 -1
  67. package/runtime/atof/parse.gr +83 -110
  68. package/runtime/atof/parse.md +12 -2
  69. package/runtime/atof/slow.gr +28 -35
  70. package/runtime/atof/slow.md +9 -1
  71. package/runtime/atof/table.gr +19 -18
  72. package/runtime/atof/table.md +10 -2
  73. package/runtime/atoi/parse.gr +153 -136
  74. package/runtime/atoi/parse.md +50 -1
  75. package/runtime/bigint.gr +410 -517
  76. package/runtime/bigint.md +71 -57
  77. package/runtime/compare.gr +176 -85
  78. package/runtime/compare.md +31 -1
  79. package/runtime/dataStructures.gr +144 -32
  80. package/runtime/dataStructures.md +267 -31
  81. package/runtime/debugPrint.gr +34 -15
  82. package/runtime/debugPrint.md +37 -5
  83. package/runtime/equal.gr +53 -52
  84. package/runtime/equal.md +30 -1
  85. package/runtime/exception.gr +38 -47
  86. package/runtime/exception.md +10 -8
  87. package/runtime/gc.gr +23 -152
  88. package/runtime/gc.md +13 -17
  89. package/runtime/malloc.gr +31 -31
  90. package/runtime/malloc.md +11 -3
  91. package/runtime/numberUtils.gr +191 -172
  92. package/runtime/numberUtils.md +17 -9
  93. package/runtime/numbers.gr +1695 -1021
  94. package/runtime/numbers.md +1098 -134
  95. package/runtime/string.gr +540 -242
  96. package/runtime/string.md +76 -6
  97. package/runtime/unsafe/constants.gr +30 -13
  98. package/runtime/unsafe/constants.md +80 -0
  99. package/runtime/unsafe/conv.gr +55 -28
  100. package/runtime/unsafe/conv.md +41 -9
  101. package/runtime/unsafe/memory.gr +10 -30
  102. package/runtime/unsafe/memory.md +15 -19
  103. package/runtime/unsafe/tags.gr +37 -21
  104. package/runtime/unsafe/tags.md +88 -8
  105. package/runtime/unsafe/wasmf32.gr +30 -36
  106. package/runtime/unsafe/wasmf32.md +64 -56
  107. package/runtime/unsafe/wasmf64.gr +30 -36
  108. package/runtime/unsafe/wasmf64.md +64 -56
  109. package/runtime/unsafe/wasmi32.gr +49 -66
  110. package/runtime/unsafe/wasmi32.md +102 -94
  111. package/runtime/unsafe/wasmi64.gr +52 -79
  112. package/runtime/unsafe/wasmi64.md +108 -100
  113. package/runtime/utils/printing.gr +13 -15
  114. package/runtime/utils/printing.md +11 -3
  115. package/runtime/wasi.gr +294 -295
  116. package/runtime/wasi.md +62 -42
  117. package/set.gr +574 -64
  118. package/set.md +634 -54
  119. package/stack.gr +181 -64
  120. package/stack.md +271 -42
  121. package/string.gr +453 -533
  122. package/string.md +241 -151
  123. package/uint16.gr +369 -0
  124. package/uint16.md +585 -0
  125. package/uint32.gr +470 -0
  126. package/uint32.md +737 -0
  127. package/uint64.gr +471 -0
  128. package/uint64.md +737 -0
  129. package/uint8.gr +369 -0
  130. package/uint8.md +585 -0
  131. package/uri.gr +1093 -0
  132. package/uri.md +477 -0
  133. package/{sys → wasi}/file.gr +914 -500
  134. package/{sys → wasi}/file.md +454 -50
  135. package/wasi/process.gr +292 -0
  136. package/{sys → wasi}/process.md +164 -6
  137. package/wasi/random.gr +77 -0
  138. package/wasi/random.md +80 -0
  139. package/{sys → wasi}/time.gr +15 -22
  140. package/{sys → wasi}/time.md +5 -5
  141. package/immutablearray.gr +0 -929
  142. package/immutablearray.md +0 -1038
  143. package/immutablemap.gr +0 -493
  144. package/immutablemap.md +0 -479
  145. package/immutablepriorityqueue.gr +0 -360
  146. package/immutablepriorityqueue.md +0 -291
  147. package/immutableset.gr +0 -498
  148. package/immutableset.md +0 -449
  149. package/runtime/debug.gr +0 -2
  150. package/runtime/debug.md +0 -6
  151. package/runtime/unsafe/errors.gr +0 -36
  152. package/runtime/unsafe/errors.md +0 -204
  153. package/sys/process.gr +0 -254
  154. package/sys/random.gr +0 -79
  155. package/sys/random.md +0 -66
package/string.md CHANGED
@@ -18,7 +18,7 @@ Utilities for working with strings.
18
18
  </details>
19
19
 
20
20
  ```grain
21
- import String from "string"
21
+ from "string" include String
22
22
  ```
23
23
 
24
24
  ## Types
@@ -41,7 +41,7 @@ Byte encodings
41
41
 
42
42
  ## Values
43
43
 
44
- Functions for working with the String data type.
44
+ Functions and constants included in the String module.
45
45
 
46
46
  ### String.**concat**
47
47
 
@@ -51,7 +51,7 @@ No other changes yet.
51
51
  </details>
52
52
 
53
53
  ```grain
54
- concat : (String, String) -> String
54
+ concat : (str1: String, str2: String) => String
55
55
  ```
56
56
 
57
57
  Concatenate two strings.
@@ -83,7 +83,7 @@ No other changes yet.
83
83
  </details>
84
84
 
85
85
  ```grain
86
- length : String -> Number
86
+ length : (string: String) => Number
87
87
  ```
88
88
 
89
89
  Returns the character length of the input string.
@@ -114,7 +114,7 @@ No other changes yet.
114
114
  </details>
115
115
 
116
116
  ```grain
117
- byteLength : String -> Number
117
+ byteLength : (string: String) => Number
118
118
  ```
119
119
 
120
120
  Returns the byte length of the input string.
@@ -137,6 +137,31 @@ Examples:
137
137
  String.byteLength("🌾") == 4
138
138
  ```
139
139
 
140
+ ### String.**isEmpty**
141
+
142
+ <details disabled>
143
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
144
+ No other changes yet.
145
+ </details>
146
+
147
+ ```grain
148
+ isEmpty : (string: String) => Bool
149
+ ```
150
+
151
+ Determines if the string contains no characters.
152
+
153
+ Parameters:
154
+
155
+ |param|type|description|
156
+ |-----|----|-----------|
157
+ |`string`|`String`|The string to inspect|
158
+
159
+ Returns:
160
+
161
+ |type|description|
162
+ |----|-----------|
163
+ |`Bool`|`true` if the string is empty and `false` otherwise|
164
+
140
165
  ### String.**indexOf**
141
166
 
142
167
  <details disabled>
@@ -145,7 +170,7 @@ No other changes yet.
145
170
  </details>
146
171
 
147
172
  ```grain
148
- indexOf : (String, String) -> Option<Number>
173
+ indexOf : (search: String, string: String) => Option<Number>
149
174
  ```
150
175
 
151
176
  Finds the first position of a substring in the input string.
@@ -177,7 +202,7 @@ No other changes yet.
177
202
  </details>
178
203
 
179
204
  ```grain
180
- lastIndexOf : (String, String) -> Option<Number>
205
+ lastIndexOf : (search: String, string: String) => Option<Number>
181
206
  ```
182
207
 
183
208
  Finds the last position of a substring in the input string.
@@ -209,7 +234,7 @@ No other changes yet.
209
234
  </details>
210
235
 
211
236
  ```grain
212
- charCodeAt : (Number, String) -> Number
237
+ charCodeAt : (position: Number, string: String) => Number
213
238
  ```
214
239
 
215
240
  Get the Unicode code point at the position in the input string.
@@ -227,6 +252,16 @@ Returns:
227
252
  |----|-----------|
228
253
  |`Number`|The character code at the provided position|
229
254
 
255
+ Throws:
256
+
257
+ `Failure(String)`
258
+
259
+ * When the `position` is out of bounds
260
+
261
+ `MalformedUnicode`
262
+
263
+ * When the `string` is malformed
264
+
230
265
  Examples:
231
266
 
232
267
  ```grain
@@ -241,7 +276,7 @@ No other changes yet.
241
276
  </details>
242
277
 
243
278
  ```grain
244
- charAt : (Number, String) -> Char
279
+ charAt : (position: Number, string: String) => Char
245
280
  ```
246
281
 
247
282
  Get the character at the position in the input string.
@@ -259,6 +294,16 @@ Returns:
259
294
  |----|-----------|
260
295
  |`Char`|The character at the provided position|
261
296
 
297
+ Throws:
298
+
299
+ `Failure(String)`
300
+
301
+ * When the `position` is out of bounds
302
+
303
+ `MalformedUnicode`
304
+
305
+ * When the `string` is malformed
306
+
262
307
  Examples:
263
308
 
264
309
  ```grain
@@ -273,7 +318,7 @@ No other changes yet.
273
318
  </details>
274
319
 
275
320
  ```grain
276
- explode : String -> Array<Char>
321
+ explode : (string: String) => Array<Char>
277
322
  ```
278
323
 
279
324
  Split a string into its Unicode characters.
@@ -290,6 +335,12 @@ Returns:
290
335
  |----|-----------|
291
336
  |`Array<Char>`|An array containing all characters in the string|
292
337
 
338
+ Throws:
339
+
340
+ `MalformedUnicode`
341
+
342
+ * When the `string` is malformed
343
+
293
344
  Examples:
294
345
 
295
346
  ```grain
@@ -304,7 +355,7 @@ No other changes yet.
304
355
  </details>
305
356
 
306
357
  ```grain
307
- implode : Array<Char> -> String
358
+ implode : (arr: Array<Char>) => String
308
359
  ```
309
360
 
310
361
  Create a string from an array of characters.
@@ -335,7 +386,7 @@ No other changes yet.
335
386
  </details>
336
387
 
337
388
  ```grain
338
- reverse : String -> String
389
+ reverse : (string: String) => String
339
390
  ```
340
391
 
341
392
  Create a string that is the given string reversed.
@@ -361,7 +412,7 @@ String.reverse("olleH") == "Hello"
361
412
  ### String.**split**
362
413
 
363
414
  ```grain
364
- split : (String, String) -> Array<String>
415
+ split : (separator: String, string: String) => Array<String>
365
416
  ```
366
417
 
367
418
  Split a string by the given separator.
@@ -379,6 +430,12 @@ Returns:
379
430
  |----|-----------|
380
431
  |`Array<String>`|An array of substrings from the initial string|
381
432
 
433
+ Throws:
434
+
435
+ `MalformedUnicode`
436
+
437
+ * When the `string` is malformed
438
+
382
439
  Examples:
383
440
 
384
441
  ```grain
@@ -387,13 +444,20 @@ String.split(" ", "Hello world") == [> "Hello", "world"]
387
444
 
388
445
  ### String.**slice**
389
446
 
390
- <details disabled>
391
- <summary tabindex="-1">Added in <code>0.1.0</code></summary>
392
- No other changes yet.
447
+ <details>
448
+ <summary>Added in <code>0.1.0</code></summary>
449
+ <table>
450
+ <thead>
451
+ <tr><th>version</th><th>changes</th></tr>
452
+ </thead>
453
+ <tbody>
454
+ <tr><td><code>0.6.0</code></td><td>Default `end` to the String length</td></tr>
455
+ </tbody>
456
+ </table>
393
457
  </details>
394
458
 
395
459
  ```grain
396
- slice : (Number, Number, String) -> String
460
+ slice : (start: Number, ?end: Number, string: String) => String
397
461
  ```
398
462
 
399
463
  Get a portion of a string.
@@ -403,7 +467,7 @@ Parameters:
403
467
  |param|type|description|
404
468
  |-----|----|-----------|
405
469
  |`start`|`Number`|The start position of the substring|
406
- |`to`|`Number`|The end position of the substring, exclusive|
470
+ |`?end`|`Number`|The end position of the substring, exclusive|
407
471
  |`string`|`String`|The input string|
408
472
 
409
473
  Returns:
@@ -412,10 +476,27 @@ Returns:
412
476
  |----|-----------|
413
477
  |`String`|The substring from the initial string|
414
478
 
479
+ Throws:
480
+
481
+ `IndexOutOfBounds`
482
+
483
+ * When `start` is out of bounds
484
+ * When `end` is out of bounds
485
+
486
+ `InvalidArgument(String)`
487
+
488
+ * When the `start` index is not an integer
489
+ * When the `to` index is not an integer
490
+ * When `start` is greater than `end`
491
+
415
492
  Examples:
416
493
 
417
494
  ```grain
418
- String.slice(0, 5, "Hello world") == "Hello"
495
+ String.slice(0, end=5, "Hello world") == "Hello"
496
+ ```
497
+
498
+ ```grain
499
+ String.slice(0, "Hello world") == "Hello world"
419
500
  ```
420
501
 
421
502
  ### String.**contains**
@@ -426,7 +507,7 @@ No other changes yet.
426
507
  </details>
427
508
 
428
509
  ```grain
429
- contains : (String, String) -> Bool
510
+ contains : (search: String, string: String) => Bool
430
511
  ```
431
512
 
432
513
  Check if a string contains a substring.
@@ -458,7 +539,7 @@ No other changes yet.
458
539
  </details>
459
540
 
460
541
  ```grain
461
- startsWith : (String, String) -> Bool
542
+ startsWith : (search: String, string: String) => Bool
462
543
  ```
463
544
 
464
545
  Check if a string begins with another string.
@@ -490,7 +571,7 @@ No other changes yet.
490
571
  </details>
491
572
 
492
573
  ```grain
493
- endsWith : (String, String) -> Bool
574
+ endsWith : (search: String, string: String) => Bool
494
575
  ```
495
576
 
496
577
  Check if a string ends with another string.
@@ -522,7 +603,8 @@ No other changes yet.
522
603
  </details>
523
604
 
524
605
  ```grain
525
- replaceFirst : (String, String, String) -> String
606
+ replaceFirst :
607
+ (searchPattern: String, replacement: String, string: String) => String
526
608
  ```
527
609
 
528
610
  Replaces the first appearance of the search pattern in the string with the replacement value.
@@ -555,7 +637,8 @@ No other changes yet.
555
637
  </details>
556
638
 
557
639
  ```grain
558
- replaceLast : (String, String, String) -> String
640
+ replaceLast :
641
+ (searchPattern: String, replacement: String, string: String) => String
559
642
  ```
560
643
 
561
644
  Replaces the last appearance of the search pattern in the string with the replacement value.
@@ -588,7 +671,8 @@ No other changes yet.
588
671
  </details>
589
672
 
590
673
  ```grain
591
- replaceAll : (String, String, String) -> String
674
+ replaceAll :
675
+ (searchPattern: String, replacement: String, string: String) => String
592
676
  ```
593
677
 
594
678
  Replaces every appearance of the search pattern in the string with the replacement value.
@@ -615,16 +699,25 @@ String.replaceAll("🌾", "🌎", "Hello 🌾🌾") == "Hello 🌎🌎"
615
699
 
616
700
  ### String.**encodeAt**
617
701
 
618
- <details disabled>
619
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
620
- No other changes yet.
702
+ <details>
703
+ <summary>Added in <code>0.4.0</code></summary>
704
+ <table>
705
+ <thead>
706
+ <tr><th>version</th><th>changes</th></tr>
707
+ </thead>
708
+ <tbody>
709
+ <tr><td><code>0.6.0</code></td><td>Added `includeBom` default argument</td></tr>
710
+ </tbody>
711
+ </table>
621
712
  </details>
622
713
 
623
714
  ```grain
624
- encodeAt : (String, Encoding, Bytes, Number) -> Bytes
715
+ encodeAt :
716
+ (string: String, encoding: Encoding, dest: Bytes, destPos: Number,
717
+ ?includeBom: Bool) => Bytes
625
718
  ```
626
719
 
627
- Encodes the given string into a byte sequence at the supplied position, excluding any byte-order marker, using the encoding scheme provided.
720
+ Encodes the given string into a byte sequence at the supplied position using the encoding scheme provided.
628
721
 
629
722
  Parameters:
630
723
 
@@ -634,6 +727,7 @@ Parameters:
634
727
  |`encoding`|`Encoding`|The encoding to use|
635
728
  |`dest`|`Bytes`|The byte sequence that will be copied|
636
729
  |`destPos`|`Number`|The location in the byte sequence to write the output|
730
+ |`?includeBom`|`Bool`|Whether or not to include a byte order marker (false by default)|
637
731
 
638
732
  Returns:
639
733
 
@@ -641,72 +735,32 @@ Returns:
641
735
  |----|-----------|
642
736
  |`Bytes`|A copy of the input bytes with the encoded string replaced at the given position|
643
737
 
644
- ### String.**encodeAtWithBom**
738
+ Throws:
645
739
 
646
- <details disabled>
647
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
648
- No other changes yet.
649
- </details>
650
-
651
- ```grain
652
- encodeAtWithBom : (String, Encoding, Bytes, Number) -> Bytes
653
- ```
740
+ `InvalidArgument(String)`
654
741
 
655
- Encodes the given string into a byte sequence at the supplied position, including any byte-order marker, using the encoding scheme provided.
656
-
657
- Parameters:
658
-
659
- |param|type|description|
660
- |-----|----|-----------|
661
- |`string`|`String`|The input string|
662
- |`encoding`|`Encoding`|The encoding to use|
663
- |`dest`|`Bytes`|The byte sequence that will be copied|
664
- |`destPos`|`Number`|The location in the byte sequence to write the output|
665
-
666
- Returns:
667
-
668
- |type|description|
669
- |----|-----------|
670
- |`Bytes`|A copy of the input bytes with the encoded string replaced at the given position|
742
+ * When `destPos` is not an integer
743
+ * When `destPos` is negative
671
744
 
672
745
  ### String.**encode**
673
746
 
674
- <details disabled>
675
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
676
- No other changes yet.
677
- </details>
678
-
679
- ```grain
680
- encode : (String, Encoding) -> Bytes
681
- ```
682
-
683
- Encodes the given string using the given encoding scheme, excluding any byte-order marker.
684
-
685
- Parameters:
686
-
687
- |param|type|description|
688
- |-----|----|-----------|
689
- |`string`|`String`|The input string|
690
- |`encoding`|`Encoding`|The encoding to use|
691
-
692
- Returns:
693
-
694
- |type|description|
695
- |----|-----------|
696
- |`Bytes`|The byte representation of the string in the given encoding|
697
-
698
- ### String.**encodeWithBom**
699
-
700
- <details disabled>
701
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
702
- No other changes yet.
747
+ <details>
748
+ <summary>Added in <code>0.4.0</code></summary>
749
+ <table>
750
+ <thead>
751
+ <tr><th>version</th><th>changes</th></tr>
752
+ </thead>
753
+ <tbody>
754
+ <tr><td><code>0.6.0</code></td><td>Added `includeBom` default argument</td></tr>
755
+ </tbody>
756
+ </table>
703
757
  </details>
704
758
 
705
759
  ```grain
706
- encodeWithBom : (String, Encoding) -> Bytes
760
+ encode : (string: String, encoding: Encoding, ?includeBom: Bool) => Bytes
707
761
  ```
708
762
 
709
- Encodes the given string using the given encoding scheme, including any byte-order marker.
763
+ Encodes the given string using the given encoding scheme.
710
764
 
711
765
  Parameters:
712
766
 
@@ -714,6 +768,7 @@ Parameters:
714
768
  |-----|----|-----------|
715
769
  |`string`|`String`|The input string|
716
770
  |`encoding`|`Encoding`|The encoding to use|
771
+ |`?includeBom`|`Bool`|Whether or not to include a byte order marker (false by default)|
717
772
 
718
773
  Returns:
719
774
 
@@ -723,16 +778,25 @@ Returns:
723
778
 
724
779
  ### String.**decodeRange**
725
780
 
726
- <details disabled>
727
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
728
- No other changes yet.
781
+ <details>
782
+ <summary>Added in <code>0.4.0</code></summary>
783
+ <table>
784
+ <thead>
785
+ <tr><th>version</th><th>changes</th></tr>
786
+ </thead>
787
+ <tbody>
788
+ <tr><td><code>0.6.0</code></td><td>Added `keepBom` default argument</td></tr>
789
+ </tbody>
790
+ </table>
729
791
  </details>
730
792
 
731
793
  ```grain
732
- decodeRange : (Bytes, Encoding, Number, Number) -> String
794
+ decodeRange :
795
+ (bytes: Bytes, encoding: Encoding, start: Number, size: Number,
796
+ ?keepBom: Bool) => String
733
797
  ```
734
798
 
735
- Decodes the given byte sequence of the specified range into a string, excluding any byte-order marker, using encoding scheme provided.
799
+ Decodes the given byte sequence of the specified range into a string using the encoding scheme provided.
736
800
 
737
801
  Parameters:
738
802
 
@@ -742,6 +806,7 @@ Parameters:
742
806
  |`encoding`|`Encoding`|The encoding to use|
743
807
  |`start`|`Number`|The byte offset to begin decoding from|
744
808
  |`size`|`Number`|The maximum number of bytes to decode|
809
+ |`?keepBom`|`Bool`|Whether or not to include a byte order marker (false by default)|
745
810
 
746
811
  Returns:
747
812
 
@@ -749,18 +814,34 @@ Returns:
749
814
  |----|-----------|
750
815
  |`String`|The decoded string|
751
816
 
752
- ### String.**decodeRangeKeepBom**
817
+ Throws:
753
818
 
754
- <details disabled>
755
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
756
- No other changes yet.
819
+ `InvalidArgument(String)`
820
+
821
+ * When `start` is not an integer
822
+ * When `start` is negative
823
+ * When `size` is not an integer
824
+ * When `size` is negative
825
+
826
+ ### String.**decode**
827
+
828
+ <details>
829
+ <summary>Added in <code>0.4.0</code></summary>
830
+ <table>
831
+ <thead>
832
+ <tr><th>version</th><th>changes</th></tr>
833
+ </thead>
834
+ <tbody>
835
+ <tr><td><code>0.6.0</code></td><td>Added `keepBom` default argument</td></tr>
836
+ </tbody>
837
+ </table>
757
838
  </details>
758
839
 
759
840
  ```grain
760
- decodeRangeKeepBom : (Bytes, Encoding, Number, Number) -> String
841
+ decode : (bytes: Bytes, encoding: Encoding, ?keepBom: Bool) => String
761
842
  ```
762
843
 
763
- Decodes the given byte sequence of the specified range into a string, including any byte-order marker, using encoding scheme provided.
844
+ Decodes the given byte sequence into a string using the given encoding scheme.
764
845
 
765
846
  Parameters:
766
847
 
@@ -768,8 +849,7 @@ Parameters:
768
849
  |-----|----|-----------|
769
850
  |`bytes`|`Bytes`|The input bytes|
770
851
  |`encoding`|`Encoding`|The encoding to use|
771
- |`start`|`Number`|The byte offset to begin decoding from|
772
- |`size`|`Number`|The maximum number of bytes to decode|
852
+ |`?keepBom`|`Bool`|Whether or not to include a byte order marker (false by default)|
773
853
 
774
854
  Returns:
775
855
 
@@ -777,7 +857,7 @@ Returns:
777
857
  |----|-----------|
778
858
  |`String`|The decoded string|
779
859
 
780
- ### String.**decode**
860
+ ### String.**forEachCodePoint**
781
861
 
782
862
  <details disabled>
783
863
  <summary tabindex="-1">Added in <code>0.4.0</code></summary>
@@ -785,25 +865,25 @@ No other changes yet.
785
865
  </details>
786
866
 
787
867
  ```grain
788
- decode : (Bytes, Encoding) -> String
868
+ forEachCodePoint : (fn: (Number => Void), str: String) => Void
789
869
  ```
790
870
 
791
- Decodes the given byte sequence into a string using the given encoding scheme, excluding any byte-order marker.
871
+ Iterates over Unicode code points in a string.
792
872
 
793
873
  Parameters:
794
874
 
795
875
  |param|type|description|
796
876
  |-----|----|-----------|
797
- |`bytes`|`Bytes`|The input bytes|
798
- |`encoding`|`Encoding`|The encoding to use|
877
+ |`fn`|`Number => Void`|The iterator function|
878
+ |`str`|`String`|The string to iterate|
799
879
 
800
- Returns:
880
+ Examples:
801
881
 
802
- |type|description|
803
- |----|-----------|
804
- |`String`|The decoded string|
882
+ ```grain
883
+ String.forEachCodePoint(print, "Hello world")
884
+ ```
805
885
 
806
- ### String.**decodeKeepBom**
886
+ ### String.**forEachCodePointi**
807
887
 
808
888
  <details disabled>
809
889
  <summary tabindex="-1">Added in <code>0.4.0</code></summary>
@@ -811,79 +891,89 @@ No other changes yet.
811
891
  </details>
812
892
 
813
893
  ```grain
814
- decodeKeepBom : (Bytes, Encoding) -> String
894
+ forEachCodePointi : (fn: ((Number, Number) => Void), str: String) => Void
815
895
  ```
816
896
 
817
- Decodes the given byte sequence into a string using the given encoding scheme, including any byte-order marker.
897
+ Iterates over Unicode code points in a string. This is the same as
898
+ `forEachCodePoint`, but provides the code point's index in the string
899
+ as the second argument to the iterator function.
818
900
 
819
901
  Parameters:
820
902
 
821
903
  |param|type|description|
822
904
  |-----|----|-----------|
823
- |`bytes`|`Bytes`|The input bytes|
824
- |`encoding`|`Encoding`|The encoding to use|
905
+ |`fn`|`(Number, Number) => Void`|The iterator function|
906
+ |`str`|`String`|The string to iterate|
825
907
 
826
- Returns:
908
+ Examples:
827
909
 
828
- |type|description|
829
- |----|-----------|
830
- |`String`|The decoded string|
910
+ ```grain
911
+ String.forEachCodePointi((codepoint, index) => print((codepoint, index)), "Hello world")
912
+ ```
831
913
 
832
- ### String.**forEachCodePoint**
914
+ ### String.**trimStart**
833
915
 
834
916
  <details disabled>
835
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
917
+ <summary tabindex="-1">Added in <code>0.4.2</code></summary>
836
918
  No other changes yet.
837
919
  </details>
838
920
 
839
921
  ```grain
840
- forEachCodePoint : ((Number -> Void), String) -> Void
922
+ trimStart : (string: String) => String
841
923
  ```
842
924
 
843
- Iterates over Unicode code points in a string.
925
+ Trims the beginning of a string—removing any leading whitespace characters.
844
926
 
845
927
  Parameters:
846
928
 
847
929
  |param|type|description|
848
930
  |-----|----|-----------|
849
- |`fn`|`Number -> Void`|The iterator function|
850
- |`str`|`String`|The string to iterate|
931
+ |`string`|`String`|The string to be trimmed|
932
+
933
+ Returns:
934
+
935
+ |type|description|
936
+ |----|-----------|
937
+ |`String`|The trimmed string|
851
938
 
852
939
  Examples:
853
940
 
854
941
  ```grain
855
- String.forEachCodePoint(print, "Hello world")
942
+ String.trimStart(" Hello World") == "Hello World"
856
943
  ```
857
944
 
858
- ### String.**forEachCodePointi**
945
+ ### String.**trimEnd**
859
946
 
860
947
  <details disabled>
861
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
948
+ <summary tabindex="-1">Added in <code>0.4.2</code></summary>
862
949
  No other changes yet.
863
950
  </details>
864
951
 
865
952
  ```grain
866
- forEachCodePointi : (((Number, Number) -> Void), String) -> Void
953
+ trimEnd : (string: String) => String
867
954
  ```
868
955
 
869
- Iterates over Unicode code points in a string. This is the same as
870
- `forEachCodePoint`, but provides the code point's index in the string
871
- as the second argument to the iterator function.
956
+ Trims the end of a string—removing any trailing whitespace characters.
872
957
 
873
958
  Parameters:
874
959
 
875
960
  |param|type|description|
876
961
  |-----|----|-----------|
877
- |`fn`|`(Number, Number) -> Void`|The iterator function|
878
- |`str`|`String`|The string to iterate|
962
+ |`string`|`String`|The string to be trimmed|
963
+
964
+ Returns:
965
+
966
+ |type|description|
967
+ |----|-----------|
968
+ |`String`|The trimmed string|
879
969
 
880
970
  Examples:
881
971
 
882
972
  ```grain
883
- String.forEachCodePointi((codepoint, index) => print((codepoint, index)), "Hello world")
973
+ String.trimEnd("Hello World ") == "Hello World"
884
974
  ```
885
975
 
886
- ### String.**trimStart**
976
+ ### String.**trim**
887
977
 
888
978
  <details disabled>
889
979
  <summary tabindex="-1">Added in <code>0.4.2</code></summary>
@@ -891,10 +981,10 @@ No other changes yet.
891
981
  </details>
892
982
 
893
983
  ```grain
894
- trimStart : String -> String
984
+ trim : (string: String) => String
895
985
  ```
896
986
 
897
- Trims the beginning of a string—removing any leading whitespace characters.
987
+ Trims a string—removing all leading and trailing whitespace characters.
898
988
 
899
989
  Parameters:
900
990
 
@@ -911,68 +1001,68 @@ Returns:
911
1001
  Examples:
912
1002
 
913
1003
  ```grain
914
- String.trimStart(" Hello World") == "Hello World"
1004
+ String.trim(" Hello World ") == "Hello World"
915
1005
  ```
916
1006
 
917
- ### String.**trimEnd**
1007
+ ### String.**toAsciiLowercase**
918
1008
 
919
1009
  <details disabled>
920
- <summary tabindex="-1">Added in <code>0.4.2</code></summary>
1010
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
921
1011
  No other changes yet.
922
1012
  </details>
923
1013
 
924
1014
  ```grain
925
- trimEnd : String -> String
1015
+ toAsciiLowercase : (string: String) => String
926
1016
  ```
927
1017
 
928
- Trims the end of a string—removing any trailing whitespace characters.
1018
+ Converts all ASCII uppercase characters in the string to lowercase.
929
1019
 
930
1020
  Parameters:
931
1021
 
932
1022
  |param|type|description|
933
1023
  |-----|----|-----------|
934
- |`string`|`String`|The string to be trimmed|
1024
+ |`string`|`String`|The string to convert|
935
1025
 
936
1026
  Returns:
937
1027
 
938
1028
  |type|description|
939
1029
  |----|-----------|
940
- |`String`|The trimmed string|
1030
+ |`String`|The lowercased string|
941
1031
 
942
1032
  Examples:
943
1033
 
944
1034
  ```grain
945
- String.trimEnd("Hello World ") == "Hello World"
1035
+ assert String.toAsciiLowercase("aBc123") == "abc123"
946
1036
  ```
947
1037
 
948
- ### String.**trim**
1038
+ ### String.**toAsciiUppercase**
949
1039
 
950
1040
  <details disabled>
951
- <summary tabindex="-1">Added in <code>0.4.2</code></summary>
1041
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
952
1042
  No other changes yet.
953
1043
  </details>
954
1044
 
955
1045
  ```grain
956
- trim : String -> String
1046
+ toAsciiUppercase : (string: String) => String
957
1047
  ```
958
1048
 
959
- Trims a string—removing all leading and trailing whitespace characters.
1049
+ Converts all ASCII lowercase characters in the string to uppercase.
960
1050
 
961
1051
  Parameters:
962
1052
 
963
1053
  |param|type|description|
964
1054
  |-----|----|-----------|
965
- |`string`|`String`|The string to be trimmed|
1055
+ |`string`|`String`|The string to convert|
966
1056
 
967
1057
  Returns:
968
1058
 
969
1059
  |type|description|
970
1060
  |----|-----------|
971
- |`String`|The trimmed string|
1061
+ |`String`|The uppercased string|
972
1062
 
973
1063
  Examples:
974
1064
 
975
1065
  ```grain
976
- String.trim(" Hello World ") == "Hello World"
1066
+ assert String.toAsciiUppercase("aBc123") == "ABC123"
977
1067
  ```
978
1068