on ca672f6 help sign in
elk/libraries/JavaScript.elm
70 lines 1.7 kB history raw
2module JavaScript where
4{-|This library does basic conversions between Elm and JS values. This allows
5the internal data structures of Elm to change and improve with no impact on JS
6integration.
8# Javascript to Elm
9@docs toString, toInt, toFloat, toBool, toList
11# JavaScript from Elm
12@docs fromString, fromInt, fromFloat, fromBool, fromList
13-}
14{-
15# DOM Nodes and Elements
16@docs toElement, fromElement
17-}
19import Native.JavaScript
21data JSNumber = JSNumber
22data JSBool = JSBool
23data JSString = JSString
24data JSArray a = JSArray a
25data JSDomNode = JSDomNode
26data JSObject = JSObject
28{-| Requires that the input array be uniform (all members have the same type) -}
29toList : JSArray a -> [a]
30toList = Native.JavaScript.toList
32toInt : JSNumber -> Int
33toInt = Native.JavaScript.toInt
35toFloat : JSNumber -> Float
36toFloat = Native.JavaScript.toFloat
38toBool : JSBool -> Bool
39toBool = Native.JavaScript.toBool
41toString : JSString -> String
42toString = Native.JavaScript.toString
45{-| Produces a uniform JavaScript array with all members of the same type. -}
46fromList : [a] -> JSArray a
47fromList = Native.JavaScript.fromList
49fromInt : Int -> JSNumber
50fromInt = Native.JavaScript.fromInt
52fromFloat : Float -> JSNumber
53fromFloat = Native.JavaScript.fromFloat
55fromBool : Bool -> JSBool
56fromBool = Native.JavaScript.fromBool
58fromString : String -> JSString
59fromString = Native.JavaScript.fromString
61{-
62{-| Turn an `Element` into a DOM node. -}
63fromElement : Element -> JSDomNode
64fromElement = Native.JavaScript.fromElement
66{-| Turn a DOM node into an `Element`. You can resize the node
67using the normal `width` and `height` functions. -}
68toElement : Int -> Int -> JSDomNode -> Element
69toElement = Native.JavaScript.toElement
70-}