@grain/stdlib 0.6.6 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/LICENSE +1 -1
  3. package/README.md +2 -2
  4. package/array.gr +55 -7
  5. package/array.md +606 -560
  6. package/bigint.md +228 -228
  7. package/buffer.gr +85 -53
  8. package/buffer.md +442 -319
  9. package/bytes.gr +112 -35
  10. package/bytes.md +299 -219
  11. package/char.gr +201 -99
  12. package/char.md +447 -120
  13. package/exception.gr +11 -11
  14. package/exception.md +29 -4
  15. package/float32.gr +327 -3
  16. package/float32.md +698 -111
  17. package/float64.gr +320 -3
  18. package/float64.md +698 -111
  19. package/fs.gr +1082 -0
  20. package/fs.md +630 -0
  21. package/hash.gr +142 -88
  22. package/hash.md +105 -17
  23. package/int16.md +178 -178
  24. package/int32.gr +26 -5
  25. package/int32.md +266 -231
  26. package/int64.gr +27 -2
  27. package/int64.md +266 -231
  28. package/int8.md +178 -178
  29. package/json.gr +366 -51
  30. package/json.md +431 -15
  31. package/list.gr +328 -31
  32. package/list.md +759 -336
  33. package/map.gr +20 -12
  34. package/map.md +266 -260
  35. package/marshal.gr +41 -40
  36. package/marshal.md +14 -14
  37. package/number.gr +278 -35
  38. package/number.md +688 -269
  39. package/option.md +162 -162
  40. package/package.json +5 -3
  41. package/path.gr +48 -0
  42. package/path.md +180 -89
  43. package/pervasives.gr +2 -2
  44. package/pervasives.md +275 -275
  45. package/priorityqueue.gr +7 -7
  46. package/priorityqueue.md +131 -131
  47. package/queue.gr +183 -29
  48. package/queue.md +404 -148
  49. package/random.md +43 -43
  50. package/range.gr +4 -4
  51. package/range.md +42 -42
  52. package/rational.md +123 -123
  53. package/regex.gr +52 -51
  54. package/regex.md +102 -102
  55. package/result.md +118 -118
  56. package/runtime/atof/common.md +39 -39
  57. package/runtime/atof/decimal.gr +6 -6
  58. package/runtime/atof/decimal.md +14 -14
  59. package/runtime/atof/lemire.gr +5 -5
  60. package/runtime/atof/lemire.md +1 -1
  61. package/runtime/atof/parse.gr +16 -16
  62. package/runtime/atof/parse.md +2 -2
  63. package/runtime/atof/slow.md +1 -1
  64. package/runtime/atof/table.md +2 -2
  65. package/runtime/atoi/parse.gr +3 -3
  66. package/runtime/atoi/parse.md +1 -1
  67. package/runtime/bigint.gr +15 -47
  68. package/runtime/bigint.md +54 -60
  69. package/runtime/compare.gr +2 -2
  70. package/runtime/compare.md +8 -8
  71. package/runtime/dataStructures.md +211 -211
  72. package/runtime/debugPrint.gr +4 -1
  73. package/runtime/debugPrint.md +9 -9
  74. package/runtime/equal.gr +99 -77
  75. package/runtime/equal.md +8 -8
  76. package/runtime/exception.gr +62 -82
  77. package/runtime/exception.md +62 -11
  78. package/runtime/gc.gr +39 -45
  79. package/runtime/gc.md +4 -4
  80. package/runtime/malloc.gr +7 -7
  81. package/runtime/malloc.md +13 -13
  82. package/runtime/math/kernel/cos.gr +70 -0
  83. package/runtime/math/kernel/cos.md +14 -0
  84. package/runtime/math/kernel/sin.gr +65 -0
  85. package/runtime/math/kernel/sin.md +14 -0
  86. package/runtime/math/kernel/tan.gr +136 -0
  87. package/runtime/math/kernel/tan.md +14 -0
  88. package/runtime/math/rempio2.gr +244 -0
  89. package/runtime/math/rempio2.md +14 -0
  90. package/runtime/math/trig.gr +130 -0
  91. package/runtime/math/trig.md +28 -0
  92. package/runtime/math/umuldi.gr +26 -0
  93. package/runtime/math/umuldi.md +14 -0
  94. package/runtime/numberUtils.gr +29 -29
  95. package/runtime/numberUtils.md +12 -12
  96. package/runtime/numbers.gr +373 -381
  97. package/runtime/numbers.md +348 -342
  98. package/runtime/string.gr +37 -105
  99. package/runtime/string.md +20 -26
  100. package/runtime/unsafe/constants.md +24 -24
  101. package/runtime/unsafe/conv.md +19 -19
  102. package/runtime/unsafe/memory.gr +24 -20
  103. package/runtime/unsafe/memory.md +27 -7
  104. package/runtime/unsafe/offsets.gr +36 -0
  105. package/runtime/unsafe/offsets.md +88 -0
  106. package/runtime/unsafe/panic.gr +28 -0
  107. package/runtime/unsafe/panic.md +14 -0
  108. package/runtime/unsafe/tags.md +32 -32
  109. package/runtime/unsafe/wasmf32.md +28 -28
  110. package/runtime/unsafe/wasmf64.md +28 -28
  111. package/runtime/unsafe/wasmi32.md +47 -47
  112. package/runtime/unsafe/wasmi64.md +50 -50
  113. package/runtime/utf8.gr +189 -0
  114. package/runtime/utf8.md +117 -0
  115. package/runtime/wasi.gr +4 -2
  116. package/runtime/wasi.md +147 -147
  117. package/set.gr +18 -11
  118. package/set.md +253 -247
  119. package/stack.gr +171 -2
  120. package/stack.md +371 -89
  121. package/string.gr +352 -557
  122. package/string.md +298 -255
  123. package/uint16.md +170 -170
  124. package/uint32.gr +25 -4
  125. package/uint32.md +249 -214
  126. package/uint64.gr +25 -5
  127. package/uint64.md +249 -214
  128. package/uint8.md +170 -170
  129. package/uri.gr +57 -53
  130. package/uri.md +88 -89
  131. package/wasi/file.gr +67 -59
  132. package/wasi/file.md +308 -308
  133. package/wasi/process.md +26 -26
  134. package/wasi/random.md +12 -12
  135. package/wasi/time.md +16 -16
  136. package/runtime/utils/printing.gr +0 -60
  137. package/runtime/utils/printing.md +0 -26
