@grain/stdlib 0.6.6 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/LICENSE +1 -1
  3. package/README.md +2 -2
  4. package/array.gr +55 -7
  5. package/array.md +123 -77
  6. package/bigint.md +30 -30
  7. package/buffer.gr +20 -53
  8. package/buffer.md +47 -47
  9. package/bytes.gr +111 -35
  10. package/bytes.md +111 -32
  11. package/char.gr +201 -99
  12. package/char.md +361 -34
  13. package/exception.gr +11 -11
  14. package/exception.md +26 -1
  15. package/float32.gr +327 -3
  16. package/float32.md +606 -19
  17. package/float64.gr +320 -3
  18. package/float64.md +606 -19
  19. package/fs.gr +1082 -0
  20. package/fs.md +630 -0
  21. package/hash.gr +142 -88
  22. package/hash.md +102 -14
  23. package/int16.md +23 -23
  24. package/int32.gr +25 -4
  25. package/int32.md +65 -30
  26. package/int64.gr +26 -1
  27. package/int64.md +65 -30
  28. package/int8.md +23 -23
  29. package/json.gr +366 -51
  30. package/json.md +418 -2
  31. package/list.gr +328 -31
  32. package/list.md +492 -69
  33. package/map.gr +20 -12
  34. package/map.md +44 -38
  35. package/marshal.gr +41 -40
  36. package/marshal.md +2 -2
  37. package/number.gr +159 -30
  38. package/number.md +215 -38
  39. package/option.md +21 -21
  40. package/package.json +5 -3
  41. package/path.gr +48 -0
  42. package/path.md +103 -12
  43. package/pervasives.gr +2 -2
  44. package/pervasives.md +37 -37
  45. package/priorityqueue.gr +7 -7
  46. package/priorityqueue.md +19 -19
  47. package/queue.gr +183 -29
  48. package/queue.md +296 -40
  49. package/random.md +6 -6
  50. package/range.gr +4 -4
  51. package/range.md +6 -6
  52. package/rational.md +16 -16
  53. package/regex.gr +52 -51
  54. package/regex.md +11 -11
  55. package/result.md +16 -16
  56. package/runtime/atof/common.md +39 -39
  57. package/runtime/atof/decimal.gr +6 -6
  58. package/runtime/atof/decimal.md +8 -8
  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 +1 -1
  71. package/runtime/dataStructures.md +33 -33
  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 +1 -1
  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 +4 -4
  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 +79 -73
  98. package/runtime/string.gr +37 -105
  99. package/runtime/string.md +3 -9
  100. package/runtime/unsafe/constants.md +24 -24
  101. package/runtime/unsafe/conv.md +13 -13
  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 +138 -138
  117. package/set.gr +18 -11
  118. package/set.md +42 -36
  119. package/stack.gr +171 -2
  120. package/stack.md +297 -15
  121. package/string.gr +352 -557
  122. package/string.md +77 -34
  123. package/uint16.md +22 -22
  124. package/uint32.gr +25 -4
  125. package/uint32.md +63 -28
  126. package/uint64.gr +25 -5
  127. package/uint64.md +63 -28
  128. package/uint8.md +22 -22
  129. package/uri.gr +57 -53
  130. package/uri.md +11 -12
  131. package/wasi/file.gr +67 -59
  132. package/wasi/file.md +39 -39
  133. package/wasi/process.md +5 -5
  134. package/wasi/random.md +3 -3
  135. package/wasi/time.md +4 -4
  136. package/runtime/utils/printing.gr +0 -60
  137. package/runtime/utils/printing.md +0 -26
package/number.md CHANGED
@@ -90,7 +90,7 @@ No other changes yet.
90
90
  </details>
91
91
 
92
92
  ```grain
93
- pi : Number
93
+ pi: Number
94
94
  ```
95
95
 
96
96
  Pi represented as a Number value.
@@ -103,7 +103,7 @@ No other changes yet.
103
103
  </details>
104
104
 
105
105
  ```grain
106
- tau : Number
106
+ tau: Number
107
107
  ```
108
108
 
109
109
  Tau represented as a Number value.
@@ -116,7 +116,7 @@ No other changes yet.
116
116
  </details>
117
117
 
118
118
  ```grain
119
- e : Number
119
+ e: Number
120
120
  ```
121
121
 
122
122
  Euler's number represented as a Number value.
