@colisweb/rescript-toolkit 3.7.0 → 3.7.1

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "3.7.0",
3
+ "version": "3.7.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -290,6 +290,20 @@ module UnitMeasure = {
290
290
  })
291
291
  }
292
292
 
293
+ module Speed = {
294
+ module Config = Toolkit__Utils_UnitMeasure.Speed
295
+
296
+ module WithUnit = MakeWithUnit({
297
+ include Config
298
+ let errorPrefix = "Speed with unit"
299
+ })
300
+
301
+ module Km_h = Make({
302
+ include Config
303
+ let wrapValue = Config.wrapValue(#km_h)
304
+ })
305
+ }
306
+
293
307
  module Volume = {
294
308
  module Config = Toolkit__Utils_UnitMeasure.Volume
295
309
 
@@ -180,6 +180,42 @@ module Dimension = {
180
180
  }
181
181
  }
182
182
 
183
+ module Speed = {
184
+ include Unit({
185
+ @deriving(jsConverter)
186
+ type unitEnum = [
187
+ | @as(`km/h`) #km_h
188
+ ]
189
+ })
190
+
191
+ type t = [
192
+ | #km_h(float)
193
+ ]
194
+
195
+ let wrapValue = (unit: unitEnum, value: float): t =>
196
+ switch unit {
197
+ | #km_h => #km_h(value)
198
+ }
199
+
200
+ let toValue = value =>
201
+ switch value {
202
+ | #km_h(value) => v
203
+ }
204
+
205
+ let display = (value, ~digits=2, ()) => {
206
+ open Js.Float
207
+ switch value {
208
+ | #km_h(value) => v->toFixedWithPrecision(~digits) ++ " km/h"
209
+ }
210
+ }
211
+
212
+ let toString = value => {
213
+ switch value {
214
+ | #km_h(value) => v->Float.toString ++ " km/h"
215
+ }
216
+ }
217
+ }
218
+
183
219
  module Volume = {
184
220
  include Unit({
185
221
  @deriving(jsConverter)