package/string.md CHANGED
@@ -51,23 +51,23 @@ No other changes yet.
51
51
  </details>
52
52
 
53
53
  ```grain
54
- concat : (str1: String, str2: String) => String
54
+ concat: (str1: String, str2: String) => String
55
55
  ```
56
56
 
57
57
  Concatenate two strings.
58
58
 
59
59
  Parameters:
60
60
 
61
- |param|type|description|
62
- |-----|----|-----------|
63
- |`str1`|`String`|The beginning string|
64
- |`str2`|`String`|The ending string|
61
+ | param | type | description |
62
+ | ------ | -------- | -------------------- |
63
+ | `str1` | `String` | The beginning string |
64
+ | `str2` | `String` | The ending string |
65
65
 
66
66
  Returns:
67
67
 
68
- |type|description|
69
- |----|-----------|
70
- |`String`|The combined string|
68
+ | type | description |
69
+ | -------- | ------------------- |
70
+ | `String` | The combined string |
71
71
 
72
72
  Examples:
73
73
 
@@ -83,22 +83,22 @@ No other changes yet.
83
83
  </details>
84
84
 
85
85
  ```grain
86
- length : (string: String) => Number
86
+ length: (string: String) => Number
87
87
  ```
88
88
 
89
89
  Returns the character length of the input string.
90
90
 
91
91
  Parameters:
92
92
 
93
- |param|type|description|
94
- |-----|----|-----------|
95
- |`string`|`String`|The string to inspect|
93
+ | param | type | description |
94
+ | -------- | -------- | --------------------- |
95
+ | `string` | `String` | The string to inspect |
96
96
 
97
97
  Returns:
98
98
 
99
- |type|description|
100
- |----|-----------|
101
- |`Number`|The number of characters in the string|
99
+ | type | description |
100
+ | -------- | -------------------------------------- |
101
+ | `Number` | The number of characters in the string |
102
102
 
103
103
  Examples:
104
104
 
@@ -114,22 +114,22 @@ No other changes yet.
114
114
  </details>
115
115
 
116
116
  ```grain
117
- byteLength : (string: String) => Number
117
+ byteLength: (string: String) => Number
118
118
  ```
119
119
 
120
120
  Returns the byte length of the input string.
121
121
 
122
122
  Parameters:
123
123
 
124
- |param|type|description|
125
- |-----|----|-----------|
126
- |`string`|`String`|The string to inspect|
124
+ | param | type | description |
125
+ | -------- | -------- | --------------------- |
126
+ | `string` | `String` | The string to inspect |
127
127
 
128
128
  Returns:
129
129
 
130
- |type|description|
131
- |----|-----------|
132
- |`Number`|The number of bytes in the string|
130
+ | type | description |
131
+ | -------- | --------------------------------- |
132
+ | `Number` | The number of bytes in the string |
133
133
 
134
134
  Examples:
135
135
 
@@ -145,22 +145,22 @@ No other changes yet.
145
145
  </details>
146
146
 
147
147
  ```grain
148
- isEmpty : (string: String) => Bool
148
+ isEmpty: (string: String) => Bool
149
149
  ```
150
150
 
151
151
  Determines if the string contains no characters.
152
152
 
153
153
  Parameters:
154
154
 
155
- |param|type|description|
156
- |-----|----|-----------|
157
- |`string`|`String`|The string to inspect|
155
+ | param | type | description |
156
+ | -------- | -------- | --------------------- |
157
+ | `string` | `String` | The string to inspect |
158
158
 
159
159
  Returns:
160
160
 
161
- |type|description|
162
- |----|-----------|
163
- |`Bool`|`true` if the string is empty and `false` otherwise|
161
+ | type | description |
162
+ | ------ | --------------------------------------------------- |
163
+ | `Bool` | `true` if the string is empty and `false` otherwise |
164
164
 
165
165
  ### String.**indexOf**
166
166
 
@@ -170,23 +170,23 @@ No other changes yet.
170
170
  </details>
171
171
 
172
172
  ```grain
173
- indexOf : (search: String, string: String) => Option<Number>
173
+ indexOf: (search: String, string: String) => Option<Number>
174
174
  ```
175
175
 
176
176
  Finds the first position of a substring in the input string.
177
177
 
178
178
  Parameters:
179
179
 
180
- |param|type|description|
181
- |-----|----|-----------|
182
- |`search`|`String`|The substring to find|
183
- |`string`|`String`|The string to inspect|
180
+ | param | type | description |
181
+ | -------- | -------- | --------------------- |
182
+ | `search` | `String` | The substring to find |
183
+ | `string` | `String` | The string to inspect |
184
184
 
185
185
  Returns:
186
186
 
187
- |type|description|
188
- |----|-----------|
189
- |`Option<Number>`|`Some(position)` containing the starting position of the substring if found or `None` otherwise|
187
+ | type | description |
188
+ | ---------------- | ----------------------------------------------------------------------------------------------- |
189
+ | `Option<Number>` | `Some(position)` containing the starting position of the substring if found or `None` otherwise |
190
190
 