@@ -136,7 +136,7 @@ Euler's number represented as a Number value.
136
136
  </details>
137
137
 
138
138
  ```grain
139
- (+) : (num1: Number, num2: Number) => Number
139
+ (+): (num1: Number, num2: Number) => Number
140
140
  ```
141
141
 
142
142
  Computes the sum of its operands.
@@ -176,7 +176,7 @@ assert 1 + 2 == 3
176
176
  </details>
177
177
 
178
178
  ```grain
179
- (-) : (num1: Number, num2: Number) => Number
179
+ (-): (num1: Number, num2: Number) => Number
180
180
  ```
181
181
 
182
182
  Computes the difference of its operands.
@@ -216,7 +216,7 @@ assert 5 - 2 == 3
216
216
  </details>
217
217
 
218
218
  ```grain
219
- (*) : (num1: Number, num2: Number) => Number
219
+ (*): (num1: Number, num2: Number) => Number
220
220
  ```
221
221
 
222
222
  Computes the product of its operands.
@@ -256,7 +256,7 @@ assert 5 * 4 == 20
256
256
  </details>
257
257
 
258
258
  ```grain
259
- (/) : (num1: Number, num2: Number) => Number
259
+ (/): (num1: Number, num2: Number) => Number
260
260
  ```
261
261
 
262
262
  Computes the quotient of its operands.
@@ -296,7 +296,7 @@ assert 10 / 2.5 == 4
296
296
  </details>
297
297
 
298
298
  ```grain
299
- (**) : (base: Number, power: Number) => Number
299
+ (**): (base: Number, power: Number) => Number
300
300
  ```
301
301
 
302
302
  Computes the exponentiation of the given base and power.
@@ -329,7 +329,7 @@ No other changes yet.
329
329
  </details>
330
330
 
331
331
  ```grain
332
- exp : (power: Number) => Number
332
+ exp: (power: Number) => Number
333
333
  ```
334
334
 
335
335
  Computes the exponentiation of Euler's number to the given power.
@@ -364,7 +364,7 @@ No other changes yet.
364
364
  </details>
365
365
 
366
366
  ```grain
367
- sqrt : (x: Number) => Number
367
+ sqrt: (x: Number) => Number
368
368
  ```
369
369
 
370
370
  Computes the square root of its operand.
@@ -395,7 +395,7 @@ No other changes yet.
395
395
  </details>
396
396
 
397
397
  ```grain
398
- sign : (x: Number) => Number
398
+ sign: (x: Number) => Number
399
399
  ```
400
400
 
401
401
  Determine the positivity or negativity of a Number.
@@ -441,7 +441,7 @@ Number.sign(0) == 0
441
441
  </details>
442
442
 
443
443
  ```grain
444
- min : (x: Number, y: Number) => Number
444
+ min: (x: Number, y: Number) => Number
445
445
  ```
446
446
 
447
447
  Returns the smaller of its operands.
@@ -480,7 +480,7 @@ Number.min(5, 2) == 2
480
480
  </details>
481
481
 
482
482
  ```grain
483
- max : (x: Number, y: Number) => Number
483
+ max: (x: Number, y: Number) => Number
484
484
  ```
485
485
 
486
486
  Returns the larger of its operands.
@@ -519,7 +519,7 @@ Number.max(5, 2) == 5
519
519
  </details>
520
520
 
521
521
  ```grain
522
- ceil : (x: Number) => Number
522
+ ceil: (x: Number) => Number
523
523
  ```
524
524
 
525
525
  Rounds its operand up to the next largest integer.
@@ -561,7 +561,7 @@ Number.ceil(-5.5) == -5
561
561
  </details>
562
562
 
563
563
  ```grain
564
- floor : (x: Number) => Number
564
+ floor: (x: Number) => Number
565
565
  ```
566
566
 
567
567
  Rounds its operand down to the largest integer less than the operand.
@@ -603,7 +603,7 @@ Number.floor(-5.5) == -6
603
603
  </details>
604
604
 
605
605
  ```grain
606
- trunc : (x: Number) => Number
606
+ trunc: (x: Number) => Number
607
607
  ```
608
608
 
609
609
  Returns the integer part of its operand, removing any fractional value.
@@ -641,7 +641,7 @@ Number.trunc(5.5) == 5
641
641
  </details>
642
642
 
