@colisweb/rescript-toolkit 4.18.0 → 4.18.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "4.18.0",
3
+ "version": "4.18.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -109,8 +109,19 @@ module MakeStringOrInt = () => {
109
109
  let deleteKey: (t<'a>, key) => t<'a>
110
110
  }
111
111
  } = {
112
+ let encoder: Decco.encoder<string> = id => id->Decco.stringToJson
113
+
114
+ let decoder: Decco.decoder<string> = json =>
115
+ switch (Decco.stringFromJson(json), Decco.intFromJson(json)) {
116
+ | (Ok(v), _) => Ok(v)
117
+ | (_, Ok(v)) => Ok(v->Int.toString)
118
+ | (Error(err), _) => Error(err)
119
+ }
120
+
121
+ let codec: Decco.codec<string> = (encoder, decoder)
122
+
112
123
  @decco
113
- type t = string
124
+ type t = @decco.codec(codec) string
114
125
  module Dict = {
115
126
  include Js.Dict
116
127
 
@@ -17,3 +17,5 @@ external difference: (array<'a>, array<'a>) => array<'a> = "default"
17
17
  external cloneDeep: 'a => 'a = "cloneDeep"
18
18
  @module("lodash")
19
19
  external chunk: (array<'a>, int) => array<array<'a>> = "chunk"
20
+ @module("lodash")
21
+ external isEmpty: 'a => bool = "isEmpty"