191
191
  Examples:
192
192
 
@@ -202,23 +202,23 @@ No other changes yet.
202
202
  </details>
203
203
 
204
204
  ```grain
205
- lastIndexOf : (search: String, string: String) => Option<Number>
205
+ lastIndexOf: (search: String, string: String) => Option<Number>
206
206
  ```
207
207
 
208
208
  Finds the last position of a substring in the input string.
209
209
 
210
210
  Parameters:
211
211
 
212
- |param|type|description|
213
- |-----|----|-----------|
214
- |`search`|`String`|The substring to find|
215
- |`string`|`String`|The string to inspect|
212
+ | param | type | description |
213
+ | -------- | -------- | --------------------- |
214
+ | `search` | `String` | The substring to find |
215
+ | `string` | `String` | The string to inspect |
216
216
 
217
217
  Returns:
218
218
 
219
- |type|description|
220
- |----|-----------|
221
- |`Option<Number>`|`Some(position)` containing the starting position of the substring if found or `None` otherwise|
219
+ | type | description |
220
+ | ---------------- | ----------------------------------------------------------------------------------------------- |
221
+ | `Option<Number>` | `Some(position)` containing the starting position of the substring if found or `None` otherwise |
222
222
 
223
223
  Examples:
224
224
 
@@ -234,23 +234,23 @@ No other changes yet.
234
234
  </details>
235
235
 
236
236
  ```grain
237
- charCodeAt : (position: Number, string: String) => Number
237
+ charCodeAt: (position: Number, string: String) => Number
238
238
  ```
239
239
 
240
240
  Get the Unicode code point at the position in the input string.
241
241
 
242
242
  Parameters:
243
243
 
244
- |param|type|description|
245
- |-----|----|-----------|
246
- |`position`|`Number`|The position to check|
247
- |`string`|`String`|The string to search|
244
+ | param | type | description |
245
+ | ---------- | -------- | --------------------- |
246
+ | `position` | `Number` | The position to check |
247
+ | `string` | `String` | The string to search |
248
248
 
249
249
  Returns:
250
250
 
251
- |type|description|
252
- |----|-----------|
253
- |`Number`|The character code at the provided position|
251
+ | type | description |
252
+ | -------- | ------------------------------------------- |
253
+ | `Number` | The character code at the provided position |
254
254
 
255
255
  Throws:
256
256
 
@@ -276,23 +276,23 @@ No other changes yet.
276
276
  </details>
277
277
 
278
278
  ```grain
279
- charAt : (position: Number, string: String) => Char
279
+ charAt: (position: Number, string: String) => Char
280
280
  ```
281
281
 
282
282
  Get the character at the position in the input string.
283
283
 
284
284
  Parameters:
285
285
 
286
- |param|type|description|
287
- |-----|----|-----------|
288
- |`position`|`Number`|The position to check|
289
- |`string`|`String`|The string to search|
286
+ | param | type | description |
287
+ | ---------- | -------- | --------------------- |
288
+ | `position` | `Number` | The position to check |
289
+ | `string` | `String` | The string to search |
290
290
 
291
291
  Returns:
292
292
 
293
- |type|description|
294
- |----|-----------|
295
- |`Char`|The character at the provided position|
293
+ | type | description |
294
+ | ------ | -------------------------------------- |
295
+ | `Char` | The character at the provided position |
296
296
 
297
297
  Throws:
298
298
 
@@ -318,22 +318,22 @@ No other changes yet.
318
318
  </details>
319
319
 
320
320
  ```grain
321
- explode : (string: String) => Array<Char>
321
+ explode: (string: String) => Array<Char>
322
322
  ```
323
323
 
324
324
  Split a string into its Unicode characters.
325
325
 
326
326
  Parameters:
327
327
 
328
- |param|type|description|
329
- |-----|----|-----------|
330
- |`string`|`String`|The string to split|
328
+ | param | type | description |
329
+ | -------- | -------- | ------------------- |
330
+ | `string` | `String` | The string to split |
331
331
 
332
332
  Returns:
333
333
 
334
- |type|description|
335
- |----|-----------|
336
- |`Array<Char>`|An array containing all characters in the string|
334
+ | type | description |
335
+ | ------------- | ------------------------------------------------ |
336
+ | `Array<Char>` | An array containing all characters in the string |
337
337
 
338
338
  Throws:
339
339
 
@@ -355,22 +355,22 @@ No other changes yet.
355
355
  </details>
356
356
 
357
357
  ```grain
358
- implode : (arr: Array<Char>) => String
358
+ implode: (arr: Array<Char>) => String
359
359
  ```
360
360
 
361
361
  Create a string from an array of characters.
362
362
 
363
363
  Parameters:
364
364
 
365
- |param|type|description|
366
- |-----|----|-----------|
367
- |`arr`|`Array<Char>`|The array to combine|
365
+ | param | type | description |
366
+ | ----- | ------------- | -------------------- |
367
+ | `arr` | `Array<Char>` | The array to combine |
368
368
 
369
369
  Returns:
370
370
 
371
- |type|description|
372
- |----|-----------|
373
- |`String`|A string representation of the array of characters|
371
+ | type | description |
372
+ | -------- | -------------------------------------------------- |
373
+ | `String` | A string representation of the array of characters |
374
374
 
375
375
  Examples:
376
376
 
@@ -386,22 +386,22 @@ No other changes yet.
386
386
  </details>
387
387
 
388
388
  ```grain
389
- reverse : (string: String) => String
389
+ reverse: (string: String) => String
390
390
  ```
391
391
 
