ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/ReadableStreamReadResult.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from streams (webref). Do not edit.
module GHCJS.DOM.JSFFI.Generated.ReadableStreamReadResult
(js_newReadableStreamReadResult, js_setValue, js_getValue, js_setDone, js_getDone, newReadableStreamReadResult, setValue, getValue, setDone, getDone, getDoneUnsafe, getDoneUnchecked, ReadableStreamReadResult(..), gTypeReadableStreamReadResult)
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 "(() => { return ({}); })"
js_newReadableStreamReadResult :: IO ReadableStreamReadResult
-- | <https://streams.spec.whatwg.org/#dictdef-readablestreamreadresult ReadableStreamReadResult specification>
newReadableStreamReadResult :: (MonadDOM m) => m ReadableStreamReadResult
newReadableStreamReadResult = liftDOM ((js_newReadableStreamReadResult))
foreign import javascript safe "(($1, $2) => { $1[\"value\"] = $2; })"
js_setValue :: ReadableStreamReadResult -> JSVal -> IO ()
-- | <https://streams.spec.whatwg.org/#dom-readablestreamreadresult-value ReadableStreamReadResult.value specification>
setValue :: (MonadDOM m) => ReadableStreamReadResult -> JSVal -> m ()
setValue self val = liftDOM (void ((js_setValue (self) (val))))
foreign import javascript unsafe "(($1) => { return $1[\"value\"]; })"
js_getValue :: ReadableStreamReadResult -> IO JSVal
-- | <https://streams.spec.whatwg.org/#dom-readablestreamreadresult-value ReadableStreamReadResult.value specification>
getValue :: (MonadDOM m) => ReadableStreamReadResult -> m JSVal
getValue self = liftDOM ((js_getValue (self)))
foreign import javascript safe "(($1, $2) => { $1[\"done\"] = $2; })"
js_setDone :: ReadableStreamReadResult -> Bool -> IO ()
-- | <https://streams.spec.whatwg.org/#dom-readablestreamreadresult-done ReadableStreamReadResult.done specification>
setDone :: (MonadDOM m) => ReadableStreamReadResult -> Bool -> m ()
setDone self val = liftDOM (void ((js_setDone (self) (val))))
foreign import javascript unsafe "(($1) => { return $1[\"done\"]; })"
js_getDone :: ReadableStreamReadResult -> IO JSVal
-- | <https://streams.spec.whatwg.org/#dom-readablestreamreadresult-done ReadableStreamReadResult.done specification>
getDone :: (MonadDOM m) => ReadableStreamReadResult -> m (Maybe Bool)
getDone self = liftDOM (((js_getDone (self)) >>= fromJSValUnchecked))
-- | <https://streams.spec.whatwg.org/#dom-readablestreamreadresult-done ReadableStreamReadResult.done specification>
getDoneUnsafe :: (MonadDOM m, HasCallStack) => ReadableStreamReadResult -> m Bool
getDoneUnsafe self = liftDOM ((((js_getDone (self)) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://streams.spec.whatwg.org/#dom-readablestreamreadresult-done ReadableStreamReadResult.done specification>
getDoneUnchecked :: (MonadDOM m) => ReadableStreamReadResult -> m Bool
getDoneUnchecked self = liftDOM ((pFromJSVal <$> (js_getDone (self))))