@grain/stdlib 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/array.md +491 -491
  3. package/bigint.md +198 -198
  4. package/buffer.gr +66 -1
  5. package/buffer.md +395 -272
  6. package/bytes.gr +1 -0
  7. package/bytes.md +200 -199
  8. package/char.md +125 -125
  9. package/exception.md +9 -9
  10. package/float32.md +195 -195
  11. package/float64.md +195 -195
  12. package/fs.md +115 -115
  13. package/hash.md +16 -16
  14. package/int16.md +155 -155
  15. package/int32.gr +1 -1
  16. package/int32.md +207 -207
  17. package/int64.gr +1 -1
  18. package/int64.md +207 -207
  19. package/int8.md +155 -155
  20. package/json.md +59 -59
  21. package/list.md +347 -347
  22. package/map.md +222 -222
  23. package/marshal.md +12 -12
  24. package/number.gr +119 -5
  25. package/number.md +503 -261
  26. package/option.md +141 -141
  27. package/package.json +2 -2
  28. package/path.gr +82 -65
  29. package/path.md +210 -141
  30. package/pervasives.md +238 -238
  31. package/priorityqueue.md +112 -112
  32. package/queue.md +117 -117
  33. package/random.md +37 -37
  34. package/range.md +36 -36
  35. package/rational.md +107 -107
  36. package/regex.md +91 -91
  37. package/result.md +102 -102
  38. package/runtime/atof/decimal.md +6 -6
  39. package/runtime/compare.md +7 -7
  40. package/runtime/dataStructures.md +178 -178
  41. package/runtime/equal.md +7 -7
  42. package/runtime/exception.md +15 -15
  43. package/runtime/malloc.md +9 -9
  44. package/runtime/numbers.md +269 -269
  45. package/runtime/string.md +17 -17
  46. package/runtime/unsafe/conv.md +6 -6
  47. package/runtime/unsafe/memory.gr +2 -19
  48. package/runtime/unsafe/memory.md +10 -10
  49. package/runtime/utf8.md +31 -31
  50. package/runtime/wasi.md +9 -9
  51. package/set.md +211 -211
  52. package/stack.md +122 -122
  53. package/string.md +228 -228
  54. package/uint16.md +148 -148
  55. package/uint32.md +192 -192
  56. package/uint64.md +192 -192
  57. package/uint8.md +148 -148
  58. package/uri.md +77 -77
  59. package/wasi/file.md +269 -269
  60. package/wasi/process.md +21 -21
  61. package/wasi/random.md +9 -9
  62. package/wasi/time.md +12 -12
package/option.md CHANGED
@@ -42,15 +42,15 @@ Checks if the Option is the `Some` variant.
42
42
 
43
43
  Parameters:
44
44
 
45
- |param|type|description|
46
- |-----|----|-----------|
47
- |`option`|`Option<a>`|The option to check|
45
+ | param | type | description |
46
+ | -------- | ----------- | ------------------- |
47
+ | `option` | `Option<a>` | The option to check |
48
48
 
49
49
  Returns:
50
50
 
51
- |type|description|
52
- |----|-----------|
53
- |`Bool`|`true` if the Option is the `Some` variant or `false` otherwise|
51
+ | type | description |
52
+ | ------ | --------------------------------------------------------------- |
53
+ | `Bool` | `true` if the Option is the `Some` variant or `false` otherwise |
54
54
 
55
55
  ### Option.**isNone**
56
56
 
@@ -67,15 +67,15 @@ Checks if the Option is the `None` variant.
67
67
 
68
68
  Parameters:
69
69
 
70
- |param|type|description|
71
- |-----|----|-----------|
72
- |`option`|`Option<a>`|The option to check|
70
+ | param | type | description |
71
+ | -------- | ----------- | ------------------- |
72
+ | `option` | `Option<a>` | The option to check |
73
73
 
74
74
  Returns:
75
75
 