392
392
  Create a string that is the given string reversed.
393
393
 
394
394
  Parameters:
395
395
 
396
- |param|type|description|
397
- |-----|----|-----------|
398
- |`string`|`String`|The string to reverse|
396
+ | param | type | description |
397
+ | -------- | -------- | --------------------- |
398
+ | `string` | `String` | The string to reverse |
399
399
 
400
400
  Returns:
401
401
 
402
- |type|description|
403
- |----|-----------|
404
- |`String`|A string whose characters are in the reverse order of the given string|
402
+ | type | description |
403
+ | -------- | ---------------------------------------------------------------------- |
404
+ | `String` | A string whose characters are in the reverse order of the given string |
405
405
 
406
406
  Examples:
407
407
 
@@ -412,23 +412,23 @@ String.reverse("olleH") == "Hello"
412
412
  ### String.**split**
413
413
 
414
414
  ```grain
415
- split : (separator: String, string: String) => Array<String>
415
+ split: (separator: String, string: String) => Array<String>
416
416
  ```
417
417
 
418
418
  Split a string by the given separator.
419
419
 
420
420
  Parameters:
421
421
 
422
- |param|type|description|
423
- |-----|----|-----------|
424
- |`separator`|`String`|The separator to split on|
425
- |`string`|`String`|The string to split|
422
+ | param | type | description |
423
+ | ----------- | -------- | ------------------------- |
424
+ | `separator` | `String` | The separator to split on |
425
+ | `string` | `String` | The string to split |
426
426
 
427
427
  Returns:
428
428
 
429
- |type|description|
430
- |----|-----------|
431
- |`Array<String>`|An array of substrings from the initial string|
429
+ | type | description |
430
+ | --------------- | ---------------------------------------------- |
431
+ | `Array<String>` | An array of substrings from the initial string |
432
432
 
433
433
  Throws:
434
434
 
@@ -457,24 +457,24 @@ String.split(" ", "Hello world") == [> "Hello", "world"]
457
457
  </details>
458
458
 
459
459
  ```grain
460
- slice : (start: Number, ?end: Number, string: String) => String
460
+ slice: (start: Number, ?end: Number, string: String) => String
461
461
  ```
462
462
 
463
463
  Get a portion of a string.
464
464
 
465
465
  Parameters:
466
466
 
467
- |param|type|description|
468
- |-----|----|-----------|
469
- |`start`|`Number`|The start position of the substring|
470
- |`?end`|`Number`|The end position of the substring, exclusive|
471
- |`string`|`String`|The input string|
467
+ | param | type | description |
468
+ | -------- | -------- | -------------------------------------------- |
469
+ | `start` | `Number` | The start position of the substring |
470
+ | `?end` | `Number` | The end position of the substring, exclusive |
471
+ | `string` | `String` | The input string |
472
472
 
473
473
  Returns:
474
474
 
475
- |type|description|
476
- |----|-----------|
477
- |`String`|The substring from the initial string|
475
+ | type | description |
476
+ | -------- | ------------------------------------- |
477
+ | `String` | The substring from the initial string |
478
478
 
479
479
  Throws:
480
480
 
@@ -507,23 +507,23 @@ No other changes yet.
507
507
  </details>
508
508
 
509
509
  ```grain
510
- contains : (search: String, string: String) => Bool
510
+ contains: (search: String, string: String) => Bool
511
511
  ```
512
512
 
513
513
  Check if a string contains a substring.
514
514
 
515
515
  Parameters:
516
516
 
517
- |param|type|description|
518
- |-----|----|-----------|
519
- |`search`|`String`|The substring to check|
520
- |`string`|`String`|The string to search|
517
+ | param | type | description |
518
+ | -------- | -------- | ---------------------- |
519
+ | `search` | `String` | The substring to check |
520
+ | `string` | `String` | The string to search |
521
521
 
522
522
  Returns:
523
523
 
524
- |type|description|
525
- |----|-----------|
526
- |`Bool`|`true` if the input string contains the search value or `false` otherwise|
524
+ | type | description |
525
+ | ------ | ------------------------------------------------------------------------- |
526
+ | `Bool` | `true` if the input string contains the search value or `false` otherwise |
527
527
 
528
528
  Examples:
529
529
 
@@ -539,23 +539,23 @@ No other changes yet.
539
539
  </details>
540
540
 
541
541
  ```grain
542
- startsWith : (search: String, string: String) => Bool
542
+ startsWith: (search: String, string: String) => Bool
543
543
  ```
544
544
 
545
545
  Check if a string begins with another string.
546
546
 
547
547
  Parameters:
548
548
 
549
- |param|type|description|
550
- |-----|----|-----------|
551
- |`search`|`String`|The string to compare to the start|
552
- |`string`|`String`|The string to search|
549
+ | param | type | description |
550
+ | -------- | -------- | ---------------------------------- |
551
+ | `search` | `String` | The string to compare to the start |
552
+ | `string` | `String` | The string to search |
553
553
 
554
554
  Returns:
555
555
 
556
- |type|description|
557
- |----|-----------|
558
- |`Bool`|`true` if the input string starts with the search value or `false` otherwise|
556
+ | type | description |
557
+ | ------ | ---------------------------------------------------------------------------- |
558
+ | `Bool` | `true` if the input string starts with the search value or `false` otherwise |
559
559
 
560
560
  Examples:
561
561
 
@@ -571,23 +571,23 @@ No other changes yet.
571
571
  </details>
572
572
 
573
573
  ```grain
574
- endsWith : (search: String, string: String) => Bool
574
+ endsWith: (search: String, string: String) => Bool
575
575
  ```
576
576
 
577
577
  Check if a string ends with another string.
578
578
 
