@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/runtime/string.md
CHANGED
|
@@ -21,16 +21,16 @@ Concatenate two strings.
|
|
|
21
21
|
|
|
22
22
|
Parameters:
|
|
23
23
|
|
|
24
|
-
|param|type|description|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
| param | type | description |
|
|
25
|
+
| ------ | -------- | -------------------- |
|
|
26
|
+
| `str1` | `String` | The beginning string |
|
|
27
|
+
| `str2` | `String` | The ending string |
|
|
28
28
|
|
|
29
29
|
Returns:
|
|
30
30
|
|
|
31
|
-
|type|description|
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
| type | description |
|
|
32
|
+
| -------- | ------------------- |
|
|
33
|
+
| `String` | The combined string |
|
|
34
34
|
|
|
35
35
|
Examples:
|
|
36
36
|
|
|
@@ -54,15 +54,15 @@ Provides a better representation of data types if those types are provided from
|
|
|
54
54
|
|
|
55
55
|
Parameters:
|
|
56
56
|
|
|
57
|
-
|param|type|description|
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
| param | type | description |
|
|
58
|
+
| ------- | ---- | ----------- |
|
|
59
|
+
| `value` | `a` | The operand |
|
|
60
60
|
|
|
61
61
|
Returns:
|
|
62
62
|
|
|
63
|
-
|type|description|
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
| type | description |
|
|
64
|
+
| -------- | ------------------------ |
|
|
65
|
+
| `String` | The operand, as a string |
|
|
66
66
|
|
|
67
67
|
### String.**print**
|
|
68
68
|
|
|
@@ -88,8 +88,8 @@ are provided from the module.
|
|
|
88
88
|
|
|
89
89
|
Parameters:
|
|
90
90
|
|
|
91
|
-
|param|type|description|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
| param | type | description |
|
|
92
|
+
| --------- | -------- | -------------------------------------- |
|
|
93
|
+
| `value` | `a` | The operand |
|
|
94
|
+
| `?suffix` | `String` | The string to print after the argument |
|
|
95
95
|
|
package/runtime/unsafe/conv.md
CHANGED
|
@@ -88,13 +88,13 @@ Converts a WasmI32 value to Number.
|
|
|
88
88
|
|
|
89
89
|
Parameters:
|
|
90
90
|
|
|
91
|
-
|param|type|description|
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
| param | type | description |
|
|
92
|
+
| ----- | --------- | ---------------------- |
|
|
93
|
+
| `n` | `WasmI32` | The WasmI32 to convert |
|
|
94
94
|
|
|
95
95
|
Returns:
|
|
96
96
|
|
|
97
|
-
|type|description|
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
| type | description |
|
|
98
|
+
| -------- | ------------------------------------------------------------------------- |
|
|
99
|
+
| `Number` | The value converted to either a simple or a 32 bit heap allocated number. |
|
|
100
100
|
|
package/runtime/unsafe/memory.gr
CHANGED
|
@@ -15,20 +15,7 @@ provide { malloc, free, incRef, decRef }
|
|
|
15
15
|
* @param src: The source memory region
|
|
16
16
|
* @param length: The length of the memory region to copy
|
|
17
17
|
*/
|
|
18
|
-
provide
|
|
19
|
-
if (dest != src) {
|
|
20
|
-
if (dest < src) {
|
|
21
|
-
for (let mut i = 0n; i < length; i += 1n) {
|
|
22
|
-
WasmI32.store8(dest, WasmI32.load8U(src, i), i)
|
|
23
|
-
}
|
|
24
|
-
} else {
|
|
25
|
-
// Copy backwards to ensure we do not overwrite on overlapping regions
|
|
26
|
-
for (let mut n = length; n > 0n; n -= 1n) {
|
|
27
|
-
WasmI32.store8(dest + n - 1n, WasmI32.load8U(src + n - 1n, 0n), 0n)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
18
|
+
provide primitive copy = "@wasm.memory_copy"
|
|
32
19
|
|
|
33
20
|
/**
|
|
34
21
|
* Fills the given memory region with the given 1-byte value. Values larger than 1 byte will be truncated.
|
|
@@ -37,10 +24,6 @@ provide let copy = (dest, src, length) => {
|
|
|
37
24
|
* @param value: The value to fill the memory region with
|
|
38
25
|
* @param length: The length of the memory region to fill
|
|
39
26
|
*/
|
|
40
|
-
provide
|
|
41
|
-
for (let mut i = 0n; i < length; i += 1n) {
|
|
42
|
-
WasmI32.store8(dest, value, i)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
27
|
+
provide primitive fill = "@wasm.memory_fill"
|
|
45
28
|
|
|
46
29
|
provide primitive compare = "@wasm.memory_compare"
|
package/runtime/unsafe/memory.md
CHANGED
|
@@ -40,11 +40,11 @@ Copies the source memory region to the destination memory region. Regions may ov
|
|
|
40
40
|
|
|
41
41
|
Parameters:
|
|
42
42
|
|
|
43
|
-
|param|type|description|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
| param | type | description |
|
|
44
|
+
| -------- | --------- | --------------------------------------- |
|
|
45
|
+
| `dest` | `WasmI32` | The destination memory region |
|
|
46
|
+
| `src` | `WasmI32` | The source memory region |
|
|
47
|
+
| `length` | `WasmI32` | The length of the memory region to copy |
|
|
48
48
|
|
|
49
49
|
### Memory.**fill**
|
|
50
50
|
|
|
@@ -56,11 +56,11 @@ Fills the given memory region with the given 1-byte value. Values larger than 1
|
|
|
56
56
|
|
|
57
57
|
Parameters:
|
|
58
58
|
|
|
59
|
-
|param|type|description|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
| param | type | description |
|
|
60
|
+
| -------- | --------- | ---------------------------------------- |
|
|
61
|
+
| `dest` | `WasmI32` | The destination memory region |
|
|
62
|
+
| `value` | `WasmI32` | The value to fill the memory region with |
|
|
63
|
+
| `length` | `WasmI32` | The length of the memory region to fill |
|
|
64
64
|
|
|
65
65
|
### Memory.**compare**
|
|
66
66
|
|
package/runtime/utf8.md
CHANGED
|
@@ -18,15 +18,15 @@ Determines if the given byte is a leading byte in a UTF-8 sequence.
|
|
|
18
18
|
|
|
19
19
|
Parameters:
|
|
20
20
|
|
|
21
|
-
|param|type|description|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
| param | type | description |
|
|
22
|
+
| ------ | --------- | ----------------- |
|
|
23
|
+
| `byte` | `WasmI32` | The byte to check |
|
|
24
24
|
|
|
25
25
|
Returns:
|
|
26
26
|
|
|
27
|
-
|type|description|
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
| type | description |
|
|
28
|
+
| ------ | ------------------------------------------------------- |
|
|
29
|
+
| `Bool` | `true` if the byte is a leading byte, `false` otherwise |
|
|
30
30
|
|
|
31
31
|
### Utf8.**utf8ByteCount**
|
|
32
32
|
|
|
@@ -38,15 +38,15 @@ Returns the total number of bytes for a UTF-8 code point given the first byte.
|
|
|
38
38
|
|
|
39
39
|
Parameters:
|
|
40
40
|
|
|
41
|
-
|param|type|description|
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
| param | type | description |
|
|
42
|
+
| ------ | --------- | -------------------------------------- |
|
|
43
|
+
| `byte` | `WasmI32` | The first byte of the UTF-8 code point |
|
|
44
44
|
|
|
45
45
|
Returns:
|
|
46
46
|
|
|
47
|
-
|type|description|
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
| type | description |
|
|
48
|
+
| --------- | ------------------------------------------- |
|
|
49
|
+
| `WasmI32` | The number of bytes in the UTF-8 code point |
|
|
50
50
|
|
|
51
51
|
### Utf8.**usvEncodeLength**
|
|
52
52
|
|
|
@@ -58,15 +58,15 @@ Returns the number of bytes required to encode the given USV as UTF-8.
|
|
|
58
58
|
|
|
59
59
|
Parameters:
|
|
60
60
|
|
|
61
|
-
|param|type|description|
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
| param | type | description |
|
|
62
|
+
| ----- | --------- | ------------------------ |
|
|
63
|
+
| `usv` | `WasmI32` | The Unicode scalar value |
|
|
64
64
|
|
|
65
65
|
Returns:
|
|
66
66
|
|
|
67
|
-
|type|description|
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
| type | description |
|
|
68
|
+
| --------- | ------------------------------------------------------------- |
|
|
69
|
+
| `WasmI32` | The number of bytes required to encode the given USV as UTF-8 |
|
|
70
70
|
|
|
71
71
|
### Utf8.**getCodePoint**
|
|
72
72
|
|
|
@@ -78,15 +78,15 @@ Returns the Unicode code point of the encoded value at the given pointer.
|
|
|
78
78
|
|
|
79
79
|
Parameters:
|
|
80
80
|
|
|
81
|
-
|param|type|description|
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
| param | type | description |
|
|
82
|
+
| ----- | --------- | ------------------------------------------ |
|
|
83
|
+
| `ptr` | `WasmI32` | The pointer to the encoded value in memory |
|
|
84
84
|
|
|
85
85
|
Returns:
|
|
86
86
|
|
|
87
|
-
|type|description|
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
| type | description |
|
|
88
|
+
| --------- | ---------------------------------------------------------------- |
|
|
89
|
+
| `WasmI32` | The Unicode code point of the encoded value at the given pointer |
|
|
90
90
|
|
|
91
91
|
Throws:
|
|
92
92
|
|
|
@@ -104,14 +104,14 @@ Writes the given Unicode code point to the given pointer as encoded UTF-8.
|
|
|
104
104
|
|
|
105
105
|
Parameters:
|
|
106
106
|
|
|
107
|
-
|param|type|description|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
| param | type | description |
|
|
108
|
+
| ----------- | --------- | ------------------------------------------- |
|
|
109
|
+
| `ptr` | `WasmI32` | The pointer to write the UTF-8 character to |
|
|
110
|
+
| `codePoint` | `WasmI32` | The Unicode code point to write |
|
|
111
111
|
|
|
112
112
|
Returns:
|
|
113
113
|
|
|
114
|
-
|type|description|
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
| type | description |
|
|
115
|
+
| --------- | --------------------------- |
|
|
116
|
+
| `WasmI32` | The number of bytes written |
|
|
117
117
|
|
package/runtime/wasi.md
CHANGED
|
@@ -102,18 +102,18 @@ Invokes the `fd_write` system call.
|
|
|
102
102
|
|
|
103
103
|
Parameters:
|
|
104
104
|
|
|
105
|
-
|param|type|description|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
| param | type | description |
|
|
106
|
+
| ----- | --------- | ------------------------------------------ |
|
|
107
|
+
| `0` | `WasmI32` | The file descriptor to write to |
|
|
108
|
+
| `1` | `WasmI32` | The pointer to the array of iovs to write |
|
|
109
|
+
| `2` | `WasmI32` | The length of the array of iovs |
|
|
110
|
+
| `3` | `WasmI32` | Where to store the number of bytes written |
|
|
111
111
|
|
|
112
112
|
Returns:
|
|
113
113
|
|
|
114
|
-
|type|description|
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
| type | description |
|
|
115
|
+
| --------- | --------------------------- |
|
|
116
|
+
| `WasmI32` | The number of bytes written |
|
|
117
117
|
|
|
118
118
|
### Wasi.**fd_pwrite**
|
|
119
119
|
|