643
643
  ```grain
644
- round : (x: Number) => Number
644
+ round: (x: Number) => Number
645
645
  ```
646
646
 
647
647
  Returns its operand rounded to its nearest integer.
@@ -684,7 +684,7 @@ No other changes yet.
684
684
  </details>
685
685
 
686
686
  ```grain
687
- abs : (x: Number) => Number
687
+ abs: (x: Number) => Number
688
688
  ```
689
689
 
690
690
  Returns the absolute value of a number. That is, it returns `x` if `x` is positive or zero and the negation of `x` if `x` is negative.
@@ -719,7 +719,7 @@ No other changes yet.
719
719
  </details>
720
720
 
721
721
  ```grain
722
- neg : (x: Number) => Number
722
+ neg: (x: Number) => Number
723
723
  ```
724
724
 
725
725
  Returns the negation of its operand.
@@ -754,7 +754,7 @@ No other changes yet.
754
754
  </details>
755
755
 
756
756
  ```grain
757
- isFloat : (x: Number) => Bool
757
+ isFloat: (x: Number) => Bool
758
758
  ```
759
759
 
760
760
  Checks if a number is a floating point value.
@@ -805,7 +805,7 @@ No other changes yet.
805
805
  </details>
806
806
 
807
807
  ```grain
808
- isInteger : (x: Number) => Bool
808
+ isInteger: (x: Number) => Bool
809
809
  ```
810
810
 
811
811
  Checks if a number is an integer.
@@ -856,7 +856,7 @@ No other changes yet.
856
856
  </details>
857
857
 
858
858
  ```grain
859
- isRational : (x: Number) => Bool
859
+ isRational: (x: Number) => Bool
860
860
  ```
861
861
 
862
862
  Checks if a number is a non-integer rational value.
@@ -907,7 +907,7 @@ No other changes yet.
907
907
  </details>
908
908
 
909
909
  ```grain
910
- isFinite : (x: Number) => Bool
910
+ isFinite: (x: Number) => Bool
911
911
  ```
912
912
 
913
913
  Checks if a number is finite.
@@ -963,7 +963,7 @@ No other changes yet.
963
963
  </details>
964
964
 
965
965
  ```grain
966
- isNaN : (x: Number) => Bool
966
+ isNaN: (x: Number) => Bool
967
967
  ```
968
968
 
969
969
  Checks if a number is the float NaN value (Not A Number).
@@ -1018,7 +1018,7 @@ No other changes yet.
1018
1018
  </details>
1019
1019
 
1020
1020
  ```grain
1021
- isInfinite : (x: Number) => Bool
1021
+ isInfinite: (x: Number) => Bool
1022
1022
  ```
1023
1023
 
1024
1024
  Checks if a number is infinite, that is either of floating point positive or negative infinity.
@@ -1074,7 +1074,7 @@ No other changes yet.
1074
1074
  </details>
1075
1075
 
1076
1076
  ```grain
1077
- isClose :
1077
+ isClose:
1078
1078
  (a: Number, b: Number, ?relativeTolerance: Number,
1079
1079
  ?absoluteTolerance: Number) => Bool
1080
1080
  ```
@@ -1145,7 +1145,7 @@ Number.isClose(4, 4.1, relativeTolerance=0.024) == false
1145
1145
  </details>
1146
1146
 
1147
1147
  ```grain
1148
- parseInt :
1148
+ parseInt:
1149
1149
  (string: String, radix: Number) => Result<Number, Atoi.ParseIntError>
1150
1150
  ```
1151
1151
 
@@ -1192,7 +1192,7 @@ No other changes yet.
1192
1192
  </details>
1193
1193
 
1194
1194
  ```grain
1195
- parseFloat : (string: String) => Result<Number, String>
1195
+ parseFloat: (string: String) => Result<Number, String>
1196
1196
  ```
1197
1197
 
1198
1198
  Parses a string representation of a float into a `Number`. Underscores that appear
@@ -1232,7 +1232,7 @@ No other changes yet.
1232
1232
  </details>
1233
1233
 
1234
1234
  ```grain
1235
- parse : (input: String) => Result<Number, Atoi.ParseIntError>
1235
+ parse: (input: String) => Result<Number, Atoi.ParseIntError>
1236
1236
  ```
1237
1237
 
1238
1238
  Parses a string representation of an integer, float, or rational into a `Number`.