579
579
  Parameters:
580
580
 
581
- |param|type|description|
582
- |-----|----|-----------|
583
- |`search`|`String`|The string to compare to the end|
584
- |`string`|`String`|The string to search|
581
+ | param | type | description |
582
+ | -------- | -------- | -------------------------------- |
583
+ | `search` | `String` | The string to compare to the end |
584
+ | `string` | `String` | The string to search |
585
585
 
586
586
  Returns:
587
587
 
588
- |type|description|
589
- |----|-----------|
590
- |`Bool`|`true` if the input string ends with the search value or `false` otherwise|
588
+ | type | description |
589
+ | ------ | -------------------------------------------------------------------------- |
590
+ | `Bool` | `true` if the input string ends with the search value or `false` otherwise |
591
591
 
592
592
  Examples:
593
593
 
@@ -603,7 +603,7 @@ No other changes yet.
603
603
  </details>
604
604
 
605
605
  ```grain
606
- replaceFirst :
606
+ replaceFirst:
607
607
  (searchPattern: String, replacement: String, string: String) => String
608
608
  ```
609
609
 
@@ -611,17 +611,17 @@ Replaces the first appearance of the search pattern in the string with the repla
611
611
 
612
612
  Parameters:
613
613
 
614
- |param|type|description|
615
- |-----|----|-----------|
616
- |`searchPattern`|`String`|The string to replace|
617
- |`replacement`|`String`|The replacement|
618
- |`string`|`String`|The string to change|
614
+ | param | type | description |
615
+ | --------------- | -------- | --------------------- |
616
+ | `searchPattern` | `String` | The string to replace |
617
+ | `replacement` | `String` | The replacement |
618
+ | `string` | `String` | The string to change |
619
619
 
620
620
  Returns:
621
621
 
622
- |type|description|
623
- |----|-----------|
624
- |`String`|A new string with the first occurrence of the search pattern replaced|
622
+ | type | description |
623
+ | -------- | --------------------------------------------------------------------- |
624
+ | `String` | A new string with the first occurrence of the search pattern replaced |
625
625
 
626
626
  Examples:
627
627
 
@@ -637,7 +637,7 @@ No other changes yet.
637
637
  </details>
638
638
 
639
639
  ```grain
640
- replaceLast :
640
+ replaceLast:
641
641
  (searchPattern: String, replacement: String, string: String) => String
642
642
  ```
643
643
 
@@ -645,17 +645,17 @@ Replaces the last appearance of the search pattern in the string with the replac
645
645
 
646
646
  Parameters:
647
647
 
648
- |param|type|description|
649
- |-----|----|-----------|
650
- |`searchPattern`|`String`|The string to replace|
651
- |`replacement`|`String`|The replacement|
652
- |`string`|`String`|The string to change|
648
+ | param | type | description |
649
+ | --------------- | -------- | --------------------- |
650
+ | `searchPattern` | `String` | The string to replace |
651
+ | `replacement` | `String` | The replacement |
652
+ | `string` | `String` | The string to change |
653
653
 
654
654
  Returns:
655
655
 
656
- |type|description|
657
- |----|-----------|
658
- |`String`|A new string with the last occurrence of the search pattern replaced|
656
+ | type | description |
657
+ | -------- | -------------------------------------------------------------------- |
658
+ | `String` | A new string with the last occurrence of the search pattern replaced |
659
659
 
660
660
  Examples:
661
661
 
@@ -671,7 +671,7 @@ No other changes yet.
671
671
  </details>
672
672
 
673
673
  ```grain
674
- replaceAll :
674
+ replaceAll:
675
675
  (searchPattern: String, replacement: String, string: String) => String
676
676
  ```
677
677
 
@@ -679,17 +679,17 @@ Replaces every appearance of the search pattern in the string with the replaceme
679
679
 
680
680
  Parameters:
681
681
 
682
- |param|type|description|
683
- |-----|----|-----------|
684
- |`searchPattern`|`String`|The string to replace|
685
- |`replacement`|`String`|The replacement|
686
- |`string`|`String`|The string to change|
682
+ | param | type | description |
683
+ | --------------- | -------- | --------------------- |
684
+ | `searchPattern` | `String` | The string to replace |
685
+ | `replacement` | `String` | The replacement |
686
+ | `string` | `String` | The string to change |
687
687
 
688
688
  Returns:
689
689
 
690
- |type|description|
691
- |----|-----------|
692
- |`String`|A new string with each occurrence of the search pattern replaced|
690
+ | type | description |
691
+ | -------- | ---------------------------------------------------------------- |
692
+ | `String` | A new string with each occurrence of the search pattern replaced |
693
693
 
694
694
  Examples:
695
695
 
@@ -712,7 +712,7 @@ String.replaceAll("🌾", "🌎", "Hello 🌾🌾") == "Hello 🌎🌎"
712
712
  </details>
713
713
 
714
714
  ```grain
715
- encodeAt :
715
+ encodeAt:
716
716
  (string: String, encoding: Encoding, dest: Bytes, destPos: Number,
717
717
  ?includeBom: Bool) => Bytes
718
718
  ```
@@ -721,19 +721,19 @@ Encodes the given string into a byte sequence at the supplied position using the
721
721
 
722
722
  Parameters:
723
723
 
724
- |param|type|description|
725
- |-----|----|-----------|
726
- |`string`|`String`|The input string|
727
- |`encoding`|`Encoding`|The encoding to use|
728
- |`dest`|`Bytes`|The byte sequence that will be copied|
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)|
724
+ | param | type | description |
725
+ | ------------- | ---------- | ---------------------------------------------------------------- |
726
+ | `string` | `String` | The input string |
727
+ | `encoding` | `Encoding` | The encoding to use |
728
+ | `dest` | `Bytes` | The byte sequence that will be copied |
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) |
731
731
 