76
- |type|description|
77
- |----|-----------|
78
- |`Bool`|`true` if the Option is the `None` variant or `false` otherwise|
76
+ | type | description |
77
+ | ------ | --------------------------------------------------------------- |
78
+ | `Bool` | `true` if the Option is the `None` variant or `false` otherwise |
79
79
 
80
80
  ### Option.**contains**
81
81
 
@@ -92,16 +92,16 @@ Checks if the Option is the `Some` variant and contains the given value. Uses th
92
92
 
93
93
  Parameters:
94
94
 
95
- |param|type|description|
96
- |-----|----|-----------|
97
- |`value`|`a`|The value to search for|
98
- |`option`|`Option<a>`|The option to search|
95
+ | param | type | description |
96
+ | -------- | ----------- | ----------------------- |
97
+ | `value` | `a` | The value to search for |
98
+ | `option` | `Option<a>` | The option to search |
99
99
 
100
100
  Returns:
101
101
 
102
- |type|description|
103
- |----|-----------|
104
- |`Bool`|`true` if the Option is equivalent to `Some(value)` or `false` otherwise|
102
+ | type | description |
103
+ | ------ | ------------------------------------------------------------------------ |
104
+ | `Bool` | `true` if the Option is equivalent to `Some(value)` or `false` otherwise |
105
105
 
106
106
  ### Option.**expect**
107
107
 
@@ -119,16 +119,16 @@ exception containing the message provided.
119
119
 
120
120
  Parameters:
121
121
 
122
- |param|type|description|
123
- |-----|----|-----------|
124
- |`msg`|`String`|The message to use upon failure|
125
- |`option`|`Option<a>`|The option to extract a value from|
122
+ | param | type | description |
123
+ | -------- | ----------- | ---------------------------------- |
124
+ | `msg` | `String` | The message to use upon failure |
125
+ | `option` | `Option<a>` | The option to extract a value from |
126
126
 
127
127
  Returns:
128
128
 
129
- |type|description|
130
- |----|-----------|
131
- |`a`|The unwrapped value if the Option is the `Some` variant|
129
+ | type | description |
130
+ | ---- | ------------------------------------------------------- |
131
+ | `a` | The unwrapped value if the Option is the `Some` variant |
132
132
 
133
133
  Throws:
134
134
 
@@ -152,15 +152,15 @@ throws an exception containing a default message.
152
152
 
153
153
  Parameters:
154
154
 
155
- |param|type|description|
156
- |-----|----|-----------|
157
- |`option`|`Option<a>`|The option to extract the value from|
155
+ | param | type | description |
156
+ | -------- | ----------- | ------------------------------------ |
157
+ | `option` | `Option<a>` | The option to extract the value from |
158
158
 
159
159
  Returns:
160
160
 
161
- |type|description|
162
- |----|-----------|
163
- |`a`|The unwrapped value if the Option is the `Some` variant|
161
+ | type | description |
162
+ | ---- | ------------------------------------------------------- |
163
+ | `a` | The unwrapped value if the Option is the `Some` variant |
164
164
 
165
165
  Throws:
166
166
 
@@ -183,16 +183,16 @@ Extracts the value inside a `Some` option or provide the default value if `None`
183
183
 
184
184
  Parameters:
185
185
 
186
- |param|type|description|
187
- |-----|----|-----------|
188
- |`default`|`a`|The default value|
189
- |`option`|`Option<a>`|The option to unwrap|
186
+ | param | type | description |
187
+ | --------- | ----------- | -------------------- |
188
+ | `default` | `a` | The default value |
189
+ | `option` | `Option<a>` | The option to unwrap |
190
190
 
191
191
  Returns:
192
192
 
193
- |type|description|
194
- |----|-----------|
195
- |`a`|The unwrapped value if the Option is the `Some` variant or the default value otherwise|
193
+ | type | description |
194
+ | ---- | -------------------------------------------------------------------------------------- |
195
+ | `a` | The unwrapped value if the Option is the `Some` variant or the default value otherwise |
196
196
 
197
197
  ### Option.**map**
