@grain/stdlib 0.7.0 → 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 (60) hide show
  1. package/CHANGELOG.md +10 -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 +1 -1
  28. package/path.md +90 -90
  29. package/pervasives.md +238 -238
  30. package/priorityqueue.md +112 -112
  31. package/queue.md +117 -117
  32. package/random.md +37 -37
  33. package/range.md +36 -36
  34. package/rational.md +107 -107
  35. package/regex.md +91 -91
  36. package/result.md +102 -102
  37. package/runtime/atof/decimal.md +6 -6
  38. package/runtime/compare.md +7 -7
  39. package/runtime/dataStructures.md +178 -178
  40. package/runtime/equal.md +7 -7
  41. package/runtime/exception.md +15 -15
  42. package/runtime/malloc.md +9 -9
  43. package/runtime/numbers.md +269 -269
  44. package/runtime/string.md +17 -17
  45. package/runtime/unsafe/conv.md +6 -6
  46. package/runtime/unsafe/memory.md +10 -10
  47. package/runtime/utf8.md +31 -31
  48. package/runtime/wasi.md +9 -9
  49. package/set.md +211 -211
  50. package/stack.md +122 -122
  51. package/string.md +228 -228
  52. package/uint16.md +148 -148
  53. package/uint32.md +192 -192
  54. package/uint64.md +192 -192
  55. package/uint8.md +148 -148
  56. package/uri.md +77 -77
  57. package/wasi/file.md +269 -269
  58. package/wasi/process.md +21 -21
  59. package/wasi/random.md +9 -9
  60. package/wasi/time.md +12 -12
package/marshal.md CHANGED
@@ -46,15 +46,15 @@ deserialized at a later time to restore the value.
46
46
 
47
47
  Parameters:
48
48
 
49
- |param|type|description|
50
- |-----|----|-----------|
51
- |`value`|`a`|The value to serialize|
49
+ | param | type | description |
50
+ | ------- | ---- | ---------------------- |
51
+ | `value` | `a` | The value to serialize |
52
52
 
53
53
  Returns:
54
54
 
55
- |type|description|
56
- |----|-----------|
57
- |`Bytes`|A byte-based representation of the value|
55
+ | type | description |
56
+ | ------- | ---------------------------------------- |
57
+ | `Bytes` | A byte-based representation of the value |
58
58
 
59
59
  Examples:
60
60
 
@@ -86,15 +86,15 @@ unmarshaled corresponds to the expected type.
86
86
 
87
87
  Parameters:
88
88
 
89
- |param|type|description|
90
- |-----|----|-----------|
91
- |`bytes`|`Bytes`|The data to deserialize|
89
+ | param | type | description |
90
+ | ------- | ------- | ----------------------- |
91
+ | `bytes` | `Bytes` | The data to deserialize |
92
92
 
93
93
  Returns:
94
94
 
95
- |type|description|
96
- |----|-----------|
97
- |`Result<a, String>`|An in-memory value|
95
+ | type | description |
96
+ | ------------------- | ------------------ |
97
+ | `Result<a, String>` | An in-memory value |
98
98
 
99
99
  Examples:
100
100
 
package/number.gr CHANGED
@@ -83,7 +83,7 @@ provide let e = 2.718281828459045
83
83
  * @returns The sum of the two operands
84
84
  *
85
85
  * @example
86
- * from Number use { (+) }
86
+ * use Number.{ (+) }
87
87
  * assert 1 + 2 == 3
88
88
  *
89
89
  * @since v0.6.0
@@ -99,7 +99,7 @@ provide let (+) = (+)
99
99
  * @returns The difference of the two operands
100
100
  *
101
101
  * @example
102
- * from Number use { (-) }
102
+ * use Number.{ (-) }
103
103
  * assert 5 - 2 == 3
104
104
  *
105
105
  * @since v0.6.0
@@ -115,7 +115,7 @@ provide let (-) = (-)
115
115
  * @returns The product of the two operands
116
116
  *
117
117
  * @example
118
- * from Number use { (*) }
118
+ * use Number.{ (*) }
119
119
  * assert 5 * 4 == 20
120
120
  *
121
121
  * @since v0.6.0
@@ -131,7 +131,7 @@ provide let (*) = (*)
131
131
  * @returns The quotient of the two operands
132
132
  *
133
133
  * @example
134
- * from Number use { (/) }
134
+ * use Number.{ (/) }
135
135
  * assert 10 / 2.5 == 4
136
136
  *