@@ -1276,7 +1276,7 @@ No other changes yet.
1276
1276
  </details>
1277
1277
 
1278
1278
  ```grain
1279
- asin : (angle: Number) => Number
1279
+ asin: (angle: Number) => Number
1280
1280
  ```
1281
1281
 
1282
1282
  Computes the inverse sine of the given angle.
@@ -1311,7 +1311,7 @@ No other changes yet.
1311
1311
  </details>
1312
1312
 
1313
1313
  ```grain
1314
- acos : (angle: Number) => Number
1314
+ acos: (angle: Number) => Number
1315
1315
  ```
1316
1316
 
1317
1317
  Computes the inverse cosine of the given angle.
@@ -1346,7 +1346,7 @@ No other changes yet.
1346
1346
  </details>
1347
1347
 
1348
1348
  ```grain
1349
- atan : (angle: Number) => Number
1349
+ atan: (angle: Number) => Number
1350
1350
  ```
1351
1351
 
1352
1352
  Computes the inverse tangent of the given angle.
@@ -1381,7 +1381,7 @@ No other changes yet.
1381
1381
  </details>
1382
1382
 
1383
1383
  ```grain
1384
- atan2 : (y: Number, x: Number) => Number
1384
+ atan2: (y: Number, x: Number) => Number
1385
1385
  ```
1386
1386
 
1387
1387
  Computes the angle between the positive x-axis and the ray from the origin to the point (x, y).
@@ -1413,7 +1413,7 @@ No other changes yet.
1413
1413
  </details>
1414
1414
 
1415
1415
  ```grain
1416
- toRadians : (degrees: Number) => Number
1416
+ toRadians: (degrees: Number) => Number
1417
1417
  ```
1418
1418
 
1419
1419
  Converts degrees to radians.
@@ -1444,7 +1444,7 @@ No other changes yet.
1444
1444
  </details>
1445
1445
 
1446
1446
  ```grain
1447
- toDegrees : (radians: Number) => Number
1447
+ toDegrees: (radians: Number) => Number
1448
1448
  ```
1449
1449
 
1450
1450
  Converts radians to degrees.
@@ -1475,7 +1475,7 @@ No other changes yet.
1475
1475
  </details>
1476
1476
 
1477
1477
  ```grain
1478
- clamp : (range: Range<Number>, input: Number) => Number
1478
+ clamp: (range: Range<Number>, input: Number) => Number
1479
1479
  ```
1480
1480
 
1481
1481
  Constrains a number within the given inclusive range.
@@ -1501,7 +1501,7 @@ No other changes yet.
1501
1501
  </details>
1502
1502
 
1503
1503
  ```grain
1504
- linearInterpolate : (range: Range<Number>, weight: Number) => Number
1504
+ linearInterpolate: (range: Range<Number>, weight: Number) => Number
1505
1505
  ```
1506
1506
 
1507
1507
  Maps a weight between 0 and 1 within the given inclusive range.
@@ -1535,7 +1535,7 @@ No other changes yet.
1535
1535
  </details>
1536
1536
 
1537
1537
  ```grain
1538
- linearMap :
1538
+ linearMap:
1539
1539
  (inputRange: Range<Number>, outputRange: Range<Number>, current: Number) =>
1540
1540
  Number
1541
1541
  ```
@@ -1566,3 +1566,180 @@ Throws:
1566
1566
  * When `outputRange` is not finite
1567
1567
  * When `outputRange` includes NaN
1568
1568
 