198
198
 
@@ -209,16 +209,16 @@ If the Option is `Some(value)`, applies the given function to the `value` and wr
209
209
 
210
210
  Parameters:
211
211
 
212
- |param|type|description|
213
- |-----|----|-----------|
214
- |`fn`|`a => b`|The function to call on the value of a `Some` variant|
215
- |`option`|`Option<a>`|The option to map|
212
+ | param | type | description |
213
+ | -------- | ----------- | ----------------------------------------------------- |
214
+ | `fn` | `a => b` | The function to call on the value of a `Some` variant |
215
+ | `option` | `Option<a>` | The option to map |
216
216
 
217
217
  Returns:
218
218
 
219
- |type|description|
220
- |----|-----------|
221
- |`Option<b>`|A new `Some` variant produced by the mapping function if the variant was `Some` or the unmodified `None` otherwise|
219
+ | type | description |
220
+ | ----------- | ------------------------------------------------------------------------------------------------------------------ |
221
+ | `Option<b>` | A new `Some` variant produced by the mapping function if the variant was `Some` or the unmodified `None` otherwise |
222
222
 
223
223
  ### Option.**mapWithDefault**
224
224
 
@@ -236,17 +236,17 @@ Useful for unwrapping an Option while providing a fallback for any `None` varian
236
236
 
237
237
  Parameters:
238
238
 
239
- |param|type|description|
240
- |-----|----|-----------|
241
- |`fn`|`a => b`|The function to call on the value of a `Some` variant|
242
- |`default`|`b`|A fallback value for a `None` variant|
243
- |`option`|`Option<a>`|The option to map|
239
+ | param | type | description |
240
+ | --------- | ----------- | ----------------------------------------------------- |
241
+ | `fn` | `a => b` | The function to call on the value of a `Some` variant |
242
+ | `default` | `b` | A fallback value for a `None` variant |
243
+ | `option` | `Option<a>` | The option to map |
244
244
 
245
245
  Returns:
246
246
 
247
- |type|description|
248
- |----|-----------|
249
- |`b`|The value produced by the mapping function if the Option is of the `Some` variant or the default value otherwise|
247
+ | type | description |
248
+ | ---- | ---------------------------------------------------------------------------------------------------------------- |
249
+ | `b` | The value produced by the mapping function if the Option is of the `Some` variant or the default value otherwise |
250
250
 
251
251
  ### Option.**mapWithDefaultFn**
252
252
 
@@ -266,17 +266,17 @@ Useful for unwrapping an Option into a value, whether it is `Some` or `None`.
266
266
 
267
267
  Parameters:
268
268
 
269
- |param|type|description|
270
- |-----|----|-----------|
271
- |`fn`|`a => b`|The function to call on the value of a `Some` variant|
272
- |`defaultFn`|`() => b`|The default function|
273
- |`option`|`Option<a>`|The option to map|
269
+ | param | type | description |
270
+ | ----------- | ----------- | ----------------------------------------------------- |
271
+ | `fn` | `a => b` | The function to call on the value of a `Some` variant |
272
+ | `defaultFn` | `() => b` | The default function |
273
+ | `option` | `Option<a>` | The option to map |
274
274
 
275
275
  Returns:
276
276
 
277
- |type|description|
278
- |----|-----------|
279
- |`b`|The value produced by one of the mapping functions|
277
+ | type | description |
278
+ | ---- | -------------------------------------------------- |
279
+ | `b` | The value produced by one of the mapping functions |
280
280
 
281
281
  ### Option.**flatMap**
282
282
 
@@ -293,16 +293,16 @@ If the Option is `Some(value)`, applies the given function to the `value` to pro
293
293
 
294
294
  Parameters:
295
295
 
296
- |param|type|description|
297
- |-----|----|-----------|
298
- |`fn`|`a => Option<b>`|The function to call on the value of a `Some` variant|
299
- |`option`|`Option<a>`|The option to map|
296
+ | param | type | description |
297
+ | -------- | ---------------- | ----------------------------------------------------- |
298
+ | `fn` | `a => Option<b>` | The function to call on the value of a `Some` variant |
299
+ | `option` | `Option<a>` | The option to map |
300
300
 