137
137
  * @since v0.6.0
@@ -139,6 +139,22 @@ provide let (*) = (*)
139
139
  */
140
140
  provide let (/) = (/)
141
141
 
142
+ /**
143
+ * Computes the remainder of the division of the first operand by the second.
144
+ * The result will have the sign of the second operand.
145
+ *
146
+ * @param num1: The first operand
147
+ * @param num2: The second operand
148
+ * @returns The modulus of its operands
149
+ *
150
+ * @example
151
+ * use Number.{ (%) }
152
+ * assert 10 % 3 == 1
153
+ *
154
+ * @since v0.7.1
155
+ */
156
+ provide let (%) = (%)
157
+
142
158
  /**
143
159
  * Computes the exponentiation of the given base and power.
144
160
  *
@@ -147,7 +163,7 @@ provide let (/) = (/)
147
163
  * @returns The base raised to the given power
148
164
  *
149
165
  * @example
150
- * from Number use { (**) }
166
+ * use Number.{ (**) }
151
167
  * assert 10 ** 2 == 100
152
168
  *
153
169
  * @since v0.6.0
@@ -155,6 +171,104 @@ provide let (/) = (/)
155
171
  */
156
172
  provide let (**) = (**)
157
173
 
174
+ /**
175
+ * Checks if the first value is equal to the second value.
176
+ *
177
+ * @param x: The first value
178
+ * @param y: The second value
179
+ * @returns `true` if the first value is equal to the second value or `false` otherwise
180
+ *
181
+ * @example
182
+ * use Number.{ (==) }
183
+ * assert 1 == 1
184
+ *
185
+ * @since v0.7.1
186
+ */
187
+ provide let (==) = Numbers.numberEq
188
+
189
+ /**
190
+ * Checks if the first value is equal to the second value.
191
+ *
192
+ * @param x: The first value
193
+ * @param y: The second value
194
+ * @returns `true` if the first value is equal to the second value or `false` otherwise
195
+ *
196
+ * @example
197
+ * use Number.{ (==) }
198
+ * assert 1 == 1
199
+ *
200
+ * @since v0.7.1
201
+ */
202
+ provide let (!=) = (x, y) => !Numbers.numberEq(x, y)
203
+
204
+ /**
205
+ * Checks if the first value is less than the second value.
206
+ *
207
+ * @param num1: The first value
208
+ * @param num2: The second value
209
+ * @returns `true` if the first value is less than the second value or `false` otherwise
210
+ *
211
+ * @example
212
+ * use Number.{ (<) }
213
+ * assert 1 < 5
214
+ *
215
+ * @since v0.7.1
216
+ */
217
+ provide let (<) = (<)
218
+
219
+ /**
220
+ * Checks if the first value is greater than the second value.
221
+ *
222
+ * @param num1: The first value
223
+ * @param num2: The second value
224
+ * @returns `true` if the first value is greater than the second value or `false` otherwise
225
+ *
226
+ * @example
227
+ * use Number.{ (>) }
228
+ * assert 5 > 1
229
+ *
230
+ * @since v0.7.1
231
+ */
232
+ provide let (>) = (>)
233
+
234
+ /**
235
+ * Checks if the first value is less than or equal to the second value.
236
+ *
237
+ * @param num1: The first value
238
+ * @param num2: The second value
239
+ * @returns `true` if the first value is less than or equal to the second value or `false` otherwise
240
+ *
241
+ * @example
242
+ * use Number.{ (<=) }
243
+ * assert 1 <= 2
244
+ * @example
245
+ * use Number.{ (<=) }
246
+ * assert 1 <= 1
247
+ *
248
+ * @since v0.7.1
249
+ */
250
+ @unsafe
251
+ provide let (<=) = (<=)
252
+
253
+ /**
254
+ * Checks if the first value is greater than or equal to the second value.
255
+ *
256
+ * @param num1: The first value
257
+ * @param num2: The second value
258
+ * @returns `true` if the first value is greater than or equal to the second value or `false` otherwise
259
+ *
260
+ * @example
261
+ * use Number.{ (>=) }
262
+ * assert 3 >= 2
263
+ * @example
264
+ * use Number.{ (>=) }
265
+ * assert 1 >= 1
266
+ *
267
+ * @since v0.7.1
268
+ */
269
+ @unsafe
270
+ provide let (>=) = (>=)
271
+
158
272
  /**
159
273
  * Computes the exponentiation of Euler's number to the given power.
160
274
  *