@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.
- package/CHANGELOG.md +67 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/array.gr +55 -7
- package/array.md +606 -560
- package/bigint.md +228 -228
- package/buffer.gr +85 -53
- package/buffer.md +442 -319
- package/bytes.gr +112 -35
- package/bytes.md +299 -219
- package/char.gr +201 -99
- package/char.md +447 -120
- package/exception.gr +11 -11
- package/exception.md +29 -4
- package/float32.gr +327 -3
- package/float32.md +698 -111
- package/float64.gr +320 -3
- package/float64.md +698 -111
- package/fs.gr +1082 -0
- package/fs.md +630 -0
- package/hash.gr +142 -88
- package/hash.md +105 -17
- package/int16.md +178 -178
- package/int32.gr +26 -5
- package/int32.md +266 -231
- package/int64.gr +27 -2
- package/int64.md +266 -231
- package/int8.md +178 -178
- package/json.gr +366 -51
- package/json.md +431 -15
- package/list.gr +328 -31
- package/list.md +759 -336
- package/map.gr +20 -12
- package/map.md +266 -260
- package/marshal.gr +41 -40
- package/marshal.md +14 -14
- package/number.gr +278 -35
- package/number.md +688 -269
- package/option.md +162 -162
- package/package.json +5 -3
- package/path.gr +48 -0
- package/path.md +180 -89
- package/pervasives.gr +2 -2
- package/pervasives.md +275 -275
- package/priorityqueue.gr +7 -7
- package/priorityqueue.md +131 -131
- package/queue.gr +183 -29
- package/queue.md +404 -148
- package/random.md +43 -43
- package/range.gr +4 -4
- package/range.md +42 -42
- package/rational.md +123 -123
- package/regex.gr +52 -51
- package/regex.md +102 -102
- package/result.md +118 -118
- package/runtime/atof/common.md +39 -39
- package/runtime/atof/decimal.gr +6 -6
- package/runtime/atof/decimal.md +14 -14
- package/runtime/atof/lemire.gr +5 -5
- package/runtime/atof/lemire.md +1 -1
- package/runtime/atof/parse.gr +16 -16
- package/runtime/atof/parse.md +2 -2
- package/runtime/atof/slow.md +1 -1
- package/runtime/atof/table.md +2 -2
- package/runtime/atoi/parse.gr +3 -3
- package/runtime/atoi/parse.md +1 -1
- package/runtime/bigint.gr +15 -47
- package/runtime/bigint.md +54 -60
- package/runtime/compare.gr +2 -2
- package/runtime/compare.md +8 -8
- package/runtime/dataStructures.md +211 -211
- package/runtime/debugPrint.gr +4 -1
- package/runtime/debugPrint.md +9 -9
- package/runtime/equal.gr +99 -77
- package/runtime/equal.md +8 -8
- package/runtime/exception.gr +62 -82
- package/runtime/exception.md +62 -11
- package/runtime/gc.gr +39 -45
- package/runtime/gc.md +4 -4
- package/runtime/malloc.gr +7 -7
- package/runtime/malloc.md +13 -13
- package/runtime/math/kernel/cos.gr +70 -0
- package/runtime/math/kernel/cos.md +14 -0
- package/runtime/math/kernel/sin.gr +65 -0
- package/runtime/math/kernel/sin.md +14 -0
- package/runtime/math/kernel/tan.gr +136 -0
- package/runtime/math/kernel/tan.md +14 -0
- package/runtime/math/rempio2.gr +244 -0
- package/runtime/math/rempio2.md +14 -0
- package/runtime/math/trig.gr +130 -0
- package/runtime/math/trig.md +28 -0
- package/runtime/math/umuldi.gr +26 -0
- package/runtime/math/umuldi.md +14 -0
- package/runtime/numberUtils.gr +29 -29
- package/runtime/numberUtils.md +12 -12
- package/runtime/numbers.gr +373 -381
- package/runtime/numbers.md +348 -342
- package/runtime/string.gr +37 -105
- package/runtime/string.md +20 -26
- package/runtime/unsafe/constants.md +24 -24
- package/runtime/unsafe/conv.md +19 -19
- package/runtime/unsafe/memory.gr +24 -20
- package/runtime/unsafe/memory.md +27 -7
- package/runtime/unsafe/offsets.gr +36 -0
- package/runtime/unsafe/offsets.md +88 -0
- package/runtime/unsafe/panic.gr +28 -0
- package/runtime/unsafe/panic.md +14 -0
- package/runtime/unsafe/tags.md +32 -32
- package/runtime/unsafe/wasmf32.md +28 -28
- package/runtime/unsafe/wasmf64.md +28 -28
- package/runtime/unsafe/wasmi32.md +47 -47
- package/runtime/unsafe/wasmi64.md +50 -50
- package/runtime/utf8.gr +189 -0
- package/runtime/utf8.md +117 -0
- package/runtime/wasi.gr +4 -2
- package/runtime/wasi.md +147 -147
- package/set.gr +18 -11
- package/set.md +253 -247
- package/stack.gr +171 -2
- package/stack.md +371 -89
- package/string.gr +352 -557
- package/string.md +298 -255
- package/uint16.md +170 -170
- package/uint32.gr +25 -4
- package/uint32.md +249 -214
- package/uint64.gr +25 -5
- package/uint64.md +249 -214
- package/uint8.md +170 -170
- package/uri.gr +57 -53
- package/uri.md +88 -89
- package/wasi/file.gr +67 -59
- package/wasi/file.md +308 -308
- package/wasi/process.md +26 -26
- package/wasi/random.md +12 -12
- package/wasi/time.md +16 -16
- package/runtime/utils/printing.gr +0 -60
- 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
|
|
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
|
-
|
|
64
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
93
|
+
| param | type | description |
|
|
94
|
+
| -------- | -------- | --------------------- |
|
|
95
|
+
| `string` | `String` | The string to inspect |
|
|
96
96
|
|
|
97
97
|
Returns:
|
|
98
98
|
|
|
99
|
-
|type|description|
|
|
100
|
-
|
|
101
|
-
|
|
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
|
|
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
|
-
|
|
124
|
+
| param | type | description |
|
|
125
|
+
| -------- | -------- | --------------------- |
|
|
126
|
+
| `string` | `String` | The string to inspect |
|
|
127
127
|
|
|
128
128
|
Returns:
|
|
129
129
|
|
|
130
|
-
|type|description|
|
|
131
|
-
|
|
132
|
-
|
|
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
|
|
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
|
-
|
|
155
|
+
| param | type | description |
|
|
156
|
+
| -------- | -------- | --------------------- |
|
|
157
|
+
| `string` | `String` | The string to inspect |
|
|
158
158
|
|
|
159
159
|
Returns:
|
|
160
160
|
|
|
161
|
-
|type|description|
|
|
162
|
-
|
|
163
|
-
|
|
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
|
|
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
|
-
|
|
183
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
215
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
247
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
289
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
328
|
+
| param | type | description |
|
|
329
|
+
| -------- | -------- | ------------------- |
|
|
330
|
+
| `string` | `String` | The string to split |
|
|
331
331
|
|
|
332
332
|
Returns:
|
|
333
333
|
|
|
334
|
-
|type|description|
|
|
335
|
-
|
|
336
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
396
|
+
| param | type | description |
|
|
397
|
+
| -------- | -------- | --------------------- |
|
|
398
|
+
| `string` | `String` | The string to reverse |
|
|
399
399
|
|
|
400
400
|
Returns:
|
|
401
401
|
|
|
402
|
-
|type|description|
|
|
403
|
-
|
|
404
|
-
|
|
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
|
|
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
|
-
|
|
425
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
470
|
-
|
|
471
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
520
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
552
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
584
|
-
|
|
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
|
-
|
|
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
|
-
|
|
617
|
-
|
|
618
|
-
|
|
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
|
-
|
|
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
|
-
|
|
651
|
-
|
|
652
|
-
|
|
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
|
-
|
|
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
|
-
|
|
685
|
-
|
|
686
|
-
|
|
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
|
-
|
|
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
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
770
|
-
|
|
771
|
-
|
|
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
|
-
|
|
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
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
851
|
-
|
|
852
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
878
|
-
|
|
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
|
|
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
|
-
|
|
906
|
-
|
|
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
|
|
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
|
-
|
|
932
|
-
|
|
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
|
|
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
|
-
|
|
960
|
-
|
|
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
|
|
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
|
-
|
|
986
|
-
|
|
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
|
|
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
|
-
|
|
1014
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
1130
|
+
| param | type | description |
|
|
1131
|
+
| -------- | -------- | --------------------- |
|
|
1132
|
+
| `string` | `String` | The string to convert |
|
|
1133
1133
|
|
|
1134
1134
|
Returns:
|
|
1135
1135
|
|
|
1136
|
-
|type|description|
|
|
1137
|
-
|
|
1138
|
-
|
|
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
|
|
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
|
-
|
|
1161
|
+
| param | type | description |
|
|
1162
|
+
| -------- | -------- | --------------------- |
|
|
1163
|
+
| `string` | `String` | The string to convert |
|
|
1164
1164
|
|
|
1165
1165
|
Returns:
|
|
1166
1166
|
|
|
1167
|
-
|type|description|
|
|
1168
|
-
|
|
1169
|
-
|
|
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
|
+
|