732
732
  Returns:
733
733
 
734
- |type|description|
735
- |----|-----------|
736
- |`Bytes`|A copy of the input bytes with the encoded string replaced at the given position|
734
+ | type | description |
735
+ | ------- | -------------------------------------------------------------------------------- |
736
+ | `Bytes` | A copy of the input bytes with the encoded string replaced at the given position |
737
737
 
738
738
  Throws:
739
739
 
@@ -757,24 +757,24 @@ Throws:
757
757
  </details>
758
758
 
759
759
  ```grain
760
- encode : (string: String, encoding: Encoding, ?includeBom: Bool) => Bytes
760
+ encode: (string: String, encoding: Encoding, ?includeBom: Bool) => Bytes
761
761
  ```
762
762
 
763
763
  Encodes the given string using the given encoding scheme.
764
764
 
765
765
  Parameters:
766
766
 
767
- |param|type|description|
768
- |-----|----|-----------|
769
- |`string`|`String`|The input string|
770
- |`encoding`|`Encoding`|The encoding to use|
771
- |`?includeBom`|`Bool`|Whether or not to include a byte order marker (false by default)|
767
+ | param | type | description |
768
+ | ------------- | ---------- | ---------------------------------------------------------------- |
769
+ | `string` | `String` | The input string |
770
+ | `encoding` | `Encoding` | The encoding to use |
771
+ | `?includeBom` | `Bool` | Whether or not to include a byte order marker (false by default) |
772
772
 
773
773
  Returns:
774
774
 
775
- |type|description|
776
- |----|-----------|
777
- |`Bytes`|The byte representation of the string in the given encoding|
775
+ | type | description |
776
+ | ------- | ----------------------------------------------------------- |
777
+ | `Bytes` | The byte representation of the string in the given encoding |
778
778
 
779
779
  ### String.**decodeRange**
780
780
 
@@ -791,7 +791,7 @@ Returns:
791
791
  </details>
792
792
 
793
793
  ```grain
794
- decodeRange :
794
+ decodeRange:
795
795
  (bytes: Bytes, encoding: Encoding, start: Number, size: Number,
796
796
  ?keepBom: Bool) => String
797
797
  ```
@@ -800,19 +800,19 @@ Decodes the given byte sequence of the specified range into a string using the e
800
800
 
801
801
  Parameters:
802
802
 
803
- |param|type|description|
804
- |-----|----|-----------|
805
- |`bytes`|`Bytes`|The input bytes|
806
- |`encoding`|`Encoding`|The encoding to use|
807
- |`start`|`Number`|The byte offset to begin decoding from|
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)|
803
+ | param | type | description |
804
+ | ---------- | ---------- | ---------------------------------------------------------------- |
805
+ | `bytes` | `Bytes` | The input bytes |
806
+ | `encoding` | `Encoding` | The encoding to use |
807
+ | `start` | `Number` | The byte offset to begin decoding from |
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) |
810
810
 
811
811
  Returns:
812
812
 
813
- |type|description|
814
- |----|-----------|
815
- |`String`|The decoded string|
813
+ | type | description |
814
+ | -------- | ------------------ |
815
+ | `String` | The decoded string |
816
816
 
817
817
  Throws:
818
818
 
@@ -838,24 +838,24 @@ Throws:
838
838
  </details>
839
839
 
840
840
  ```grain
841
- decode : (bytes: Bytes, encoding: Encoding, ?keepBom: Bool) => String
841
+ decode: (bytes: Bytes, encoding: Encoding, ?keepBom: Bool) => String
842
842
  ```
843
843
 
844
844
  Decodes the given byte sequence into a string using the given encoding scheme.
845
845
 
846
846
  Parameters:
847
847
 
848
- |param|type|description|
849
- |-----|----|-----------|
850
- |`bytes`|`Bytes`|The input bytes|
851
- |`encoding`|`Encoding`|The encoding to use|
852
- |`?keepBom`|`Bool`|Whether or not to include a byte order marker (false by default)|
848
+ | param | type | description |
849
+ | ---------- | ---------- | ---------------------------------------------------------------- |
850
+ | `bytes` | `Bytes` | The input bytes |
851
+ | `encoding` | `Encoding` | The encoding to use |
852
+ | `?keepBom` | `Bool` | Whether or not to include a byte order marker (false by default) |
853
853
 
854
854
  Returns:
855
855
 
856
- |type|description|
857
- |----|-----------|
858
- |`String`|The decoded string|
856
+ | type | description |
857
+ | -------- | ------------------ |
858
+ | `String` | The decoded string |
859
859
 
860
860
  ### String.**forEachCodePoint**
861
861
 
@@ -865,17 +865,17 @@ No other changes yet.
865
865
  </details>
866
866
 
867
867
  ```grain
868
- forEachCodePoint : (fn: (Number => Void), str: String) => Void
868
+ forEachCodePoint: (fn: (Number => Void), str: String) => Void
869
869
  ```
870
870
 
871
871
  Iterates over Unicode code points in a string.
872
872
 
873
873
  Parameters:
874
874
 
875
- |param|type|description|
876
- |-----|----|-----------|
877
- |`fn`|`Number => Void`|The iterator function|
878
- |`str`|`String`|The string to iterate|
875
+ | param | type | description |
876
+ | ----- | ---------------- | --------------------- |
877
+ | `fn` | `Number => Void` | The iterator function |
878
+ | `str` | `String` | The string to iterate |
879
879
 
880
880
  Examples:
881
881
 
@@ -891,7 +891,7 @@ No other changes yet.
891
891
  </details>
