@grain/stdlib 0.5.2 → 0.5.4
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 +59 -0
- package/array.gr +61 -1
- package/array.md +113 -0
- package/bigint.md +30 -30
- package/buffer.gr +24 -22
- package/char.gr +2 -2
- package/float32.md +3 -3
- package/float64.md +3 -3
- package/immutablemap.gr +493 -0
- package/immutablemap.md +479 -0
- package/immutablepriorityqueue.gr +360 -0
- package/immutablepriorityqueue.md +291 -0
- package/immutableset.gr +498 -0
- package/immutableset.md +449 -0
- package/list.gr +75 -2
- package/list.md +110 -0
- package/map.gr +1 -2
- package/marshal.gr +1058 -0
- package/marshal.md +76 -0
- package/number.gr +689 -23
- package/number.md +362 -27
- package/package.json +1 -1
- package/pervasives.gr +16 -5
- package/pervasives.md +28 -0
- package/priorityqueue.gr +261 -0
- package/priorityqueue.md +309 -0
- package/queue.gr +14 -1
- package/queue.md +16 -1
- package/regex.gr +90 -67
- package/runtime/bigint.gr +4 -4
- package/runtime/compare.gr +179 -0
- package/runtime/compare.md +6 -0
- package/runtime/equal.gr +3 -3
- package/runtime/exception.gr +9 -5
- package/runtime/exception.md +8 -2
- package/runtime/gc.gr +2 -1
- package/runtime/malloc.gr +1 -3
- package/runtime/numberUtils.gr +11 -11
- package/runtime/numbers.gr +423 -100
- package/runtime/numbers.md +50 -0
- package/runtime/string.gr +4 -2
- package/set.gr +26 -27
- package/stack.gr +12 -0
- package/stack.md +15 -0
- package/string.gr +409 -53
- package/string.md +164 -1
- package/sys/file.gr +4 -4
- package/sys/file.md +3 -3
- package/sys/process.gr +3 -3
- package/sys/process.md +3 -3
- package/sys/random.gr +2 -2
- package/sys/random.md +2 -2
- package/sys/time.gr +2 -2
- package/sys/time.md +2 -2
package/marshal.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Marshal
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Utilities for serializing and deserializing Grain data.
|
|
6
|
+
|
|
7
|
+
<details disabled>
|
|
8
|
+
<summary tabindex="-1">Added in <code>0.5.3</code></summary>
|
|
9
|
+
No other changes yet.
|
|
10
|
+
</details>
|
|
11
|
+
|
|
12
|
+
```grain
|
|
13
|
+
import Marshal from "marshal"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Values
|
|
17
|
+
|
|
18
|
+
Functions for marshaling and unmarshaling data.
|
|
19
|
+
|
|
20
|
+
### Marshal.**marshal**
|
|
21
|
+
|
|
22
|
+
<details disabled>
|
|
23
|
+
<summary tabindex="-1">Added in <code>0.5.3</code></summary>
|
|
24
|
+
No other changes yet.
|
|
25
|
+
</details>
|
|
26
|
+
|
|
27
|
+
```grain
|
|
28
|
+
marshal : a -> Bytes
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Serialize a value into a byte-based representation suitable for transmission
|
|
32
|
+
across a network or disk storage. The byte-based representation can be
|
|
33
|
+
deserialized at a later time to restore the value.
|
|
34
|
+
|
|
35
|
+
Parameters:
|
|
36
|
+
|
|
37
|
+
|param|type|description|
|
|
38
|
+
|-----|----|-----------|
|
|
39
|
+
|`value`|`a`|The value to serialize|
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
|
|
43
|
+
|type|description|
|
|
44
|
+
|----|-----------|
|
|
45
|
+
|`Bytes`|A byte-based representation of the value|
|
|
46
|
+
|
|
47
|
+
### Marshal.**unmarshal**
|
|
48
|
+
|
|
49
|
+
<details disabled>
|
|
50
|
+
<summary tabindex="-1">Added in <code>0.5.3</code></summary>
|
|
51
|
+
No other changes yet.
|
|
52
|
+
</details>
|
|
53
|
+
|
|
54
|
+
```grain
|
|
55
|
+
unmarshal : Bytes -> Result<a, String>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Deserialize the byte-based representation of a value back into an in-memory
|
|
59
|
+
value. This operation is not type-safe, and it is recommended that a type
|
|
60
|
+
annotation is used to declare the type of the unmarshaled value. While
|
|
61
|
+
attempts to unmarshal bad data will fail, this operation is still generally
|
|
62
|
+
unsafe and great care should be taken to ensure that the data being
|
|
63
|
+
unmarshaled corresponds to the expected type.
|
|
64
|
+
|
|
65
|
+
Parameters:
|
|
66
|
+
|
|
67
|
+
|param|type|description|
|
|
68
|
+
|-----|----|-----------|
|
|
69
|
+
|`bytes`|`Bytes`|The data to deserialize|
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
|
|
73
|
+
|type|description|
|
|
74
|
+
|----|-----------|
|
|
75
|
+
|`Result<a, String>`|An in-memory value|
|
|
76
|
+
|