301
301
  Returns:
302
302
 
303
- |type|description|
304
- |----|-----------|
305
- |`Option<b>`|A new Option produced by the mapping function if the variant was `Some` or the unmodified `None` otherwise|
303
+ | type | description |
304
+ | ----------- | ---------------------------------------------------------------------------------------------------------- |
305
+ | `Option<b>` | A new Option produced by the mapping function if the variant was `Some` or the unmodified `None` otherwise |
306
306
 
307
307
  ### Option.**filter**
308
308
 
@@ -320,16 +320,16 @@ if the `fn` return `true` returns `Some(value)`, otherwise returns `None`.
320
320
 
321
321
  Parameters:
322
322
 
323
- |param|type|description|
324
- |-----|----|-----------|
325
- |`fn`|`a => Bool`|The predicate function to indicate if the option should remain `Some`|
326
- |`option`|`Option<a>`|The option to inspect|
323
+ | param | type | description |
324
+ | -------- | ----------- | --------------------------------------------------------------------- |
325
+ | `fn` | `a => Bool` | The predicate function to indicate if the option should remain `Some` |
326
+ | `option` | `Option<a>` | The option to inspect |
327
327
 
328
328
  Returns:
329
329
 
330
- |type|description|
331
- |----|-----------|
332
- |`Option<a>`|`Some(value)` if the variant was `Some` and the predicate returns `true` or `None` otherwise|
330
+ | type | description |
331
+ | ----------- | -------------------------------------------------------------------------------------------- |
332
+ | `Option<a>` | `Some(value)` if the variant was `Some` and the predicate returns `true` or `None` otherwise |
333
333
 
334
334
  ### Option.**zip**
335
335
 
@@ -346,16 +346,16 @@ Combine two Options into a single Option containing a tuple of their values.
346
346
 
347
347
  Parameters:
348
348
 
349
- |param|type|description|
350
- |-----|----|-----------|
351
- |`optionA`|`Option<a>`|The first option to combine|
352
- |`optionB`|`Option<b>`|The second option to combine|
349
+ | param | type | description |
350
+ | --------- | ----------- | ---------------------------- |
351
+ | `optionA` | `Option<a>` | The first option to combine |
352
+ | `optionB` | `Option<b>` | The second option to combine |
353
353
 
354
354
  Returns:
355
355
 
356
- |type|description|
357
- |----|-----------|
358
- |`Option<(a, b)>`|`Some((valueA, valueB))` if both Options are `Some` variants or `None` otherwise|
356
+ | type | description |
357
+ | ---------------- | -------------------------------------------------------------------------------- |
358
+ | `Option<(a, b)>` | `Some((valueA, valueB))` if both Options are `Some` variants or `None` otherwise |
359
359
 
360
360
  ### Option.**zipWith**
361
361
 
@@ -373,17 +373,17 @@ Combine two Options into a single Option. The new value is produced by applying
373
373
 
374
374
  Parameters:
375
375
 
376
- |param|type|description|
377
- |-----|----|-----------|
378
- |`fn`|`(a, b) => c`|The function to generate a new value|
379
- |`optionA`|`Option<a>`|The first option to combine|
380
- |`optionB`|`Option<b>`|The second option to combine|
376
+ | param | type | description |
377
+ | --------- | ------------- | ------------------------------------ |
378
+ | `fn` | `(a, b) => c` | The function to generate a new value |
379
+ | `optionA` | `Option<a>` | The first option to combine |
380
+ | `optionB` | `Option<b>` | The second option to combine |
381
381
 
382
382
  Returns:
383
383
 
