@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/fs.md
CHANGED
|
@@ -154,13 +154,13 @@ Represents metadata about a file.
|
|
|
154
154
|
|
|
155
155
|
Fields:
|
|
156
156
|
|
|
157
|
-
|name|type|description|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
157
|
+
| name | type | description |
|
|
158
|
+
| ------------------- | ---------- | ------------------------------------------------ |
|
|
159
|
+
| `fileType` | `FileType` | |
|
|
160
|
+
| `size` | `Number` | File size in bytes |
|
|
161
|
+
| `accessedTimestamp` | `Number` | Last accessed timestamp in nanoseconds |
|
|
162
|
+
| `modifiedTimestamp` | `Number` | Last modified timestamp in nanoseconds |
|
|
163
|
+
| `changedTimestamp` | `Number` | Last file status change timestamp in nanoseconds |
|
|
164
164
|
|
|
165
165
|
### Fs.**DirectoryEntry**
|
|
166
166
|
|
|
@@ -228,17 +228,17 @@ Removes a file or directory.
|
|
|
228
228
|
|
|
229
229
|
Parameters:
|
|
230
230
|
|
|
231
|
-
|param|type|description|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
231
|
+
| param | type | description |
|
|
232
|
+
| -------------- | ------------------- | --------------------------------------------------------- |
|
|
233
|
+
| `?removeMode` | `RemoveMode` | The type of removal to perform; `RemoveFile` by default |
|
|
234
|
+
| `?baseDirPath` | `Option<Path.Path>` | The path to the directory in which path resolution starts |
|
|
235
|
+
| `path` | `Path.Path` | The path of the file or directory to remove |
|
|
236
236
|
|
|
237
237
|
Returns:
|
|
238
238
|
|
|
239
|
-
|type|description|
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
| type | description |
|
|
240
|
+
| ------------------------- | -------------------------------------------------------------------------------------- |
|
|
241
|
+
| `Result<Void, FileError>` | `Ok(void)` if the operation succeeds, `Err(err)` if a file system error is encountered |
|
|
242
242
|
|
|
243
243
|
Examples:
|
|
244
244
|
|
|
@@ -271,16 +271,16 @@ Reads the contents of a directory.
|
|
|
271
271
|
|
|
272
272
|
Parameters:
|
|
273
273
|
|
|
274
|
-
|param|type|description|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
| param | type | description |
|
|
275
|
+
| -------------- | ------------------- | ---------------------------------------------------------- |
|
|
276
|
+
| `?baseDirPath` | `Option<Path.Path>` | The path to the directory in which resolution should begin |
|
|
277
|
+
| `path` | `Path.Path` | The path to the directory to read |
|
|
278
278
|
|
|
279
279
|
Returns:
|
|
280
280
|
|
|
281
|
-
|type|description|
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
| type | description |
|
|
282
|
+
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
283
|
+
| `Result<List<DirectoryEntry>, FileError>` | `Ok(contents)` containing the directory contents or `Err(err)` if a file system error is encountered |
|
|
284
284
|
|
|
285
285
|
### Fs.**createDir**
|
|
286
286
|
|
|
@@ -299,16 +299,16 @@ Creates a new empty directory at the given path.
|
|
|
299
299
|
|
|
300
300
|
Parameters:
|
|
301
301
|
|
|
302
|
-
|param|type|description|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
302
|
+
| param | type | description |
|
|
303
|
+
| -------------- | ------------------- | -------------------------------------------------------------------- |
|
|
304
|
+
| `?baseDirPath` | `Option<Path.Path>` | The path to the directory in which resolution should begin |
|
|
305
|
+
| `path` | `Path.Path` | The path to create the new directory, relative to the base directory |
|
|
306
306
|
|
|
307
307
|
Returns:
|
|
308
308
|
|
|
309
|
-
|type|description|
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
| type | description |
|
|
310
|
+
| ------------------------- | -------------------------------------------------------------------------------------- |
|
|
311
|
+
| `Result<Void, FileError>` | `Ok(void)` if the operation succeeds, `Err(err)` if a file system error is encountered |
|
|
312
312
|
|
|
313
313
|
### Fs.**createSymlink**
|
|
314
314
|
|
|
@@ -327,17 +327,17 @@ Creates a new symbolic link with the given contents.
|
|
|
327
327
|
|
|
328
328
|
Parameters:
|
|
329
329
|
|
|
330
|
-
|param|type|description|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
330
|
+
| param | type | description |
|
|
331
|
+
| -------------------- | ------------------- | -------------------------------------------------------------------- |
|
|
332
|
+
| `linkContents` | `Path.Path` | The path to store into the link |
|
|
333
|
+
| `?targetBaseDirPath` | `Option<Path.Path>` | The path to the directory in which the target path resolution starts |
|
|
334
|
+
| `targetPath` | `Path.Path` | The path to the target of the link |
|
|
335
335
|
|
|
336
336
|
Returns:
|
|
337
337
|
|
|
338
|
-
|type|description|
|
|
339
|
-
|
|
340
|
-
|
|
338
|
+
| type | description |
|
|
339
|
+
| ------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
340
|
+
| `Result<Void, FileError>` | `Ok(void)` if the operation succeeds, `Err(err)` if a file system error or relativization error is encountered |
|
|
341
341
|
|
|
342
342
|
### Fs.**stats**
|
|
343
343
|
|
|
@@ -356,17 +356,17 @@ Queries information about a file.
|
|
|
356
356
|
|
|
357
357
|
Parameters:
|
|
358
358
|
|
|
359
|
-
|param|type|description|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
359
|
+
| param | type | description |
|
|
360
|
+
| ---------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
361
|
+
| `?followSymlink` | `Bool` | Whether to follow symlinks or not; if `true` then the stats of a valid symlink's underlying file will be returned. `true` by default |
|
|
362
|
+
| `?baseDirPath` | `Option<Path.Path>` | The path to the directory in which the path resolution starts |
|
|
363
|
+
| `path` | `Path.Path` | The path of the file to query |
|
|
364
364
|
|
|
365
365
|
Returns:
|
|
366
366
|
|
|
367
|
-
|type|description|
|
|
368
|
-
|
|
369
|
-
|
|
367
|
+
| type | description |
|
|
368
|
+
| -------------------------- | ----------------------------------------------------------------------------------- |
|
|
369
|
+
| `Result<Stats, FileError>` | `Ok(stats)` containing metadata or `Err(err)` if a file system error is encountered |
|
|
370
370
|
|
|
371
371
|
### Fs.**exists**
|
|
372
372
|
|
|
@@ -383,16 +383,16 @@ Polls whether or not a file or directory exists at the given path.
|
|
|
383
383
|
|
|
384
384
|
Parameters:
|
|
385
385
|
|
|
386
|
-
|param|type|description|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
386
|
+
| param | type | description |
|
|
387
|
+
| -------------- | ------------------- | ------------------------------------------------------------- |
|
|
388
|
+
| `?baseDirPath` | `Option<Path.Path>` | The path to the directory in which the path resolution starts |
|
|
389
|
+
| `path` | `Path.Path` | The path of the file to query |
|
|
390
390
|
|
|
391
391
|
Returns:
|
|
392
392
|
|
|
393
|
-
|type|description|
|
|
394
|
-
|
|
395
|
-
|
|
393
|
+
| type | description |
|
|
394
|
+
| ------ | --------------------------------------------------------------------- |
|
|
395
|
+
| `Bool` | `true` if a file or directory exists at the path or `false` otherwise |
|
|
396
396
|
|
|
397
397
|
### Fs.**readLink**
|
|
398
398
|
|
|
@@ -411,16 +411,16 @@ Reads the contents of a symbolic link.
|
|
|
411
411
|
|
|
412
412
|
Parameters:
|
|
413
413
|
|
|
414
|
-
|param|type|description|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
414
|
+
| param | type | description |
|
|
415
|
+
| -------------- | ------------------- | -------------------------------------------------- |
|
|
416
|
+
| `?baseDirPath` | `Option<Path.Path>` | The path to the directory to begin path resolution |
|
|
417
|
+
| `path` | `Path.Path` | The path to the link to read |
|
|
418
418
|
|
|
419
419
|
Returns:
|
|
420
420
|
|
|
421
|
-
|type|description|
|
|
422
|
-
|
|
423
|
-
|
|
421
|
+
| type | description |
|
|
422
|
+
| ------------------------------ | ------------------------------------------------------------------------------------------- |
|
|
423
|
+
| `Result<Path.Path, FileError>` | `Ok(path)` containing the link contents or `Err(err)` if a file system error is encountered |
|
|
424
424
|
|
|
425
425
|
### Fs.**copy**
|
|
426
426
|
|
|
@@ -436,20 +436,20 @@ Copies a file or directory.
|
|
|
436
436
|
|
|
437
437
|
Parameters:
|
|
438
438
|
|
|
439
|
-
|param|type|description|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
439
|
+
| param | type | description |
|
|
440
|
+
| -------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
441
|
+
| `?copyMode` | `CopyMode` | The type of copy to perform; `CopyFile` by default |
|
|
442
|
+
| `?followSymlink` | `Bool` | Whether to follow symlinks or not; if `true` then the stats of a valid symlink's underlying file will be returned. `true` by default |
|
|
443
|
+
| `?sourceBaseDirPath` | `Option<Path.Path>` | The path to the directory in which the source path resolution starts |
|
|
444
|
+
| `sourcePath` | `Path.Path` | The path of the file or directory to copy |
|
|
445
|
+
| `?targetBaseDirPath` | `Option<Path.Path>` | The path to the directory in which the target path resolution starts |
|
|
446
|
+
| `targetPath` | `Path.Path` | The path to copy the file or directory to |
|
|
447
447
|
|
|
448
448
|
Returns:
|
|
449
449
|
|
|
450
|
-
|type|description|
|
|
451
|
-
|
|
452
|
-
|
|
450
|
+
| type | description |
|
|
451
|
+
| ------------------------- | -------------------------------------------------------------------------------------- |
|
|
452
|
+
| `Result<Void, FileError>` | `Ok(void)` if the operation succeeds, `Err(err)` if a file system error is encountered |
|
|
453
453
|
|
|
454
454
|
### Fs.**rename**
|
|
455
455
|
|
|
@@ -469,18 +469,18 @@ Renames a file or directory.
|
|
|
469
469
|
|
|
470
470
|
Parameters:
|
|
471
471
|
|
|
472
|
-
|param|type|description|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
472
|
+
| param | type | description |
|
|
473
|
+
| -------------------- | ------------------- | -------------------------------------------------------------------- |
|
|
474
|
+
| `?sourceBaseDirPath` | `Option<Path.Path>` | The path to the directory in which the source path resolution starts |
|
|
475
|
+
| `sourcePath` | `Path.Path` | The path of the file to rename |
|
|
476
|
+
| `?targetBaseDirPath` | `Option<Path.Path>` | The path to the directory in which the target path resolution starts |
|
|
477
|
+
| `targetPath` | `Path.Path` | The new path of the file |
|
|
478
478
|
|
|
479
479
|
Returns:
|
|
480
480
|
|
|
481
|
-
|type|description|
|
|
482
|
-
|
|
483
|
-
|
|
481
|
+
| type | description |
|
|
482
|
+
| ------------------------- | -------------------------------------------------------------------------------------- |
|
|
483
|
+
| `Result<Void, FileError>` | `Ok(void)` if the operation succeeds, `Err(err)` if a file system error is encountered |
|
|
484
484
|
|
|
485
485
|
## Fs.Binary
|
|
486
486
|
|
|
@@ -512,17 +512,17 @@ Read the contents of a file as `Bytes`.
|
|
|
512
512
|
|
|
513
513
|
Parameters:
|
|
514
514
|
|
|
515
|
-
|param|type|description|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
515
|
+
| param | type | description |
|
|
516
|
+
| -------------- | ------------------- | -------------------------------------------------- |
|
|
517
|
+
| `?sync` | `Bool` | Whether to synchronously read; `true` by default |
|
|
518
|
+
| `?baseDirPath` | `Option<Path.Path>` | The path to the directory to begin path resolution |
|
|
519
|
+
| `path` | `Path.Path` | The file path to read from |
|
|
520
520
|
|
|
521
521
|
Returns:
|
|
522
522
|
|
|
523
|
-
|type|description|
|
|
524
|
-
|
|
525
|
-
|
|
523
|
+
| type | description |
|
|
524
|
+
| -------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
525
|
+
| `Result<Bytes, FileError>` | `Ok(contents)` containing the bytes read if successful or `Err(err)` if a file system error is encountered |
|
|
526
526
|
|
|
527
527
|
#### Fs.Binary.**writeFile**
|
|
528
528
|
|
|
@@ -541,19 +541,19 @@ Write `Bytes` to a file.
|
|
|
541
541
|
|
|
542
542
|
Parameters:
|
|
543
543
|
|
|
544
|
-
|param|type|description|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
544
|
+
| param | type | description |
|
|
545
|
+
| -------------- | ------------------- | ------------------------------------------------------------- |
|
|
546
|
+
| `?writeMode` | `WriteMode` | The type of write operation to perform; `Truncate` by default |
|
|
547
|
+
| `?sync` | `Bool` | Whether to synchronously write; `true` by default |
|
|
548
|
+
| `?baseDirPath` | `Option<Path.Path>` | The path to the directory to begin path resolution |
|
|
549
|
+
| `path` | `Path.Path` | The file path to write to |
|
|
550
|
+
| `data` | `Bytes` | The bytes to write to the file |
|
|
551
551
|
|
|
552
552
|
Returns:
|
|
553
553
|
|
|
554
|
-
|type|description|
|
|
555
|
-
|
|
556
|
-
|
|
554
|
+
| type | description |
|
|
555
|
+
| ------------------------- | --------------------------------------------------------------------------------------------- |
|
|
556
|
+
| `Result<Void, FileError>` | `Ok(void)` if the operation is successful or `Err(err)` if a file system error is encountered |
|
|
557
557
|
|
|
558
558
|
## Fs.Utf8
|
|
559
559
|
|
|
@@ -585,17 +585,17 @@ Read the contents of a file as a `String`.
|
|
|
585
585
|
|
|
586
586
|
Parameters:
|
|
587
587
|
|
|
588
|
-
|param|type|description|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
588
|
+
| param | type | description |
|
|
589
|
+
| -------------- | ------------------- | -------------------------------------------------- |
|
|
590
|
+
| `?sync` | `Bool` | Whether to synchronously read; `true` by default |
|
|
591
|
+
| `?baseDirPath` | `Option<Path.Path>` | The path to the directory to begin path resolution |
|
|
592
|
+
| `path` | `Path.Path` | The file path to read from |
|
|
593
593
|
|
|
594
594
|
Returns:
|
|
595
595
|
|
|
596
|
-
|type|description|
|
|
597
|
-
|
|
598
|
-
|
|
596
|
+
| type | description |
|
|
597
|
+
| --------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
598
|
+
| `Result<String, FileError>` | `Ok(contents)` containing the string read if successful or `Err(err)` if a file system error is encountered |
|
|
599
599
|
|
|
600
600
|
#### Fs.Utf8.**writeFile**
|
|
601
601
|
|
|
@@ -614,17 +614,17 @@ Write a `String` to a file.
|
|
|
614
614
|
|
|
615
615
|
Parameters:
|
|
616
616
|
|
|
617
|
-
|param|type|description|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
617
|
+
| param | type | description |
|
|
618
|
+
| -------------- | ------------------- | ------------------------------------------------------------- |
|
|
619
|
+
| `?writeMode` | `WriteMode` | The type of write operation to perform; `Truncate` by default |
|
|
620
|
+
| `?sync` | `Bool` | Whether to synchronously write; `true` by default |
|
|
621
|
+
| `?baseDirPath` | `Option<Path.Path>` | The path to the directory to begin path resolution |
|
|
622
|
+
| `path` | `Path.Path` | The file path to write to |
|
|
623
|
+
| `data` | `String` | The string to write to the file |
|
|
624
624
|
|
|
625
625
|
Returns:
|
|
626
626
|
|
|
627
|
-
|type|description|
|
|
628
|
-
|
|
629
|
-
|
|
627
|
+
| type | description |
|
|
628
|
+
| ------------------------- | --------------------------------------------------------------------------------------------- |
|
|
629
|
+
| `Result<Void, FileError>` | `Ok(void)` if the operation is successful or `Err(err)` if a file system error is encountered |
|
|
630
630
|
|
package/hash.md
CHANGED
|
@@ -59,9 +59,9 @@ Produces a generic hash instance using a random seed value.
|
|
|
59
59
|
|
|
60
60
|
Returns:
|
|
61
61
|
|
|
62
|
-
|type|description|
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
| type | description |
|
|
63
|
+
| -------------- | ------------------------------------------------------ |
|
|
64
|
+
| `HashInstance` | A hashing instance that can be consumed during hashing |
|
|
65
65
|
|
|
66
66
|
Throws:
|
|
67
67
|
|
|
@@ -91,15 +91,15 @@ Produces a hashInstance using the given seed.
|
|
|
91
91
|
|
|
92
92
|
Parameters:
|
|
93
93
|
|
|
94
|
-
|param|type|description|
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
| param | type | description |
|
|
95
|
+
| ------ | -------- | ----------------------------- |
|
|
96
|
+
| `seed` | `Number` | The seed to use while hashing |
|
|
97
97
|
|
|
98
98
|
Returns:
|
|
99
99
|
|
|
100
|
-
|type|description|
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
| type | description |
|
|
101
|
+
| -------------- | ------------------------------------------------------ |
|
|
102
|
+
| `HashInstance` | A hashing instance that can be consumed during hashing |
|
|
103
103
|
|
|
104
104
|
Examples:
|
|
105
105
|
|
|
@@ -136,16 +136,16 @@ A generic hash function that produces an integer from any value given a hashing
|
|
|
136
136
|
|
|
137
137
|
Parameters:
|
|
138
138
|
|
|
139
|
-
|param|type|description|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
| param | type | description |
|
|
140
|
+
| -------------- | -------------- | ------------------------------------- |
|
|
141
|
+
| `hashInstance` | `HashInstance` | The hashing instance to use as a seed |
|
|
142
|
+
| `anything` | `a` | The value to hash |
|
|
143
143
|
|
|
144
144
|
Returns:
|
|
145
145
|
|
|
146
|
-
|type|description|
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
| type | description |
|
|
147
|
+
| -------- | -------------------------- |
|
|
148
|
+
| `Number` | A hash for the given value |
|
|
149
149
|
|
|
150
150
|
Examples:
|
|
151
151
|
|