module Js_undefined:sig
..end
'a Js.undefined
typetype'a
t ='a Js.undefined
'a Js.undefined
val return : 'a -> 'a t
'a Js.undefined
containing a value of 'a
val test : 'a t -> bool
true
if the given value is empty
(undefined
), false
otherwiseval testAny : 'a -> bool
val empty : 'a t
undefined
val bind : 'a t -> ('a -> 'b [@bs]) -> 'b t
If 'a Js.undefined
contains a value, that value is unwrapped, mapped to a 'b
using
the given function a' -> 'b
, then wrapped back up and returned as 'b Js.undefined
let maybeGreetWorld (maybeGreeting: string Js.undefined) = Js.Undefined.bind maybeGreeting (fun greeting -> greeting ^ " world!")
val iter : 'a t -> ('a -> unit [@bs]) -> unit
If 'a Js.undefined
contains a value, that value is unwrapped and applied to
the given function.
let maybeSay (maybeMessage: string Js.undefined) = Js.Undefined.iter maybeMessage (fun message -> Js.log message)
val from_opt : 'a option -> 'a t
'a option
to 'a Js.undefined
Some a | -> | return a |
None | -> | empty |
val to_opt : 'a t -> 'a option
'a Js.undefined
to 'a option
return a | -> | Some a |
empty | -> | None |