@@ -97,13 +97,12 @@ module Data.Options
9797
9898import Prelude
9999
100- import Data.Foreign (toForeign , Foreign )
101100import Data.Maybe (Maybe , maybe )
102- import Data.Monoid (mempty , class Monoid )
103101import Data.Newtype (class Newtype , unwrap )
104102import Data.Op (Op (..))
105- import Data.StrMap as StrMap
106103import Data.Tuple (Tuple (..))
104+ import Foreign (Foreign , unsafeToForeign )
105+ import Foreign.Object as Object
107106
108107-- | The `Options` type represents a set of options. The type argument is a
109108-- | phantom type, which is useful for ensuring that options for one particular
@@ -117,7 +116,7 @@ derive newtype instance monoidOptions ∷ Monoid (Options opt)
117116-- | Convert an `Options` value into a JavaScript object, suitable for passing
118117-- | to JavaScript APIs.
119118options :: forall opt . Options opt -> Foreign
120- options (Options os) = toForeign ( StrMap .fromFoldable os)
119+ options (Options os) = unsafeToForeign ( Object .fromFoldable os)
121120
122121-- | An `Option` represents an opportunity to configure a specific attribute
123122-- | of a call to some API. This normally corresponds to one specific property
@@ -148,8 +147,8 @@ tag :: forall opt value. Option opt value -> value -> Option opt Unit
148147tag o value = Op \_ -> o := value
149148
150149-- | The default method for turning a string property key into an
151- -- | `Option`. This function simply calls `toForeign ` on the value. If
150+ -- | `Option`. This function simply calls `unsafeToForeign ` on the value. If
152151-- | you need some other behaviour, you can write your own function to replace
153152-- | this one, and construct an `Option` yourself.
154153defaultToOptions :: forall opt value . String -> value -> Options opt
155- defaultToOptions k v = Options [Tuple k (toForeign v)]
154+ defaultToOptions k v = Options [Tuple k (unsafeToForeign v)]
0 commit comments