on c2eecc2 help sign in
elk/libraries/JavaScript.elm
71 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
20import open Basics
22data JSNumber = JSNumber
23data JSBool = JSBool
24data JSString = JSString
25data JSArray a = JSArray a
26data JSDomNode = JSDomNode
27data JSObject = JSObject
29{-| Requires that the input array be uniform (all members have the same type) -}
30toList : JSArray a -> [a]
31toList = Native.JavaScript.toList
33toInt : JSNumber -> Int
34toInt = Native.JavaScript.toInt
36toFloat : JSNumber -> Float
37toFloat = Native.JavaScript.toFloat
39toBool : JSBool -> Bool
40toBool = Native.JavaScript.toBool
42toString : JSString -> String
43toString = Native.JavaScript.toString
46{-| Produces a uniform JavaScript array with all members of the same type. -}
47fromList : [a] -> JSArray a
48fromList = Native.JavaScript.fromList
50fromInt : Int -> JSNumber
51fromInt = Native.JavaScript.fromInt
53fromFloat : Float -> JSNumber
54fromFloat = Native.JavaScript.fromFloat
56fromBool : Bool -> JSBool
57fromBool = Native.JavaScript.fromBool
59fromString : String -> JSString
60fromString = Native.JavaScript.fromString
62{-
63{-| Turn an `Element` into a DOM node. -}
64fromElement : Element -> JSDomNode
65fromElement = Native.JavaScript.fromElement
67{-| Turn a DOM node into an `Element`. You can resize the node
68using the normal `width` and `height` functions. -}
69toElement : Int -> Int -> JSDomNode -> Element
70toElement = Native.JavaScript.toElement
71-}