384
- |type|description|
385
- |----|-----------|
386
- |`Option<c>`|`Some(newValue)` if both Options are `Some` variants or `None` otherwise|
384
+ | type | description |
385
+ | ----------- | ------------------------------------------------------------------------ |
386
+ | `Option<c>` | `Some(newValue)` if both Options are `Some` variants or `None` otherwise |
387
387
 
388
388
  ### Option.**flatten**
389
389
 
@@ -400,15 +400,15 @@ Flattens nested Options.
400
400
 
401
401
  Parameters:
402
402
 
403
- |param|type|description|
404
- |-----|----|-----------|
405
- |`option`|`Option<Option<a>>`|The option to flatten|
403
+ | param | type | description |
404
+ | -------- | ------------------- | --------------------- |
405
+ | `option` | `Option<Option<a>>` | The option to flatten |
406
406
 
407
407
  Returns:
408
408
 
409
- |type|description|
410
- |----|-----------|
411
- |`Option<a>`|`Some(innerValue)` if all nested options were the `Some` variant or `None` otherwise|
409
+ | type | description |
410
+ | ----------- | ------------------------------------------------------------------------------------ |
411
+ | `Option<a>` | `Some(innerValue)` if all nested options were the `Some` variant or `None` otherwise |
412
412
 
413
413
  Examples:
414
414
 
@@ -431,15 +431,15 @@ Converts an Option to a list with either zero or one item.
431
431
 
432
432
  Parameters:
433
433
 
434
- |param|type|description|
435
- |-----|----|-----------|
436
- |`option`|`Option<a>`|The option to convert|
434
+ | param | type | description |
435
+ | -------- | ----------- | --------------------- |
436
+ | `option` | `Option<a>` | The option to convert |
437
437
 
438
438
  Returns:
439
439
 
440
- |type|description|
441
- |----|-----------|
442
- |`List<a>`|`[value]` if the Option was the `Some` variant or `[]` otherwise|
440
+ | type | description |
441
+ | --------- | ---------------------------------------------------------------- |
442
+ | `List<a>` | `[value]` if the Option was the `Some` variant or `[]` otherwise |
443
443
 
444
444
  ### Option.**toArray**
445
445
 
@@ -456,15 +456,15 @@ Converts an Option to an array with either zero or one item.
456
456
 
457
457
  Parameters:
458
458
 
459
- |param|type|description|
460
- |-----|----|-----------|
461
- |`option`|`Option<a>`|The option to convert|
459
+ | param | type | description |
460
+ | -------- | ----------- | --------------------- |
461
+ | `option` | `Option<a>` | The option to convert |
462
462
 
463
463
  Returns:
464
464
 
465
- |type|description|
466
- |----|-----------|
467
- |`Array<a>`|`[> value]` if the Option was the `Some` variant or `[> ]` otherwise|
465
+ | type | description |
466
+ | ---------- | -------------------------------------------------------------------- |
467
+ | `Array<a>` | `[> value]` if the Option was the `Some` variant or `[> ]` otherwise |
468
468
 
469
469
  ### Option.**toResult**
470
470
 
@@ -481,16 +481,16 @@ Converts the Option to a Result, using the provided error in case of the `None`
481
481
 
482
482
  Parameters:
483
483
 
484
- |param|type|description|
485
- |-----|----|-----------|
486
- |`err`|`a`|The error to use if the option is `None`|
487
- |`option`|`Option<b>`|The option to convert|
484
+ | param | type | description |
485
+ | -------- | ----------- | ---------------------------------------- |
486
+ | `err` | `a` | The error to use if the option is `None` |
487
+ | `option` | `Option<b>` | The option to convert |
488
488
 
489
489
  Returns:
490
490
 
491
- |type|description|
492
- |----|-----------|
493
- |`Result<b, a>`|`Ok(value)` if the Option is `Some(value)` or `Err(err)` if the Option is `None`|
491
+ | type | description |
492
+ | -------------- | -------------------------------------------------------------------------------- |
493
+ | `Result<b, a>` | `Ok(value)` if the Option is `Some(value)` or `Err(err)` if the Option is `None` |
494
494
 