1569
+ ### Number.**sin**
1570
+
1571
+ <details disabled>
1572
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
1573
+ No other changes yet.
1574
+ </details>
1575
+
1576
+ ```grain
1577
+ sin: (radians: Number) => Number
1578
+ ```
1579
+
1580
+ Computes the sine of a number (in radians).
1581
+
1582
+ Parameters:
1583
+
1584
+ |param|type|description|
1585
+ |-----|----|-----------|
1586
+ |`radians`|`Number`|The input in radians|
1587
+
1588
+ Returns:
1589
+
1590
+ |type|description|
1591
+ |----|-----------|
1592
+ |`Number`|The computed sine|
1593
+
1594
+ Examples:
1595
+
1596
+ ```grain
1597
+ Number.sin(0) == 0
1598
+ ```
1599
+
1600
+ ### Number.**cos**
1601
+
1602
+ <details disabled>
1603
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
1604
+ No other changes yet.
1605
+ </details>
1606
+
1607
+ ```grain
1608
+ cos: (radians: Number) => Number
1609
+ ```
1610
+
1611
+ Computes the cosine of a number (in radians).
1612
+
1613
+ Parameters:
1614
+
1615
+ |param|type|description|
1616
+ |-----|----|-----------|
1617
+ |`radians`|`Number`|The input in radians|
1618
+
1619
+ Returns:
1620
+
1621
+ |type|description|
1622
+ |----|-----------|
1623
+ |`Number`|The computed cosine|
1624
+
1625
+ Examples:
1626
+
1627
+ ```grain
1628
+ Number.cos(0) == 1
1629
+ ```
1630
+
1631
+ ### Number.**tan**
1632
+
1633
+ <details disabled>
1634
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
1635
+ No other changes yet.
1636
+ </details>
1637
+
1638
+ ```grain
1639
+ tan: (radians: Number) => Number
1640
+ ```
1641
+
1642
+ Computes the tangent of a number (in radians).
1643
+
1644
+ Parameters:
1645
+
1646
+ |param|type|description|
1647
+ |-----|----|-----------|
1648
+ |`radians`|`Number`|The input in radians|
1649
+
1650
+ Returns:
1651
+
1652
+ |type|description|
1653
+ |----|-----------|
1654
+ |`Number`|The computed tangent|
1655
+
1656
+ Examples:
1657
+
1658
+ ```grain
1659
+ Number.tan(0) == 0
1660
+ ```
1661
+
1662
+ ### Number.**gamma**
1663
+
1664
+ <details disabled>
1665
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
1666
+ No other changes yet.
1667
+ </details>
1668
+
1669
+ ```grain
1670
+ gamma: (z: Number) => Number
1671
+ ```
1672
+
1673
+ Computes the gamma function of a value using the Lanczos approximation.
1674
+
1675
+ Parameters:
1676
+
1677
+ |param|type|description|
1678
+ |-----|----|-----------|
1679
+ |`z`|`Number`|The value to interpolate|
1680
+
1681
+ Returns:
1682
+
1683
+ |type|description|
1684
+ |----|-----------|
1685
+ |`Number`|The gamma of the given value|
1686
+
1687
+ Examples:
1688
+
1689
+ ```grain
1690
+ Number.gamma(1) == 1
1691
+ ```
1692
+
1693
+ ```grain
1694
+ Number.gamma(3) == 2
1695
+ ```
1696
+
1697
+ ```grain
1698
+ Number.isClose(Number.gamma(0.5), Number.sqrt(Number.pi))
1699
+ ```
1700
+
1701
+ ### Number.**factorial**
1702
+
1703
+ <details disabled>
1704
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
1705
+ No other changes yet.
1706
+ </details>
1707
+
1708
+ ```grain
1709
+ factorial: (n: Number) => Number
1710
+ ```
1711
+
1712
+ Computes the factorial of an integer input or the gamma function of a non-integer input.
1713
+
1714
+ Parameters:
1715
+
1716
+ |param|type|description|
1717
+ |-----|----|-----------|
1718
+ |`n`|`Number`|The value to factorialize|
1719
+
1720
+ Returns:
1721
+
1722
+ |type|description|
1723
+ |----|-----------|
1724
+ |`Number`|The factorial of the given value|
1725
+
1726
+ Throws:
1727
+
1728
+ `InvalidArgument(String)`
1729
+
1730
+ * When `n` is a negative integer
1731
+
1732
+ Examples:
1733
+
1734
+ ```grain
1735
+ Number.factorial(0) == 1
1736
+ ```
1737
+
1738
+ ```grain
1739
+ Number.factorial(3) == 6
1740
+ ```
1741
+
1742
+ ```grain
1743
+ Number.isClose(Number.factorial(0.5), (1/2) * Number.sqrt(Number.pi))
1744
+ ```
1745
+
package/option.md CHANGED
@@ -35,7 +35,7 @@ No other changes yet.
35
35
  </details>
36
36
 
37
37
  ```grain
38
- isSome : (option: Option<a>) => Bool
38
+ isSome: (option: Option<a>) => Bool
39
39
  ```
40
40
 
41
41
  Checks if the Option is the `Some` variant.
@@ -60,7 +60,7 @@ No other changes yet.
60
60
  </details>
