1module JavaScript.Experimental where
2{-| A pair of very experimental functions for converting between
3Elm records and JavaScript objects. It currently uses a best effort
4conversion that can cause runtime errors. This API should change and
5improve as we find its key failings.
8import JavaScript (JSObject)
9import Native.JavaScript
11{-| Turn arbitrary JavaScript objects into Elm records.
12Arrays are converted into lists, nested objects are allowed.
13No `null` values or non-homogeneous arrays.
16 { student:"Steve", scores:[83,94,99,72] }
17 { errorLevel:10, critical:true }
21 { info:[true,42,'what'] }
23toRecord : JSObject -> a
24toRecord = Native.JavaScript.toRecord
26{-| Turn arbitrary Elm records into JavaScript objects.
27Lists become arrays, nested records are allowed. No ADTs.
30 { student="Steve", scores=[83,94,99,72] }
31 { errorLevel=10, critical=True }
35 { result = Left "An error occurred" }
37fromRecord : a -> JSObject
38fromRecord = Native.JavaScript.fromRecord
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list