jsaddle-dom-0.10.0.0: src/JSDOM/Generated/TextDecodeOptions.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from encoding (webref). Do not edit.
module JSDOM.Generated.TextDecodeOptions
(newTextDecodeOptions, setStream, getStream, getStreamUnsafe, getStreamUnchecked, TextDecodeOptions(..), gTypeTextDecodeOptions)
where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums
-- | <https://encoding.spec.whatwg.org/#textdecodeoptions TextDecodeOptions specification>
newTextDecodeOptions :: (MonadDOM m) => m TextDecodeOptions
newTextDecodeOptions = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))
-- | <https://encoding.spec.whatwg.org/#dom-textdecodeoptions-stream TextDecodeOptions.stream specification>
setStream :: (MonadDOM m) => TextDecodeOptions -> Bool -> m ()
setStream self val = liftDOM (void (self ^. jss "stream" (toJSVal val)))
-- | <https://encoding.spec.whatwg.org/#dom-textdecodeoptions-stream TextDecodeOptions.stream specification>
getStream :: (MonadDOM m) => TextDecodeOptions -> m (Maybe Bool)
getStream self = liftDOM (((self ^. js "stream") >>= fromJSValUnchecked))
-- | <https://encoding.spec.whatwg.org/#dom-textdecodeoptions-stream TextDecodeOptions.stream specification>
getStreamUnsafe :: (MonadDOM m, HasCallStack) => TextDecodeOptions -> m Bool
getStreamUnsafe self = liftDOM ((((self ^. js "stream") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://encoding.spec.whatwg.org/#dom-textdecodeoptions-stream TextDecodeOptions.stream specification>
getStreamUnchecked :: (MonadDOM m) => TextDecodeOptions -> m Bool
getStreamUnchecked self = liftDOM (((self ^. js "stream") >>= valToBool))