495
495
  ### Option.**sideEffect**
496
496
 
@@ -507,10 +507,10 @@ If the Option is `Some(value)`, applies the `fn` function to the `value` without
507
507
 
508
508
  Parameters:
509
509
 
510
- |param|type|description|
511
- |-----|----|-----------|
512
- |`fn`|`a => Void`|The function to call on the value of a `Some` variant|
513
- |`option`|`Option<a>`|The option to inspect|
510
+ | param | type | description |
511
+ | -------- | ----------- | ----------------------------------------------------- |
512
+ | `fn` | `a => Void` | The function to call on the value of a `Some` variant |
513
+ | `option` | `Option<a>` | The option to inspect |
514
514
 
515
515
  ### Option.**peek**
516
516
 
@@ -528,16 +528,16 @@ Useful for inspecting Options without changing anything.
528
528
 
529
529
  Parameters:
530
530
 
531
- |param|type|description|
532
- |-----|----|-----------|
533
- |`fn`|`a => Void`|The function to call on the value of a `Some` variant|
534
- |`option`|`Option<a>`|The option to inspect|
531
+ | param | type | description |
532
+ | -------- | ----------- | ----------------------------------------------------- |
533
+ | `fn` | `a => Void` | The function to call on the value of a `Some` variant |
534
+ | `option` | `Option<a>` | The option to inspect |
535
535
 
536
536
  Returns:
537
537
 
538
- |type|description|
539
- |----|-----------|
540
- |`Option<a>`|The unmodified option|
538
+ | type | description |
539
+ | ----------- | --------------------- |
540
+ | `Option<a>` | The unmodified option |
541
541
 
542
542
  ### Option.**(||)**
543
543
 
@@ -561,16 +561,16 @@ Behaves like a logical OR (`||`) where the first Option is only returned if it i
561
561
 
562
562
  Parameters:
563
563
 
564
- |param|type|description|
565
- |-----|----|-----------|
566
- |`optionA`|`Option<a>`|The first option|
567
- |`optionB`|`Option<a>`|The second option|
564
+ | param | type | description |
565
+ | --------- | ----------- | ----------------- |
566
+ | `optionA` | `Option<a>` | The first option |
567
+ | `optionB` | `Option<a>` | The second option |
568
568
 
569
569
  Returns:
570
570
 
571
- |type|description|
572
- |----|-----------|
573
- |`Option<a>`|The first Option if it is the `Some` variant or the second Option otherwise|
571
+ | type | description |
572
+ | ----------- | --------------------------------------------------------------------------- |
573
+ | `Option<a>` | The first Option if it is the `Some` variant or the second Option otherwise |
574
574
 
575
575
  ### Option.**(&&)**
576
576
 
@@ -594,14 +594,14 @@ Behaves like a logical AND (`&&`) where the first Option is only returned if it
594
594
 
595
595
  Parameters:
596
596
 
597
- |param|type|description|
598
- |-----|----|-----------|
599
- |`optionA`|`Option<a>`|The first option|
600
- |`optionB`|`Option<a>`|The second option|
597
+ | param | type | description |
598
+ | --------- | ----------- | ----------------- |
599
+ | `optionA` | `Option<a>` | The first option |
600
+ | `optionB` | `Option<a>` | The second option |
601
601
 
602
602
  Returns:
603
603
 
604
- |type|description|
605
- |----|-----------|
606
- |`Option<a>`|The second Option if both are the `Some` variant or the first Option otherwise|
604
+ | type | description |
605
+ | ----------- | ------------------------------------------------------------------------------ |
606
+ | `Option<a>` | The second Option if both are the `Some` variant or the first Option otherwise |
607
607
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grain/stdlib",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "The standard library for the Grain language.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://grain-lang.org",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {},
35
35
  "devDependencies": {
36
- "del-cli": "^4.0.1"
36
+ "del-cli": "^7.0.0"
37
37
  },
38
38
  "pkg": {
39
39
  "assets": "**/*.gr"