{-# LANGUAGE PatternSynonyms #-}
-- For HasCallStack compatibility
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.MimeTypeArray
       (item, item_, itemUnsafe, itemUnchecked, namedItem, namedItem_,
        namedItemUnsafe, namedItemUnchecked, getLength, MimeTypeArray(..),
        gTypeMimeTypeArray)
       where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MimeTypeArray.item Mozilla MimeTypeArray.item documentation> 
item :: (MonadDOM m) => MimeTypeArray -> Word -> m (Maybe MimeType)
item :: forall (m :: * -> *).
MonadDOM m =>
MimeTypeArray -> Word -> m (Maybe MimeType)
item MimeTypeArray
self Word
index
  = DOM (Maybe MimeType) -> m (Maybe MimeType)
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((MimeTypeArray
self MimeTypeArray
-> Getting (JSM JSVal) MimeTypeArray (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"item" [Word -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Word
index]) JSM JSVal
-> (JSVal -> DOM (Maybe MimeType)) -> DOM (Maybe MimeType)
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM (Maybe MimeType)
forall a. FromJSVal a => JSVal -> JSM (Maybe a)
fromJSVal)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MimeTypeArray.item Mozilla MimeTypeArray.item documentation> 
item_ :: (MonadDOM m) => MimeTypeArray -> Word -> m ()
item_ :: forall (m :: * -> *). MonadDOM m => MimeTypeArray -> Word -> m ()
item_ MimeTypeArray
self Word
index
  = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (MimeTypeArray
self MimeTypeArray
-> Getting (JSM JSVal) MimeTypeArray (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"item" [Word -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Word
index]))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MimeTypeArray.item Mozilla MimeTypeArray.item documentation> 
itemUnsafe ::
           (MonadDOM m, HasCallStack) => MimeTypeArray -> Word -> m MimeType
itemUnsafe :: forall (m :: * -> *).
(MonadDOM m, HasCallStack) =>
MimeTypeArray -> Word -> m MimeType
itemUnsafe MimeTypeArray
self Word
index
  = DOM MimeType -> m MimeType
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (((MimeTypeArray
self MimeTypeArray
-> Getting (JSM JSVal) MimeTypeArray (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"item" [Word -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Word
index]) JSM JSVal
-> (JSVal -> DOM (Maybe MimeType)) -> DOM (Maybe MimeType)
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM (Maybe MimeType)
forall a. FromJSVal a => JSVal -> JSM (Maybe a)
fromJSVal) DOM (Maybe MimeType)
-> (Maybe MimeType -> DOM MimeType) -> DOM MimeType
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
         DOM MimeType
-> (MimeType -> DOM MimeType) -> Maybe MimeType -> DOM MimeType
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> DOM MimeType
forall a. HasCallStack => String -> a
Prelude.error String
"Nothing to return") MimeType -> DOM MimeType
forall a. a -> JSM a
forall (m :: * -> *) a. Monad m => a -> m a
return)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MimeTypeArray.item Mozilla MimeTypeArray.item documentation> 
itemUnchecked ::
              (MonadDOM m) => MimeTypeArray -> Word -> m MimeType
itemUnchecked :: forall (m :: * -> *).
MonadDOM m =>
MimeTypeArray -> Word -> m MimeType
itemUnchecked MimeTypeArray
self Word
index
  = DOM MimeType -> m MimeType
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      ((MimeTypeArray
self MimeTypeArray
-> Getting (JSM JSVal) MimeTypeArray (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"item" [Word -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Word
index]) JSM JSVal -> (JSVal -> DOM MimeType) -> DOM MimeType
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM MimeType
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MimeTypeArray.namedItem Mozilla MimeTypeArray.namedItem documentation> 
namedItem ::
          (MonadDOM m, ToJSString name) =>
            MimeTypeArray -> name -> m (Maybe MimeType)
namedItem :: forall (m :: * -> *) name.
(MonadDOM m, ToJSString name) =>
MimeTypeArray -> name -> m (Maybe MimeType)
namedItem MimeTypeArray
self name
name = DOM (Maybe MimeType) -> m (Maybe MimeType)
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((MimeTypeArray
self MimeTypeArray -> name -> JSM JSVal
forall this name.
(MakeObject this, ToJSString name) =>
this -> name -> JSM JSVal
! name
name) JSM JSVal
-> (JSVal -> DOM (Maybe MimeType)) -> DOM (Maybe MimeType)
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM (Maybe MimeType)
forall a. FromJSVal a => JSVal -> JSM (Maybe a)
fromJSVal)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MimeTypeArray.namedItem Mozilla MimeTypeArray.namedItem documentation> 
namedItem_ ::
           (MonadDOM m, ToJSString name) => MimeTypeArray -> name -> m ()
namedItem_ :: forall (m :: * -> *) name.
(MonadDOM m, ToJSString name) =>
MimeTypeArray -> name -> m ()
namedItem_ MimeTypeArray
self name
name = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (MimeTypeArray
self MimeTypeArray -> name -> JSM JSVal
forall this name.
(MakeObject this, ToJSString name) =>
this -> name -> JSM JSVal
! name
name))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MimeTypeArray.namedItem Mozilla MimeTypeArray.namedItem documentation> 
namedItemUnsafe ::
                (MonadDOM m, ToJSString name, HasCallStack) =>
                  MimeTypeArray -> name -> m MimeType
namedItemUnsafe :: forall (m :: * -> *) name.
(MonadDOM m, ToJSString name, HasCallStack) =>
MimeTypeArray -> name -> m MimeType
namedItemUnsafe MimeTypeArray
self name
name
  = DOM MimeType -> m MimeType
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (((MimeTypeArray
self MimeTypeArray -> name -> JSM JSVal
forall this name.
(MakeObject this, ToJSString name) =>
this -> name -> JSM JSVal
! name
name) JSM JSVal
-> (JSVal -> DOM (Maybe MimeType)) -> DOM (Maybe MimeType)
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM (Maybe MimeType)
forall a. FromJSVal a => JSVal -> JSM (Maybe a)
fromJSVal) DOM (Maybe MimeType)
-> (Maybe MimeType -> DOM MimeType) -> DOM MimeType
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
         DOM MimeType
-> (MimeType -> DOM MimeType) -> Maybe MimeType -> DOM MimeType
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> DOM MimeType
forall a. HasCallStack => String -> a
Prelude.error String
"Nothing to return") MimeType -> DOM MimeType
forall a. a -> JSM a
forall (m :: * -> *) a. Monad m => a -> m a
return)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MimeTypeArray.namedItem Mozilla MimeTypeArray.namedItem documentation> 
namedItemUnchecked ::
                   (MonadDOM m, ToJSString name) =>
                     MimeTypeArray -> name -> m MimeType
namedItemUnchecked :: forall (m :: * -> *) name.
(MonadDOM m, ToJSString name) =>
MimeTypeArray -> name -> m MimeType
namedItemUnchecked MimeTypeArray
self name
name
  = DOM MimeType -> m MimeType
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((MimeTypeArray
self MimeTypeArray -> name -> JSM JSVal
forall this name.
(MakeObject this, ToJSString name) =>
this -> name -> JSM JSVal
! name
name) JSM JSVal -> (JSVal -> DOM MimeType) -> DOM MimeType
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM MimeType
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/MimeTypeArray.length Mozilla MimeTypeArray.length documentation> 
getLength :: (MonadDOM m) => MimeTypeArray -> m Word
getLength :: forall (m :: * -> *). MonadDOM m => MimeTypeArray -> m Word
getLength MimeTypeArray
self
  = DOM Word -> m Word
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (Double -> Word
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Word) -> JSM Double -> DOM Word
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((MimeTypeArray
self MimeTypeArray
-> Getting (JSM JSVal) MimeTypeArray (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter MimeTypeArray (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"length") JSM JSVal -> (JSVal -> JSM Double) -> JSM Double
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM Double
forall value. ToJSVal value => value -> JSM Double
valToNumber))