March 2019
Intermediate to advanced
208 pages
5h 11m
English
Sometimes you need to convert a JavaScript type to a ReasonML type. For example, one of the reviewers of this book suggested using the Performance[57] interface for measuring the time required to process the palindrome functions rather than using Js.Date.now as we did. He wrote this code:
| 1: | module Performance = { |
| - | type t; /* DOMHighResTimeStamp - a double, milliseconds since startup */ |
| - | |
| - | [@bs.scope "performance"] [@bs.module "perf_hooks"] |
| 5: | external now: unit => t = ""; |
| - | |
| - | external toFloat: t => float = "%identity"; |
| - | external fromFloat: float => t = "%identity"; |
| - | |
| 10: | let zero: t = fromFloat(0.0); |
| - | |
| - | let ... |
Read now
Unlock full access