jsaddle-dom-0.10.0.0: src/JSDOM/Generated/TextDecoderOptions.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.TextDecoderOptions
(newTextDecoderOptions, setFatal, getFatal, getFatalUnsafe, getFatalUnchecked, setIgnoreBOM, getIgnoreBOM, getIgnoreBOMUnsafe, getIgnoreBOMUnchecked, TextDecoderOptions(..), gTypeTextDecoderOptions)
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/#textdecoderoptions TextDecoderOptions specification>
newTextDecoderOptions :: (MonadDOM m) => m TextDecoderOptions
newTextDecoderOptions = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))
-- | <https://encoding.spec.whatwg.org/#dom-textdecoderoptions-fatal TextDecoderOptions.fatal specification>
setFatal :: (MonadDOM m) => TextDecoderOptions -> Bool -> m ()
setFatal self val = liftDOM (void (self ^. jss "fatal" (toJSVal val)))
-- | <https://encoding.spec.whatwg.org/#dom-textdecoderoptions-fatal TextDecoderOptions.fatal specification>
getFatal :: (MonadDOM m) => TextDecoderOptions -> m (Maybe Bool)
getFatal self = liftDOM (((self ^. js "fatal") >>= fromJSValUnchecked))
-- | <https://encoding.spec.whatwg.org/#dom-textdecoderoptions-fatal TextDecoderOptions.fatal specification>
getFatalUnsafe :: (MonadDOM m, HasCallStack) => TextDecoderOptions -> m Bool
getFatalUnsafe self = liftDOM ((((self ^. js "fatal") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://encoding.spec.whatwg.org/#dom-textdecoderoptions-fatal TextDecoderOptions.fatal specification>
getFatalUnchecked :: (MonadDOM m) => TextDecoderOptions -> m Bool
getFatalUnchecked self = liftDOM (((self ^. js "fatal") >>= valToBool))
-- | <https://encoding.spec.whatwg.org/#dom-textdecoderoptions-ignorebom TextDecoderOptions.ignoreBOM specification>
setIgnoreBOM :: (MonadDOM m) => TextDecoderOptions -> Bool -> m ()
setIgnoreBOM self val = liftDOM (void (self ^. jss "ignoreBOM" (toJSVal val)))
-- | <https://encoding.spec.whatwg.org/#dom-textdecoderoptions-ignorebom TextDecoderOptions.ignoreBOM specification>
getIgnoreBOM :: (MonadDOM m) => TextDecoderOptions -> m (Maybe Bool)
getIgnoreBOM self = liftDOM (((self ^. js "ignoreBOM") >>= fromJSValUnchecked))
-- | <https://encoding.spec.whatwg.org/#dom-textdecoderoptions-ignorebom TextDecoderOptions.ignoreBOM specification>
getIgnoreBOMUnsafe :: (MonadDOM m, HasCallStack) => TextDecoderOptions -> m Bool
getIgnoreBOMUnsafe self = liftDOM ((((self ^. js "ignoreBOM") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://encoding.spec.whatwg.org/#dom-textdecoderoptions-ignorebom TextDecoderOptions.ignoreBOM specification>
getIgnoreBOMUnchecked :: (MonadDOM m) => TextDecoderOptions -> m Bool
getIgnoreBOMUnchecked self = liftDOM (((self ^. js "ignoreBOM") >>= valToBool))