@grain/stdlib 0.5.13 → 0.6.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 +201 -0
- package/LICENSE +1 -1
- package/README.md +25 -2
- package/array.gr +1512 -199
- package/array.md +2032 -94
- package/bigint.gr +239 -140
- package/bigint.md +450 -106
- package/buffer.gr +595 -102
- package/buffer.md +903 -145
- package/bytes.gr +401 -110
- package/bytes.md +551 -63
- package/char.gr +228 -49
- package/char.md +373 -7
- package/exception.gr +26 -12
- package/exception.md +29 -5
- package/float32.gr +130 -109
- package/float32.md +185 -57
- package/float64.gr +112 -99
- package/float64.md +185 -57
- package/hash.gr +62 -40
- package/hash.md +27 -3
- package/int16.gr +430 -0
- package/int16.md +618 -0
- package/int32.gr +200 -269
- package/int32.md +254 -289
- package/int64.gr +142 -225
- package/int64.md +254 -289
- package/int8.gr +511 -0
- package/int8.md +786 -0
- package/json.gr +2071 -0
- package/json.md +646 -0
- package/list.gr +120 -68
- package/list.md +125 -80
- package/map.gr +560 -57
- package/map.md +672 -56
- package/marshal.gr +239 -227
- package/marshal.md +36 -4
- package/number.gr +626 -676
- package/number.md +738 -153
- package/option.gr +33 -35
- package/option.md +58 -42
- package/package.json +2 -2
- package/path.gr +148 -187
- package/path.md +47 -96
- package/pervasives.gr +75 -416
- package/pervasives.md +85 -180
- package/priorityqueue.gr +433 -74
- package/priorityqueue.md +422 -54
- package/queue.gr +362 -80
- package/queue.md +433 -38
- package/random.gr +67 -75
- package/random.md +68 -40
- package/range.gr +135 -63
- package/range.md +198 -43
- package/rational.gr +284 -0
- package/rational.md +545 -0
- package/regex.gr +933 -1066
- package/regex.md +59 -60
- package/result.gr +23 -25
- package/result.md +54 -39
- package/runtime/atof/common.gr +78 -82
- package/runtime/atof/common.md +22 -10
- package/runtime/atof/decimal.gr +102 -127
- package/runtime/atof/decimal.md +28 -7
- package/runtime/atof/lemire.gr +56 -71
- package/runtime/atof/lemire.md +9 -1
- package/runtime/atof/parse.gr +83 -110
- package/runtime/atof/parse.md +12 -2
- package/runtime/atof/slow.gr +28 -35
- package/runtime/atof/slow.md +9 -1
- package/runtime/atof/table.gr +19 -18
- package/runtime/atof/table.md +10 -2
- package/runtime/atoi/parse.gr +153 -136
- package/runtime/atoi/parse.md +50 -1
- package/runtime/bigint.gr +410 -517
- package/runtime/bigint.md +71 -57
- package/runtime/compare.gr +176 -85
- package/runtime/compare.md +31 -1
- package/runtime/dataStructures.gr +144 -32
- package/runtime/dataStructures.md +267 -31
- package/runtime/debugPrint.gr +34 -15
- package/runtime/debugPrint.md +37 -5
- package/runtime/equal.gr +53 -52
- package/runtime/equal.md +30 -1
- package/runtime/exception.gr +38 -47
- package/runtime/exception.md +10 -8
- package/runtime/gc.gr +23 -152
- package/runtime/gc.md +13 -17
- package/runtime/malloc.gr +31 -31
- package/runtime/malloc.md +11 -3
- package/runtime/numberUtils.gr +193 -174
- package/runtime/numberUtils.md +29 -9
- package/runtime/numbers.gr +1695 -1021
- package/runtime/numbers.md +1098 -134
- package/runtime/string.gr +543 -245
- package/runtime/string.md +76 -6
- package/runtime/unsafe/constants.gr +30 -13
- package/runtime/unsafe/constants.md +80 -0
- package/runtime/unsafe/conv.gr +55 -28
- package/runtime/unsafe/conv.md +41 -9
- package/runtime/unsafe/memory.gr +10 -30
- package/runtime/unsafe/memory.md +15 -19
- package/runtime/unsafe/tags.gr +37 -21
- package/runtime/unsafe/tags.md +88 -8
- package/runtime/unsafe/wasmf32.gr +30 -36
- package/runtime/unsafe/wasmf32.md +64 -56
- package/runtime/unsafe/wasmf64.gr +30 -36
- package/runtime/unsafe/wasmf64.md +64 -56
- package/runtime/unsafe/wasmi32.gr +49 -66
- package/runtime/unsafe/wasmi32.md +102 -94
- package/runtime/unsafe/wasmi64.gr +52 -79
- package/runtime/unsafe/wasmi64.md +108 -100
- package/runtime/utils/printing.gr +13 -15
- package/runtime/utils/printing.md +11 -3
- package/runtime/wasi.gr +294 -295
- package/runtime/wasi.md +62 -42
- package/set.gr +574 -64
- package/set.md +634 -54
- package/stack.gr +181 -64
- package/stack.md +271 -42
- package/string.gr +453 -533
- package/string.md +241 -151
- package/uint16.gr +369 -0
- package/uint16.md +585 -0
- package/uint32.gr +470 -0
- package/uint32.md +737 -0
- package/uint64.gr +471 -0
- package/uint64.md +737 -0
- package/uint8.gr +369 -0
- package/uint8.md +585 -0
- package/uri.gr +1093 -0
- package/uri.md +477 -0
- package/{sys → wasi}/file.gr +914 -500
- package/{sys → wasi}/file.md +454 -50
- package/wasi/process.gr +292 -0
- package/{sys → wasi}/process.md +164 -6
- package/wasi/random.gr +77 -0
- package/wasi/random.md +80 -0
- package/{sys → wasi}/time.gr +15 -22
- package/{sys → wasi}/time.md +5 -5
- package/immutablearray.gr +0 -929
- package/immutablearray.md +0 -1038
- package/immutablemap.gr +0 -493
- package/immutablemap.md +0 -479
- package/immutablepriorityqueue.gr +0 -360
- package/immutablepriorityqueue.md +0 -291
- package/immutableset.gr +0 -498
- package/immutableset.md +0 -449
- package/runtime/debug.gr +0 -2
- package/runtime/debug.md +0 -6
- package/runtime/unsafe/errors.gr +0 -36
- package/runtime/unsafe/errors.md +0 -204
- package/sys/process.gr +0 -254
- package/sys/random.gr +0 -79
- package/sys/random.md +0 -66
package/path.md
CHANGED
|
@@ -25,7 +25,7 @@ No other changes yet.
|
|
|
25
25
|
</details>
|
|
26
26
|
|
|
27
27
|
```grain
|
|
28
|
-
|
|
28
|
+
from "path" include Path
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
## Types
|
|
@@ -167,27 +167,37 @@ Represents possible errors for the `relativeTo` operation.
|
|
|
167
167
|
|
|
168
168
|
## Values
|
|
169
169
|
|
|
170
|
-
Functions
|
|
170
|
+
Functions and constants included in the Path module.
|
|
171
171
|
|
|
172
172
|
### Path.**fromString**
|
|
173
173
|
|
|
174
|
-
<details
|
|
175
|
-
<summary
|
|
176
|
-
|
|
174
|
+
<details>
|
|
175
|
+
<summary>Added in <code>0.5.5</code></summary>
|
|
176
|
+
<table>
|
|
177
|
+
<thead>
|
|
178
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
179
|
+
</thead>
|
|
180
|
+
<tbody>
|
|
181
|
+
<tr><td><code>0.6.0</code></td><td>Merged with `fromPlatformString`; modified signature to accept platform</td></tr>
|
|
182
|
+
</tbody>
|
|
183
|
+
</table>
|
|
177
184
|
</details>
|
|
178
185
|
|
|
179
186
|
```grain
|
|
180
|
-
fromString : String
|
|
187
|
+
fromString : (pathStr: String, ?platform: Platform) => Path
|
|
181
188
|
```
|
|
182
189
|
|
|
183
|
-
Parses a path string into a `Path
|
|
184
|
-
|
|
190
|
+
Parses a path string into a `Path` using the path separators appropriate to
|
|
191
|
+
the given platform (`/` for `Posix` and either `/` or `\` for `Windows`).
|
|
192
|
+
Paths will be parsed as file paths rather than directory paths if there is
|
|
193
|
+
ambiguity.
|
|
185
194
|
|
|
186
195
|
Parameters:
|
|
187
196
|
|
|
188
197
|
|param|type|description|
|
|
189
198
|
|-----|----|-----------|
|
|
190
199
|
|`pathStr`|`String`|The string to parse as a path|
|
|
200
|
+
|`?platform`|`Platform`|The platform whose path separators should be used for parsing|
|
|
191
201
|
|
|
192
202
|
Returns:
|
|
193
203
|
|
|
@@ -197,10 +207,6 @@ Returns:
|
|
|
197
207
|
|
|
198
208
|
Examples:
|
|
199
209
|
|
|
200
|
-
```grain
|
|
201
|
-
fromString("/bin/") // an absolute Path referencing the directory /bin/
|
|
202
|
-
```
|
|
203
|
-
|
|
204
210
|
```grain
|
|
205
211
|
fromString("file.txt") // a relative Path referencing the file ./file.txt
|
|
206
212
|
```
|
|
@@ -209,57 +215,34 @@ fromString("file.txt") // a relative Path referencing the file ./file.txt
|
|
|
209
215
|
fromString(".") // a relative Path referencing the current directory
|
|
210
216
|
```
|
|
211
217
|
|
|
212
|
-
### Path.**fromPlatformString**
|
|
213
|
-
|
|
214
|
-
<details disabled>
|
|
215
|
-
<summary tabindex="-1">Added in <code>0.5.5</code></summary>
|
|
216
|
-
No other changes yet.
|
|
217
|
-
</details>
|
|
218
|
-
|
|
219
218
|
```grain
|
|
220
|
-
|
|
219
|
+
fromString("/bin/", Posix) // an absolute Path referencing the directory /bin/
|
|
221
220
|
```
|
|
222
221
|
|
|
223
|
-
Parses a path string into a `Path` using the path separators appropriate to
|
|
224
|
-
the given platform (`/` for `Posix` and either `/` or `\` for `Windows`).
|
|
225
|
-
Paths will be parsed as file paths rather than directory paths if there is
|
|
226
|
-
ambiguity.
|
|
227
|
-
|
|
228
|
-
Parameters:
|
|
229
|
-
|
|
230
|
-
|param|type|description|
|
|
231
|
-
|-----|----|-----------|
|
|
232
|
-
|`pathStr`|`String`|The string to parse as a path|
|
|
233
|
-
|`platform`|`Platform`|The platform whose path separators should be used for parsing|
|
|
234
|
-
|
|
235
|
-
Returns:
|
|
236
|
-
|
|
237
|
-
|type|description|
|
|
238
|
-
|----|-----------|
|
|
239
|
-
|`Path`|The path wrapped with details encoded within the type|
|
|
240
|
-
|
|
241
|
-
Examples:
|
|
242
|
-
|
|
243
222
|
```grain
|
|
244
|
-
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
```grain
|
|
248
|
-
fromPlatformString("C:\\file.txt", Windows) // a relative Path referencing the file C:\file.txt
|
|
223
|
+
fromString("C:\\file.txt", Windows) // a relative Path referencing the file C:\file.txt
|
|
249
224
|
```
|
|
250
225
|
|
|
251
226
|
### Path.**toString**
|
|
252
227
|
|
|
253
|
-
<details
|
|
254
|
-
<summary
|
|
255
|
-
|
|
228
|
+
<details>
|
|
229
|
+
<summary>Added in <code>0.5.5</code></summary>
|
|
230
|
+
<table>
|
|
231
|
+
<thead>
|
|
232
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
233
|
+
</thead>
|
|
234
|
+
<tbody>
|
|
235
|
+
<tr><td><code>0.6.0</code></td><td>Merged with `toPlatformString`; modified signature to accept platform</td></tr>
|
|
236
|
+
</tbody>
|
|
237
|
+
</table>
|
|
256
238
|
</details>
|
|
257
239
|
|
|
258
240
|
```grain
|
|
259
|
-
toString : Path
|
|
241
|
+
toString : (path: Path, ?platform: Platform) => String
|
|
260
242
|
```
|
|
261
243
|
|
|
262
|
-
Converts the given `Path` into a string, using the
|
|
244
|
+
Converts the given `Path` into a string, using the canonical path separator
|
|
245
|
+
appropriate to the given platform (`/` for `Posix` and `\` for `Windows`).
|
|
263
246
|
A trailing slash is added to directory paths.
|
|
264
247
|
|
|
265
248
|
Parameters:
|
|
@@ -267,6 +250,7 @@ Parameters:
|
|
|
267
250
|
|param|type|description|
|
|
268
251
|
|-----|----|-----------|
|
|
269
252
|
|`path`|`Path`|The path to convert to a string|
|
|
253
|
+
|`?platform`|`Platform`|The `Platform` to use to represent the path as a string|
|
|
270
254
|
|
|
271
255
|
Returns:
|
|
272
256
|
|
|
@@ -281,45 +265,11 @@ toString(fromString("/file.txt")) == "/file.txt"
|
|
|
281
265
|
```
|
|
282
266
|
|
|
283
267
|
```grain
|
|
284
|
-
toString(fromString("dir/")) == "./dir/"
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
### Path.**toPlatformString**
|
|
288
|
-
|
|
289
|
-
<details disabled>
|
|
290
|
-
<summary tabindex="-1">Added in <code>0.5.5</code></summary>
|
|
291
|
-
No other changes yet.
|
|
292
|
-
</details>
|
|
293
|
-
|
|
294
|
-
```grain
|
|
295
|
-
toPlatformString : (Path, Platform) -> String
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
Converts the given `Path` into a string, using the canonical path separator
|
|
299
|
-
appropriate to the given platform (`/` for `Posix` and `\` for `Windows`).
|
|
300
|
-
A trailing slash is added to directory paths.
|
|
301
|
-
|
|
302
|
-
Parameters:
|
|
303
|
-
|
|
304
|
-
|param|type|description|
|
|
305
|
-
|-----|----|-----------|
|
|
306
|
-
|`path`|`Path`|The path to convert to a string|
|
|
307
|
-
|`platform`|`Platform`|The `Platform` to use to represent the path as a string|
|
|
308
|
-
|
|
309
|
-
Returns:
|
|
310
|
-
|
|
311
|
-
|type|description|
|
|
312
|
-
|----|-----------|
|
|
313
|
-
|`String`|A string representing the given path|
|
|
314
|
-
|
|
315
|
-
Examples:
|
|
316
|
-
|
|
317
|
-
```grain
|
|
318
|
-
toPlatformString(fromString("dir/"), Posix) == "./dir/"
|
|
268
|
+
toString(fromString("dir/"), Posix) == "./dir/"
|
|
319
269
|
```
|
|
320
270
|
|
|
321
271
|
```grain
|
|
322
|
-
|
|
272
|
+
toString(fromString("C:/file.txt"), Windows) == "C:\\file.txt"
|
|
323
273
|
```
|
|
324
274
|
|
|
325
275
|
### Path.**isDirectory**
|
|
@@ -330,7 +280,7 @@ No other changes yet.
|
|
|
330
280
|
</details>
|
|
331
281
|
|
|
332
282
|
```grain
|
|
333
|
-
isDirectory : Path
|
|
283
|
+
isDirectory : (path: Path) => Bool
|
|
334
284
|
```
|
|
335
285
|
|
|
336
286
|
Determines whether the path is a directory path.
|
|
@@ -360,7 +310,7 @@ isDirectory(fromString("/bin/")) == true
|
|
|
360
310
|
### Path.**isAbsolute**
|
|
361
311
|
|
|
362
312
|
```grain
|
|
363
|
-
isAbsolute : Path
|
|
313
|
+
isAbsolute : (path: Path) => Bool
|
|
364
314
|
```
|
|
365
315
|
|
|
366
316
|
Determines whether the path is an absolute path.
|
|
@@ -395,7 +345,7 @@ No other changes yet.
|
|
|
395
345
|
</details>
|
|
396
346
|
|
|
397
347
|
```grain
|
|
398
|
-
append : (Path, Path)
|
|
348
|
+
append : (path: Path, toAppend: Path) => Result<Path, AppendError>
|
|
399
349
|
```
|
|
400
350
|
|
|
401
351
|
Creates a new path by appending a relative path segment to a directory path.
|
|
@@ -435,7 +385,7 @@ No other changes yet.
|
|
|
435
385
|
</details>
|
|
436
386
|
|
|
437
387
|
```grain
|
|
438
|
-
relativeTo : (Path, Path)
|
|
388
|
+
relativeTo : (source: Path, dest: Path) => Result<Path, RelativizationError>
|
|
439
389
|
```
|
|
440
390
|
|
|
441
391
|
Attempts to construct a new relative path which will lead to the destination
|
|
@@ -494,7 +444,8 @@ No other changes yet.
|
|
|
494
444
|
</details>
|
|
495
445
|
|
|
496
446
|
```grain
|
|
497
|
-
ancestry :
|
|
447
|
+
ancestry :
|
|
448
|
+
(base: Path, path: Path) => Result<AncestryStatus, IncompatibilityError>
|
|
498
449
|
```
|
|
499
450
|
|
|
500
451
|
Determines the relative ancestry betwen two paths.
|
|
@@ -538,7 +489,7 @@ No other changes yet.
|
|
|
538
489
|
</details>
|
|
539
490
|
|
|
540
491
|
```grain
|
|
541
|
-
parent : Path
|
|
492
|
+
parent : (path: Path) => Path
|
|
542
493
|
```
|
|
543
494
|
|
|
544
495
|
Retrieves the path corresponding to the parent directory of the given path.
|
|
@@ -573,7 +524,7 @@ No other changes yet.
|
|
|
573
524
|
</details>
|
|
574
525
|
|
|
575
526
|
```grain
|
|
576
|
-
basename : Path
|
|
527
|
+
basename : (path: Path) => Option<String>
|
|
577
528
|
```
|
|
578
529
|
|
|
579
530
|
Retrieves the basename (named final segment) of a path.
|
|
@@ -608,7 +559,7 @@ No other changes yet.
|
|
|
608
559
|
</details>
|
|
609
560
|
|
|
610
561
|
```grain
|
|
611
|
-
stem : Path
|
|
562
|
+
stem : (path: Path) => Result<String, PathOperationError>
|
|
612
563
|
```
|
|
613
564
|
|
|
614
565
|
Retrieves the basename of a file path without the extension.
|
|
@@ -651,7 +602,7 @@ No other changes yet.
|
|
|
651
602
|
</details>
|
|
652
603
|
|
|
653
604
|
```grain
|
|
654
|
-
extension : Path
|
|
605
|
+
extension : (path: Path) => Result<String, PathOperationError>
|
|
655
606
|
```
|
|
656
607
|
|
|
657
608
|
Retrieves the extension on the basename of a file path.
|
|
@@ -694,7 +645,7 @@ No other changes yet.
|
|
|
694
645
|
</details>
|
|
695
646
|
|
|
696
647
|
```grain
|
|
697
|
-
root : Path
|
|
648
|
+
root : (path: Path) => Result<AbsoluteRoot, PathOperationError>
|
|
698
649
|
```
|
|
699
650
|
|
|
700
651
|
Retrieves the root of the absolute path.
|