892
892
 
893
893
  ```grain
894
- forEachCodePointi : (fn: ((Number, Number) => Void), str: String) => Void
894
+ forEachCodePointi: (fn: ((Number, Number) => Void), str: String) => Void
895
895
  ```
896
896
 
897
897
  Iterates over Unicode code points in a string. This is the same as
@@ -900,10 +900,10 @@ as the second argument to the iterator function.
900
900
 
901
901
  Parameters:
902
902
 
903
- |param|type|description|
904
- |-----|----|-----------|
905
- |`fn`|`(Number, Number) => Void`|The iterator function|
906
- |`str`|`String`|The string to iterate|
903
+ | param | type | description |
904
+ | ----- | -------------------------- | --------------------- |
905
+ | `fn` | `(Number, Number) => Void` | The iterator function |
906
+ | `str` | `String` | The string to iterate |
907
907
 
908
908
  Examples:
909
909
 
@@ -919,17 +919,17 @@ No other changes yet.
919
919
  </details>
920
920
 
921
921
  ```grain
922
- forEachChar : (fn: (Char => Void), str: String) => Void
922
+ forEachChar: (fn: (Char => Void), str: String) => Void
923
923
  ```
924
924
 
925
925
  Iterates over Unicode characters in a string.
926
926
 
927
927
  Parameters:
928
928
 
929
- |param|type|description|
930
- |-----|----|-----------|
931
- |`fn`|`Char => Void`|The iterator function|
932
- |`str`|`String`|The string to iterate|
929
+ | param | type | description |
930
+ | ----- | -------------- | --------------------- |
931
+ | `fn` | `Char => Void` | The iterator function |
932
+ | `str` | `String` | The string to iterate |
933
933
 
934
934
  Examples:
935
935
 
@@ -945,7 +945,7 @@ No other changes yet.
945
945
  </details>
946
946
 
947
947
  ```grain
948
- forEachChari : (fn: ((Char, Number) => Void), str: String) => Void
948
+ forEachChari: (fn: ((Char, Number) => Void), str: String) => Void
949
949
  ```
950
950
 
951
951
  Iterates over Unicode characters in a string. This is the same as
@@ -954,10 +954,10 @@ as the second argument to the iterator function.
954
954
 
955
955
  Parameters:
956
956
 
957
- |param|type|description|
958
- |-----|----|-----------|
959
- |`fn`|`(Char, Number) => Void`|The iterator function|
960
- |`str`|`String`|The string to iterate|
957
+ | param | type | description |
958
+ | ----- | ------------------------ | --------------------- |
959
+ | `fn` | `(Char, Number) => Void` | The iterator function |
960
+ | `str` | `String` | The string to iterate |
961
961
 
962
962
  Examples:
963
963
 
@@ -973,17 +973,17 @@ No other changes yet.
973
973
  </details>
974
974
 
975
975
  ```grain
976
- map : (fn: (Char => Char), str: String) => String
976
+ map: (fn: (Char => Char), str: String) => String
977
977
  ```
978
978
 
979
979
  Builds a new string by mapping Unicode characters.
980
980
 
981
981
  Parameters:
982
982
 
983
- |param|type|description|
984
- |-----|----|-----------|
985
- |`fn`|`Char => Char`|The mapping function|
986
- |`str`|`String`|The string to map|
983
+ | param | type | description |
984
+ | ----- | -------------- | -------------------- |
985
+ | `fn` | `Char => Char` | The mapping function |
986
+ | `str` | `String` | The string to map |
987
987
 
988
988
  Examples:
989
989
 
@@ -999,7 +999,7 @@ No other changes yet.
999
999
  </details>
1000
1000
 
1001
1001
  ```grain
1002
- mapi : (fn: ((Char, Number) => Char), str: String) => String
1002
+ mapi: (fn: ((Char, Number) => Char), str: String) => String
1003
1003
  ```
1004
1004
 
1005
1005
  Builds a new string by mapping Unicode characters. This is the same as
@@ -1008,10 +1008,10 @@ as the second argument to the mapping function.
1008
1008
 
1009
1009
  Parameters:
1010
1010
 
1011
- |param|type|description|
1012
- |-----|----|-----------|
1013
- |`fn`|`(Char, Number) => Char`|The mapping function|
1014
- |`str`|`String`|The string to map|
1011
+ | param | type | description |
1012
+ | ----- | ------------------------ | -------------------- |
1013
+ | `fn` | `(Char, Number) => Char` | The mapping function |
1014
+ | `str` | `String` | The string to map |
1015
1015
 
1016
1016
  Examples:
1017
1017
 
@@ -1027,22 +1027,22 @@ No other changes yet.
1027
1027
  </details>
1028
1028
 
1029
1029
  ```grain
1030
- trimStart : (string: String) => String
1030
+ trimStart: (string: String) => String
1031
1031
  ```
1032
1032
 
1033
1033
  Trims the beginning of a string—removing any leading whitespace characters.
1034
1034
 
1035
1035
  Parameters:
1036
1036
 
1037
- |param|type|description|
1038
- |-----|----|-----------|
1039
- |`string`|`String`|The string to be trimmed|
1037
+ | param | type | description |
1038
+ | -------- | -------- | ------------------------ |
1039
+ | `string` | `String` | The string to be trimmed |
1040
1040
 
1041
1041
  Returns:
1042
1042
 
1043
- |type|description|
1044
- |----|-----------|
1045
- |`String`|The trimmed string|
1043
+ | type | description |
1044
+ | -------- | ------------------ |
1045
+ | `String` | The trimmed string |
1046
1046
 
1047
1047
  Examples:
1048
1048
 
@@ -1058,22 +1058,22 @@ No other changes yet.
1058
1058
  </details>
