packages feed

ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/TextDecoder.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from encoding (webref). Do not edit.
module GHCJS.DOM.JSFFI.Generated.TextDecoder
       (js_newTextDecoder, js_decode, newTextDecoder, decode, decode_, TextDecoder(..), gTypeTextDecoder)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import GHCJS.Types (JSVal, JSString)
import GHCJS.Foreign (jsUndefined, jsNull)
import GHCJS.DOM.Types
import qualified GHCJS.DOM.Types as Types
import GHCJS.DOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import GHCJS.DOM.JSFFI.Generated.Enums

foreign import javascript safe "(($1, $2) => { return new globalThis[\"TextDecoder\"]($1, $2); })"
        js_newTextDecoder :: (Optional JSString) -> JSVal -> IO TextDecoder
-- | <https://developer.mozilla.org/docs/Web/API/TextDecoder/TextDecoder MDN TextDecoder. documentation>
newTextDecoder :: (MonadDOM m, ToJSString label) => Maybe label -> Maybe TextDecoderOptions -> m TextDecoder
newTextDecoder label options = liftDOM (((P.maybe (P.return jsUndefined) toJSVal options) >>= \a2' -> js_newTextDecoder (toOptionalJSString label) a2'))

foreign import javascript safe "(($1, $2, $3) => { return $1[\"decode\"]($2, $3); })"
        js_decode :: TextDecoder -> JSVal -> JSVal -> IO JSString
-- | <https://developer.mozilla.org/docs/Web/API/TextDecoder/decode MDN TextDecoder.decode documentation>
decode :: (MonadDOM m, IsAllowSharedBufferSource input, FromJSString result) => TextDecoder -> Maybe input -> Maybe TextDecodeOptions -> m result
decode self input options = liftDOM ((fromJSString <$> ((P.maybe (P.return jsUndefined) toJSVal input) >>= \a2' -> (P.maybe (P.return jsUndefined) toJSVal options) >>= \a3' -> js_decode (self) a2' a3')))

-- | <https://developer.mozilla.org/docs/Web/API/TextDecoder/decode MDN TextDecoder.decode documentation>
decode_ :: (MonadDOM m, IsAllowSharedBufferSource input) => TextDecoder -> Maybe input -> Maybe TextDecodeOptions -> m ()
decode_ self input options = liftDOM (void (((P.maybe (P.return jsUndefined) toJSVal input) >>= \a2' -> (P.maybe (P.return jsUndefined) toJSVal options) >>= \a3' -> js_decode (self) a2' a3')))