61
61
 
62
62
  ```grain
63
- isNone : (option: Option<a>) => Bool
63
+ isNone: (option: Option<a>) => Bool
64
64
  ```
65
65
 
66
66
  Checks if the Option is the `None` variant.
@@ -85,7 +85,7 @@ No other changes yet.
85
85
  </details>
86
86
 
87
87
  ```grain
88
- contains : (value: a, option: Option<a>) => Bool
88
+ contains: (value: a, option: Option<a>) => Bool
89
89
  ```
90
90
 
91
91
  Checks if the Option is the `Some` variant and contains the given value. Uses the generic `==` equality operator.
@@ -111,7 +111,7 @@ No other changes yet.
111
111
  </details>
112
112
 
113
113
  ```grain
114
- expect : (msg: String, option: Option<a>) => a
114
+ expect: (msg: String, option: Option<a>) => a
115
115
  ```
116
116
 
117
117
  Extracts the value inside a `Some` option, otherwise throws an
@@ -144,7 +144,7 @@ No other changes yet.
144
144
  </details>
145
145
 
146
146
  ```grain
147
- unwrap : (option: Option<a>) => a
147
+ unwrap: (option: Option<a>) => a
148
148
  ```
149
149
 
150
150
  Extracts the value inside a `Some` option, otherwise
@@ -176,7 +176,7 @@ No other changes yet.
176
176
  </details>
177
177
 
178
178
  ```grain
179
- unwrapWithDefault : (default: a, option: Option<a>) => a
179
+ unwrapWithDefault: (default: a, option: Option<a>) => a
180
180
  ```
181
181
 
182
182
  Extracts the value inside a `Some` option or provide the default value if `None`.
@@ -202,7 +202,7 @@ No other changes yet.
202
202
  </details>
203
203
 
204
204
  ```grain
205
- map : (fn: (a => b), option: Option<a>) => Option<b>
205
+ map: (fn: (a => b), option: Option<a>) => Option<b>
206
206
  ```
207
207
 
208
208
  If the Option is `Some(value)`, applies the given function to the `value` and wraps the new value in a `Some` variant.
@@ -228,7 +228,7 @@ No other changes yet.
228
228
  </details>
229
229
 
230
230
  ```grain
231
- mapWithDefault : (fn: (a => b), default: b, option: Option<a>) => b
231
+ mapWithDefault: (fn: (a => b), default: b, option: Option<a>) => b
232
232
  ```
233
233
 
234
234
  If the Option is `Some(value)`, applies the given function to the `value` to produce a new value, otherwise uses the default value.
@@ -256,7 +256,7 @@ No other changes yet.
256
256
  </details>
257
257
 
258
258
  ```grain
259
- mapWithDefaultFn :
259
+ mapWithDefaultFn:
260
260
  (fn: (a => b), defaultFn: (() => b), option: Option<a>) => b
261
261
  ```
262
262
 
@@ -286,7 +286,7 @@ No other changes yet.
286
286
  </details>
287
287
 
288
288
  ```grain
289
- flatMap : (fn: (a => Option<b>), option: Option<a>) => Option<b>
289
+ flatMap: (fn: (a => Option<b>), option: Option<a>) => Option<b>
290
290
  ```
291
291
 
292
292
  If the Option is `Some(value)`, applies the given function to the `value` to produce a new Option.
@@ -312,7 +312,7 @@ No other changes yet.
312
312
  </details>
313
313
 
314
314
  ```grain
315
- filter : (fn: (a => Bool), option: Option<a>) => Option<a>
315
+ filter: (fn: (a => Bool), option: Option<a>) => Option<a>
316
316
  ```
317
317
 
318
318
  Converts `Some(value)` variants to `None` variants where the predicate function returns `false`.
@@ -339,7 +339,7 @@ No other changes yet.
339
339
  </details>
340
340
 
341
341
  ```grain
342
- zip : (optionA: Option<a>, optionB: Option<b>) => Option<(a, b)>
342
+ zip: (optionA: Option<a>, optionB: Option<b>) => Option<(a, b)>
343
343
  ```
344
344
 
345
345
  Combine two Options into a single Option containing a tuple of their values.
@@ -365,7 +365,7 @@ No other changes yet.
365
365
  </details>
366
366
 
