@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.
- package/CHANGELOG.md +10 -0
- package/array.md +491 -491
- package/bigint.md +198 -198
- package/buffer.gr +66 -1
- package/buffer.md +395 -272
- package/bytes.gr +1 -0
- package/bytes.md +200 -199
- package/char.md +125 -125
- package/exception.md +9 -9
- package/float32.md +195 -195
- package/float64.md +195 -195
- package/fs.md +115 -115
- package/hash.md +16 -16
- package/int16.md +155 -155
- package/int32.gr +1 -1
- package/int32.md +207 -207
- package/int64.gr +1 -1
- package/int64.md +207 -207
- package/int8.md +155 -155
- package/json.md +59 -59
- package/list.md +347 -347
- package/map.md +222 -222
- package/marshal.md +12 -12
- package/number.gr +119 -5
- package/number.md +503 -261
- package/option.md +141 -141
- package/package.json +1 -1
- package/path.md +90 -90
- package/pervasives.md +238 -238
- package/priorityqueue.md +112 -112
- package/queue.md +117 -117
- package/random.md +37 -37
- package/range.md +36 -36
- package/rational.md +107 -107
- package/regex.md +91 -91
- package/result.md +102 -102
- package/runtime/atof/decimal.md +6 -6
- package/runtime/compare.md +7 -7
- package/runtime/dataStructures.md +178 -178
- package/runtime/equal.md +7 -7
- package/runtime/exception.md +15 -15
- package/runtime/malloc.md +9 -9
- package/runtime/numbers.md +269 -269
- package/runtime/string.md +17 -17
- package/runtime/unsafe/conv.md +6 -6
- package/runtime/unsafe/memory.md +10 -10
- package/runtime/utf8.md +31 -31
- package/runtime/wasi.md +9 -9
- package/set.md +211 -211
- package/stack.md +122 -122
- package/string.md +228 -228
- package/uint16.md +148 -148
- package/uint32.md +192 -192
- package/uint64.md +192 -192
- package/uint8.md +148 -148
- package/uri.md +77 -77
- package/wasi/file.md +269 -269
- package/wasi/process.md +21 -21
- package/wasi/random.md +9 -9
- 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
|
-
|
|
49
|
+
| param | type | description |
|
|
50
|
+
| ------- | ---- | ---------------------- |
|
|
51
|
+
| `value` | `a` | The value to serialize |
|
|
52
52
|
|
|
53
53
|
Returns:
|
|
54
54
|
|
|
55
|
-
|type|description|
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
89
|
+
| param | type | description |
|
|
90
|
+
| ------- | ------- | ----------------------- |
|
|
91
|
+
| `bytes` | `Bytes` | The data to deserialize |
|
|
92
92
|
|
|
93
93
|
Returns:
|
|
94
94
|
|
|
95
|
-
|type|description|
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
*
|