@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.
- package/CHANGELOG.md +18 -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 +2 -2
- package/path.gr +82 -65
- package/path.md +210 -141
- 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.gr +2 -19
- 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/uri.md
CHANGED
|
@@ -116,16 +116,16 @@ Percent-encodes characters in a string based on the specified `EncodeSet`.
|
|
|
116
116
|
|
|
117
117
|
Parameters:
|
|
118
118
|
|
|
119
|
-
|param|type|description|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
| param | type | description |
|
|
120
|
+
| ------------ | ----------- | -------------------------------------------------------------------------------------- |
|
|
121
|
+
| `str` | `String` | The string to encode |
|
|
122
|
+
| `?encodeSet` | `EncodeSet` | An indication for which characters to percent-encode. `EncodeNonUnreserved` by default |
|
|
123
123
|
|
|
124
124
|
Returns:
|
|
125
125
|
|
|
126
|
-
|type|description|
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
| type | description |
|
|
127
|
+
| -------- | -------------------------------------- |
|
|
128
|
+
| `String` | A percent-encoding of the given string |
|
|
129
129
|
|
|
130
130
|
Examples:
|
|
131
131
|
|
|
@@ -156,15 +156,15 @@ Decodes any percent-encoded characters in a string.
|
|
|
156
156
|
|
|
157
157
|
Parameters:
|
|
158
158
|
|
|
159
|
-
|param|type|description|
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
| param | type | description |
|
|
160
|
+
| ----- | -------- | -------------------- |
|
|
161
|
+
| `str` | `String` | The string to decode |
|
|
162
162
|
|
|
163
163
|
Returns:
|
|
164
164
|
|
|
165
|
-
|type|description|
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
| type | description |
|
|
166
|
+
| ------------------------------- | -------------------------------------------------------------------------------- |
|
|
167
|
+
| `Result<String, DecodingError>` | `Ok(decoded)` containing the decoded string or `Err(err)` if the decoding failed |
|
|
168
168
|
|
|
169
169
|
### Uri.**encodeQuery**
|
|
170
170
|
|
|
@@ -182,15 +182,15 @@ Encodes a list of key-value pairs into an query string.
|
|
|
182
182
|
|
|
183
183
|
Parameters:
|
|
184
184
|
|
|
185
|
-
|param|type|description|
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
| param | type | description |
|
|
186
|
+
| --------- | ------------------------ | ------------------------- |
|
|
187
|
+
| `urlVals` | `List<(String, String)>` | A list of key-value pairs |
|
|
188
188
|
|
|
189
189
|
Returns:
|
|
190
190
|
|
|
191
|
-
|type|description|
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
| type | description |
|
|
192
|
+
| -------- | -------------- |
|
|
193
|
+
| `String` | A query string |
|
|
194
194
|
|
|
195
195
|
### Uri.**decodeQuery**
|
|
196
196
|
|
|
@@ -207,15 +207,15 @@ Decodes a query string into a list of pairs.
|
|
|
207
207
|
|
|
208
208
|
Parameters:
|
|
209
209
|
|
|
210
|
-
|param|type|description|
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
| param | type | description |
|
|
211
|
+
| ----- | -------- | -------------- |
|
|
212
|
+
| `str` | `String` | A query string |
|
|
213
213
|
|
|
214
214
|
Returns:
|
|
215
215
|
|
|
216
|
-
|type|description|
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
| type | description |
|
|
217
|
+
| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
218
|
+
| `Result<List<(String, String)>, DecodingError>` | `Ok(decoded)` containing a list of key-value pairs from the decoded string or `Err(err)` if the decoding failed |
|
|
219
219
|
|
|
220
220
|
### Uri.**parse**
|
|
221
221
|
|
|
@@ -234,15 +234,15 @@ segments.
|
|
|
234
234
|
|
|
235
235
|
Parameters:
|
|
236
236
|
|
|
237
|
-
|param|type|description|
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
| param | type | description |
|
|
238
|
+
| ----- | -------- | -------------------------------- |
|
|
239
|
+
| `str` | `String` | The RFC 3986 URI string to parse |
|
|
240
240
|
|
|
241
241
|
Returns:
|
|
242
242
|
|
|
243
|
-
|type|description|
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
| type | description |
|
|
244
|
+
| ------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
245
|
+
| `Result<Uri, ParseError>` | `Ok(uri)` containing a `Uri` if the given string is a valid URI or `Err(ParseError)` otherwise |
|
|
246
246
|
|
|
247
247
|
Examples:
|
|
248
248
|
|
|
@@ -269,16 +269,16 @@ Transforms a base URI and a URI reference into a target URI
|
|
|
269
269
|
|
|
270
270
|
Parameters:
|
|
271
271
|
|
|
272
|
-
|param|type|description|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
272
|
+
| param | type | description |
|
|
273
|
+
| ------ | ----- | ------------------------------------------ |
|
|
274
|
+
| `base` | `Uri` | The base URI to resolve a URI reference on |
|
|
275
|
+
| `ref` | `Uri` | The URI reference to apply onto the base |
|
|
276
276
|
|
|
277
277
|
Returns:
|
|
278
278
|
|
|
279
|
-
|type|description|
|
|
280
|
-
|
|
281
|
-
|
|
279
|
+
| type | description |
|
|
280
|
+
| ------------------------------------ | ----------------------------------------------------------------------------- |
|
|
281
|
+
| `Result<Uri, ResolveReferenceError>` | `Ok(uri)` containing the target `Uri` or `Err(err)` if the input is malformed |
|
|
282
282
|
|
|
283
283
|
Examples:
|
|
284
284
|
|
|
@@ -313,16 +313,16 @@ Constructs a new `Uri` from components.
|
|
|
313
313
|
|
|
314
314
|
Parameters:
|
|
315
315
|
|
|
316
|
-
|param|type|description|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
316
|
+
| param | type | description |
|
|
317
|
+
| ------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
318
|
+
| `?scheme` | `Option<String>` | `Some(scheme)` containing the desired scheme component or `None` for a scheme-less URI |
|
|
319
|
+
| `?userinfo` | `Option<String>` | `Some(userinfo)` containing the desired userinfo component or `None` for a userinfo-less URI |
|
|
320
|
+
| `?host` | `Option<String>` | `Some(host)` containing the desired host component or `None` for a host-less URI |
|
|
321
|
+
| `?port` | `Option<Number>` | `Some(port)` containing the desired port component or `None` for a port-less URI |
|
|
322
|
+
| `?path` | `String` | The desired path for the URI. `""` by default |
|
|
323
|
+
| `?query` | `Option<String>` | `Some(query)` containing the desired query string component or `None` for a query-less URI |
|
|
324
|
+
| `?fragment` | `Option<String>` | `Some(fragment)` containing the desired fragment component or `None` for a fragment-less URI |
|
|
325
|
+
| `?encodeComponents` | `Bool` | Whether or not to apply percent encoding for each component to remove unsafe characters for each component |
|
|
326
326
|
|
|
327
327
|
Examples:
|
|
328
328
|
|
|
@@ -365,17 +365,17 @@ used for that component.
|
|
|
365
365
|
|
|
366
366
|
Parameters:
|
|
367
367
|
|
|
368
|
-
|param|type|description|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
368
|
+
| param | type | description |
|
|
369
|
+
| ------------------- | ------------------------ | ---------------------------------------------------------------------------------------------------------------- |
|
|
370
|
+
| `uri` | `Uri` | The `Uri` to update |
|
|
371
|
+
| `?scheme` | `Option<Option<String>>` | `Some(scheme)` containing the desired updated scheme component or `None` to maintain the base URI's scheme |
|
|
372
|
+
| `?userinfo` | `Option<Option<String>>` | `Some(userinfo)` containing the desired updated userinfo component or `None` to maintain the base URI's userinfo |
|
|
373
|
+
| `?host` | `Option<Option<String>>` | `Some(host)` containing the desired updated host component or `None` to maintain the base URI's host |
|
|
374
|
+
| `?port` | `Option<Option<Number>>` | `Some(port)` containing the desired updated port component or `None` to maintain the base URI's port |
|
|
375
|
+
| `?path` | `Option<String>` | `Some(path)` containing the desired updated path component or `None` to maintain the base URI's path |
|
|
376
|
+
| `?query` | `Option<Option<String>>` | `Some(query)` containing the desired updated query string component or `None` to maintain the base URI's query |
|
|
377
|
+
| `?fragment` | `Option<Option<String>>` | `Some(fragment)` containing the desired updated fragment component or `None` to maintain the base URI's fragment |
|
|
378
|
+
| `?encodeComponents` | `Bool` | Whether or not to apply percent encoding for each updated component to remove unsafe characters |
|
|
379
379
|
|
|
380
380
|
Examples:
|
|
381
381
|
|
|
@@ -414,15 +414,15 @@ Determines whether a `Uri` has an authority (i.e. has a host component)
|
|
|
414
414
|
|
|
415
415
|
Parameters:
|
|
416
416
|
|
|
417
|
-
|param|type|description|
|
|
418
|
-
|
|
419
|
-
|
|
417
|
+
| param | type | description |
|
|
418
|
+
| ----- | ----- | --------------------- |
|
|
419
|
+
| `uri` | `Uri` | The `Uri` to consider |
|
|
420
420
|
|
|
421
421
|
Returns:
|
|
422
422
|
|
|
423
|
-
|type|description|
|
|
424
|
-
|
|
425
|
-
|
|
423
|
+
| type | description |
|
|
424
|
+
| ------ | ------------------------------------------------------------------- |
|
|
425
|
+
| `Bool` | `true` if the `Uri` has an authority component or `false` otherwise |
|
|
426
426
|
|
|
427
427
|
### Uri.**isAbsolute**
|
|
428
428
|
|
|
@@ -439,15 +439,15 @@ Determines whether a `Uri` is an absolute URI (has a scheme component)
|
|
|
439
439
|
|
|
440
440
|
Parameters:
|
|
441
441
|
|
|
442
|
-
|param|type|description|
|
|
443
|
-
|
|
444
|
-
|
|
442
|
+
| param | type | description |
|
|
443
|
+
| ----- | ----- | --------------------- |
|
|
444
|
+
| `uri` | `Uri` | The `Uri` to consider |
|
|
445
445
|
|
|
446
446
|
Returns:
|
|
447
447
|
|
|
448
|
-
|type|description|
|
|
449
|
-
|
|
450
|
-
|
|
448
|
+
| type | description |
|
|
449
|
+
| ------ | ----------------------------------------------------------------------------- |
|
|
450
|
+
| `Bool` | `true` if the `Uri` is absolute (has a scheme component) or `false` otherwise |
|
|
451
451
|
|
|
452
452
|
### Uri.**toString**
|
|
453
453
|
|
|
@@ -464,13 +464,13 @@ Converts the given `Uri` into a string.
|
|
|
464
464
|
|
|
465
465
|
Parameters:
|
|
466
466
|
|
|
467
|
-
|param|type|description|
|
|
468
|
-
|
|
469
|
-
|
|
467
|
+
| param | type | description |
|
|
468
|
+
| ----- | ----- | -------------------- |
|
|
469
|
+
| `uri` | `Uri` | The `Uri` to convert |
|
|
470
470
|
|
|
471
471
|
Returns:
|
|
472
472
|
|
|
473
|
-
|type|description|
|
|
474
|
-
|
|
475
|
-
|
|
473
|
+
| type | description |
|
|
474
|
+
| -------- | ------------------------------------ |
|
|
475
|
+
| `String` | A string representation of the `Uri` |
|
|
476
476
|
|