367
367
  ```grain
368
- zipWith :
368
+ zipWith:
369
369
  (fn: ((a, b) => c), optionA: Option<a>, optionB: Option<b>) => Option<c>
370
370
  ```
371
371
 
@@ -393,7 +393,7 @@ No other changes yet.
393
393
  </details>
394
394
 
395
395
  ```grain
396
- flatten : (option: Option<Option<a>>) => Option<a>
396
+ flatten: (option: Option<Option<a>>) => Option<a>
397
397
  ```
398
398
 
399
399
  Flattens nested Options.
@@ -424,7 +424,7 @@ No other changes yet.
424
424
  </details>
425
425
 
426
426
  ```grain
427
- toList : (option: Option<a>) => List<a>
427
+ toList: (option: Option<a>) => List<a>
428
428
  ```
429
429
 
430
430
  Converts an Option to a list with either zero or one item.
@@ -449,7 +449,7 @@ No other changes yet.
449
449
  </details>
450
450
 
451
451
  ```grain
452
- toArray : (option: Option<a>) => Array<a>
452
+ toArray: (option: Option<a>) => Array<a>
453
453
  ```
454
454
 
455
455
  Converts an Option to an array with either zero or one item.
@@ -474,7 +474,7 @@ No other changes yet.
474
474
  </details>
475
475
 
476
476
  ```grain
477
- toResult : (err: a, option: Option<b>) => Result<b, a>
477
+ toResult: (err: a, option: Option<b>) => Result<b, a>
478
478
  ```
479
479
 
480
480
  Converts the Option to a Result, using the provided error in case of the `None` variant.
@@ -500,7 +500,7 @@ No other changes yet.
500
500
  </details>
501
501
 
502
502
  ```grain
503
- sideEffect : (fn: (a => Void), option: Option<a>) => Void
503
+ sideEffect: (fn: (a => Void), option: Option<a>) => Void
504
504
  ```
505
505
 
506
506
  If the Option is `Some(value)`, applies the `fn` function to the `value` without producing a new value.
@@ -520,7 +520,7 @@ No other changes yet.
520
520
  </details>
521
521
 
522
522
  ```grain
523
- peek : (fn: (a => Void), option: Option<a>) => Option<a>
523
+ peek: (fn: (a => Void), option: Option<a>) => Option<a>
524
524
  ```
525
525
 
526
526
  If the Option is `Some(value)`, applies the `fn` function to the `value` without producing a new value.
@@ -554,7 +554,7 @@ Returns:
554
554
  </details>
555
555
 
556
556
  ```grain
557
- (||) : (optionA: Option<a>, optionB: Option<a>) => Option<a>
557
+ (||): (optionA: Option<a>, optionB: Option<a>) => Option<a>
558
558
  ```
559
559
 
560
560
  Behaves like a logical OR (`||`) where the first Option is only returned if it is the `Some` variant and falling back to the second Option in all other cases.
@@ -587,7 +587,7 @@ Returns:
587
587
  </details>
588
588
 
589
589
  ```grain
590
- (&&) : (optionA: Option<a>, optionB: Option<a>) => Option<a>
590
+ (&&): (optionA: Option<a>, optionB: Option<a>) => Option<a>
591
591
  ```
592
592
 
593
593
  Behaves like a logical AND (`&&`) where the first Option is only returned if it is the `None` variant and falling back to the second Option Result in all other cases.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grain/stdlib",
3
- "version": "0.6.6",
3
+ "version": "0.7.0",
4
4
  "description": "The standard library for the Grain language.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://grain-lang.org",
@@ -18,7 +18,7 @@
18
18
  "directory": "stdlib"
19
19
  },
20
20
  "engines": {
21
- "node": ">=18.15"
21
+ "node": ">=22.13"
22
22
  },
23
23
  "main": "index.js",
24
24
  "files": [
@@ -27,7 +27,9 @@
27
27
  "index.js"
28
28
  ],
29
29
  "scripts": {
30
- "clean": "del-cli \"**/*.wasm\" \"**/*.wat\" \"**/*.modsig\""
30
+ "clean": "del-cli \"**/*.wasm\" \"**/*.wat\" \"**/*.gro\" \"**/*.modsig\"",
31
+ "doc": "grain doc ./ -o ./ --current-version=$(grain -v)",
32
+ "format": "grain format ./ -o ./"
31
33
  },
32
34
  "dependencies": {},
33
35
  "devDependencies": {