@grain/stdlib 0.5.13 → 0.6.0
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 +193 -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 +47 -37
- package/hash.md +21 -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 +2084 -0
- package/json.md +608 -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 +191 -172
- package/runtime/numberUtils.md +17 -9
- package/runtime/numbers.gr +1695 -1021
- package/runtime/numbers.md +1098 -134
- package/runtime/string.gr +540 -242
- 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/{sys → wasi}/time.gr
RENAMED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Access to system clocks.
|
|
3
3
|
*
|
|
4
|
-
* @example
|
|
4
|
+
* @example from "wasi/time" include Time
|
|
5
5
|
*/
|
|
6
|
+
module Time
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import Wasi from "runtime/wasi"
|
|
14
|
-
import Errors from "runtime/unsafe/errors"
|
|
15
|
-
import { allocateInt64, tagSimpleNumber } from "runtime/dataStructures"
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @section Values: Functions and constants included in the Time module.
|
|
19
|
-
*/
|
|
8
|
+
from "runtime/unsafe/wasmi32" include WasmI32
|
|
9
|
+
use WasmI32.{ (+), (==), (!=) }
|
|
10
|
+
from "runtime/unsafe/memory" include Memory
|
|
11
|
+
from "runtime/wasi" include Wasi
|
|
12
|
+
from "runtime/dataStructures" include DataStructures
|
|
13
|
+
use DataStructures.{ allocateInt64, tagSimpleNumber }
|
|
20
14
|
|
|
21
15
|
@unsafe
|
|
22
16
|
let getClockTime = (clockid, precision) => {
|
|
@@ -25,10 +19,9 @@ let getClockTime = (clockid, precision) => {
|
|
|
25
19
|
let err = Wasi.clock_time_get(clockid, precision, timePtr)
|
|
26
20
|
if (err != Wasi._ESUCCESS) {
|
|
27
21
|
Memory.free(int64Ptr)
|
|
28
|
-
Err(Wasi.SystemError(tagSimpleNumber(err)))
|
|
29
|
-
} else {
|
|
30
|
-
Ok(WasmI32.toGrain(int64Ptr): Int64)
|
|
22
|
+
return Err(Wasi.SystemError(tagSimpleNumber(err)))
|
|
31
23
|
}
|
|
24
|
+
return Ok(WasmI32.toGrain(int64Ptr): Int64)
|
|
32
25
|
}
|
|
33
26
|
|
|
34
27
|
/**
|
|
@@ -38,7 +31,7 @@ let getClockTime = (clockid, precision) => {
|
|
|
38
31
|
* @returns `Ok(time)` of the current time if successful or `Err(exception)` otherwise
|
|
39
32
|
*/
|
|
40
33
|
@unsafe
|
|
41
|
-
|
|
34
|
+
provide let realTime = () => {
|
|
42
35
|
getClockTime(Wasi._CLOCK_REALTIME, 1000N)
|
|
43
36
|
}
|
|
44
37
|
|
|
@@ -51,7 +44,7 @@ export let realTime = () => {
|
|
|
51
44
|
* @returns `Ok(time)` of the current time if successful or `Err(exception)` otherwise
|
|
52
45
|
*/
|
|
53
46
|
@unsafe
|
|
54
|
-
|
|
47
|
+
provide let monotonicTime = () => {
|
|
55
48
|
getClockTime(Wasi._CLOCK_MONOTONIC, 1N)
|
|
56
49
|
}
|
|
57
50
|
|
|
@@ -61,7 +54,7 @@ export let monotonicTime = () => {
|
|
|
61
54
|
* @returns `Ok(elapsed)` of the elapsed nanoseconds if successful or `Err(exception)` otherwise
|
|
62
55
|
*/
|
|
63
56
|
@unsafe
|
|
64
|
-
|
|
57
|
+
provide let processCpuTime = () => {
|
|
65
58
|
getClockTime(Wasi._CLOCK_PROCESS_CPUTIME, 1N)
|
|
66
59
|
}
|
|
67
60
|
|
|
@@ -71,6 +64,6 @@ export let processCpuTime = () => {
|
|
|
71
64
|
* @returns `Ok(elapsed)` of the elapsed nanoseconds if successful or `Err(exception)` otherwise
|
|
72
65
|
*/
|
|
73
66
|
@unsafe
|
|
74
|
-
|
|
67
|
+
provide let threadCpuTime = () => {
|
|
75
68
|
getClockTime(Wasi._CLOCK_THREAD_CPUTIME, 1N)
|
|
76
69
|
}
|
package/{sys → wasi}/time.md
RENAMED
|
@@ -5,7 +5,7 @@ title: Time
|
|
|
5
5
|
Access to system clocks.
|
|
6
6
|
|
|
7
7
|
```grain
|
|
8
|
-
|
|
8
|
+
from "wasi/time" include Time
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Values
|
|
@@ -15,7 +15,7 @@ Functions and constants included in the Time module.
|
|
|
15
15
|
### Time.**realTime**
|
|
16
16
|
|
|
17
17
|
```grain
|
|
18
|
-
realTime : ()
|
|
18
|
+
realTime : () => Result<Int64, Exception>
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Get the current time, in nanoseconds.
|
|
@@ -30,7 +30,7 @@ Returns:
|
|
|
30
30
|
### Time.**monotonicTime**
|
|
31
31
|
|
|
32
32
|
```grain
|
|
33
|
-
monotonicTime : ()
|
|
33
|
+
monotonicTime : () => Result<Int64, Exception>
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
Get the time of the system's high-resolution clock, in nanoseconds.
|
|
@@ -47,7 +47,7 @@ Returns:
|
|
|
47
47
|
### Time.**processCpuTime**
|
|
48
48
|
|
|
49
49
|
```grain
|
|
50
|
-
processCpuTime : ()
|
|
50
|
+
processCpuTime : () => Result<Int64, Exception>
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
Get the number of nanoseconds elapsed since the process began.
|
|
@@ -61,7 +61,7 @@ Returns:
|
|
|
61
61
|
### Time.**threadCpuTime**
|
|
62
62
|
|
|
63
63
|
```grain
|
|
64
|
-
threadCpuTime : ()
|
|
64
|
+
threadCpuTime : () => Result<Int64, Exception>
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
Get the number of nanoseconds elapsed since the thread began.
|