1059
1059
 
1060
1060
  ```grain
1061
- trimEnd : (string: String) => String
1061
+ trimEnd: (string: String) => String
1062
1062
  ```
1063
1063
 
1064
1064
  Trims the end of a string—removing any trailing whitespace characters.
1065
1065
 
1066
1066
  Parameters:
1067
1067
 
1068
- |param|type|description|
1069
- |-----|----|-----------|
1070
- |`string`|`String`|The string to be trimmed|
1068
+ | param | type | description |
1069
+ | -------- | -------- | ------------------------ |
1070
+ | `string` | `String` | The string to be trimmed |
1071
1071
 
1072
1072
  Returns:
1073
1073
 
1074
- |type|description|
1075
- |----|-----------|
1076
- |`String`|The trimmed string|
1074
+ | type | description |
1075
+ | -------- | ------------------ |
1076
+ | `String` | The trimmed string |
1077
1077
 
1078
1078
  Examples:
1079
1079
 
@@ -1089,22 +1089,22 @@ No other changes yet.
1089
1089
  </details>
1090
1090
 
1091
1091
  ```grain
1092
- trim : (string: String) => String
1092
+ trim: (string: String) => String
1093
1093
  ```
1094
1094
 
1095
1095
  Trims a string—removing all leading and trailing whitespace characters.
1096
1096
 
1097
1097
  Parameters:
1098
1098
 
1099
- |param|type|description|
1100
- |-----|----|-----------|
1101
- |`string`|`String`|The string to be trimmed|
1099
+ | param | type | description |
1100
+ | -------- | -------- | ------------------------ |
1101
+ | `string` | `String` | The string to be trimmed |
1102
1102
 
1103
1103
  Returns:
1104
1104
 
1105
- |type|description|
1106
- |----|-----------|
1107
- |`String`|The trimmed string|
1105
+ | type | description |
1106
+ | -------- | ------------------ |
1107
+ | `String` | The trimmed string |
1108
1108
 
1109
1109
  Examples:
1110
1110
 
@@ -1120,22 +1120,22 @@ No other changes yet.
1120
1120
  </details>
1121
1121
 
1122
1122
  ```grain
1123
- toAsciiLowercase : (string: String) => String
1123
+ toAsciiLowercase: (string: String) => String
1124
1124
  ```
1125
1125
 
1126
1126
  Converts all ASCII uppercase characters in the string to lowercase.
1127
1127
 
1128
1128
  Parameters:
1129
1129
 
1130
- |param|type|description|
1131
- |-----|----|-----------|
1132
- |`string`|`String`|The string to convert|
1130
+ | param | type | description |
1131
+ | -------- | -------- | --------------------- |
1132
+ | `string` | `String` | The string to convert |
1133
1133
 
1134
1134
  Returns:
1135
1135
 
1136
- |type|description|
1137
- |----|-----------|
1138
- |`String`|The lowercased string|
1136
+ | type | description |
1137
+ | -------- | --------------------- |
1138
+ | `String` | The lowercased string |
1139
1139
 
1140
1140
  Examples:
1141
1141
 
@@ -1151,22 +1151,22 @@ No other changes yet.
1151
1151
  </details>
1152
1152
 
1153
1153
  ```grain
1154
- toAsciiUppercase : (string: String) => String
1154
+ toAsciiUppercase: (string: String) => String
1155
1155
  ```
1156
1156
 
1157
1157
  Converts all ASCII lowercase characters in the string to uppercase.
1158
1158
 
1159
1159
  Parameters:
1160
1160
 
1161
- |param|type|description|
1162
- |-----|----|-----------|
1163
- |`string`|`String`|The string to convert|
1161
+ | param | type | description |
1162
+ | -------- | -------- | --------------------- |
1163
+ | `string` | `String` | The string to convert |
1164
1164
 
1165
1165
  Returns:
1166
1166
 
1167
- |type|description|
1168
- |----|-----------|
1169
- |`String`|The uppercased string|
1167
+ | type | description |
1168
+ | -------- | --------------------- |
1169
+ | `String` | The uppercased string |
1170
1170
 
1171
1171
  Examples:
1172
1172
 
@@ -1174,3 +1174,46 @@ Examples:
1174
1174
  assert String.toAsciiUppercase("aBc123") == "ABC123"
1175
1175
  ```
1176
1176
 
1177
+ ### String.**repeat**
1178
+
1179
+ <details disabled>
1180
+ <summary tabindex="-1">Added in <code>0.6.7</code></summary>
1181
+ No other changes yet.
1182
+ </details>
1183
+
1184
+ ```grain
1185
+ repeat: (count: Number, string: String) => String
1186
+ ```
1187
+
1188
+ Produces a new string by repeating a substring a given number of times.
1189
+
1190
+ Parameters:
1191
+
1192
+ | param | type | description |
1193
+ | -------- | -------- | ---------------------------------------- |
1194
+ | `count` | `Number` | The number of times to repeat the string |
1195
+ | `string` | `String` | The string to repeat |
1196
+
1197
+ Returns:
1198
+
1199
+ | type | description |
1200
+ | -------- | --------------------------------------------- |
1201
+ | `String` | A string containing the repeated input string |
1202
+
1203
+ Throws:
1204
+
1205
+ `InvalidArgument(String)`
1206
+
1207
+ * When the `count` is not an integer
1208
+ * When the `count` is negative
1209
+
1210
+ Examples:
1211
+
1212
+ ```grain
1213
+ assert String.repeat(5, "=") == "====="
1214
+ ```
1215
+
1216
+ ```grain
1217
+ assert String.repeat(0, ".") == ""
1218
+ ```
1219
+