@greenlabs/ppx-spice 0.2.1 → 0.2.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 +5 -1
- package/README.md +3 -3
- package/package.json +1 -1
- package/ppx-linux.exe +0 -0
- package/ppx-osx.exe +0 -0
- package/ppx-windows.exe +0 -0
- package/src/rescript/Spice.res +19 -7
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -183,11 +183,11 @@ Make sure running tests in `/test`
|
|
|
183
183
|
cd test
|
|
184
184
|
|
|
185
185
|
(install dependencies)
|
|
186
|
-
|
|
186
|
+
pnpm install
|
|
187
187
|
|
|
188
188
|
(build --watch)
|
|
189
|
-
|
|
189
|
+
pnpm res:clean && pnpm res:watch
|
|
190
190
|
|
|
191
191
|
(run test --watch)
|
|
192
|
-
|
|
192
|
+
pnpm test:watch
|
|
193
193
|
```
|
package/package.json
CHANGED
package/ppx-linux.exe
CHANGED
|
Binary file
|
package/ppx-osx.exe
CHANGED
|
Binary file
|
package/ppx-windows.exe
CHANGED
|
Binary file
|
package/src/rescript/Spice.res
CHANGED
|
@@ -98,15 +98,15 @@ let listFromJson = (decoder, json) =>
|
|
|
98
98
|
Belt.Result.map(arrayFromJson(decoder, json), Belt.List.fromArray)
|
|
99
99
|
|
|
100
100
|
let filterOptional = arr =>
|
|
101
|
-
Belt.Array.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
)
|
|
101
|
+
Belt.Array.keepMap(arr, ((k, v)) => switch v {
|
|
102
|
+
| Some(v) => Some(k, v)
|
|
103
|
+
| None => None
|
|
104
|
+
})
|
|
105
105
|
|
|
106
|
-
let optionToJson = (encoder, opt): Js.Json.t =>
|
|
106
|
+
let optionToJson = (encoder, opt): option<Js.Json.t> =>
|
|
107
107
|
switch opt {
|
|
108
|
-
| Some(x) => encoder(x)
|
|
109
|
-
| None =>
|
|
108
|
+
| Some(x) => Some(encoder(x))
|
|
109
|
+
| None => None
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
let optionFromJson = (decoder, json) =>
|
|
@@ -115,6 +115,18 @@ let optionFromJson = (decoder, json) =>
|
|
|
115
115
|
| _ => Belt.Result.map(decoder(json), v => Some(v))
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
let nullToJson = (encoder, opt): Js.Json.t =>
|
|
119
|
+
switch opt {
|
|
120
|
+
| Js.Null.Value(x) => encoder(x)
|
|
121
|
+
| Null => Js.Json.Null
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let nullFromJson = (decoder, json) =>
|
|
125
|
+
switch (json: Js.Json.t) {
|
|
126
|
+
| Js.Json.Null => Ok(Js.Null.Null)
|
|
127
|
+
| _ => Belt.Result.map(decoder(json), v => Js.Null.Value(v))
|
|
128
|
+
}
|
|
129
|
+
|
|
118
130
|
let resultToJson = (okEncoder, errorEncoder, result): Js.Json.t => Js.Json.Array(
|
|
119
131
|
switch result {
|
|
120
132
|
| Ok(v) => [Js.Json.String("Ok"), okEncoder(v)]
|