Module Js.Null_undefined

module Null_undefined: Js_null_undefined
Provide utilities arond Js.null_undefined

type 'a t = 'a Js.null_undefined 
Local alias for 'a Js.null_undefined
val return : 'a -> 'a t
Constructs a value of 'a Js.null_undefined containing a value of 'a
val test : 'a t -> bool
Returns true if the given value is null or undefined, false otherwise
val null : 'a t
The null value of type 'a Js.null_undefined
val undefined : 'a t
The undefined value of type 'a Js.null_undefined
val empty : 'a t
The empty value, undefined
val bind : 'a t -> ('a -> 'b [@bs]) -> 'b t
Maps the contained value using the given function

If 'a Js.null_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.null_undefined

 
let maybeGreetWorld (maybeGreeting: string Js.null_undefined) =
  Js.Undefined.bind maybeGreeting (fun greeting -> greeting ^ " world!")
val iter : 'a t -> ('a -> unit [@bs]) -> unit
Iterates over the contained value with the given function

If 'a Js.null_undefined contains a value, that value is unwrapped and applied to the given function.

 
let maybeSay (maybeMessage: string Js.null_undefined) =
  Js.Null_undefined.iter maybeMessage (fun message -> Js.log message)
val from_opt : 'a option -> 'a t
Maps 'a option to 'a Js.null_undefined

Some a -> return a
None -> undefined

val to_opt : 'a t -> 'a option
Maps 'a Js.null_undefined to 'a option

return a -> Some a
undefined -> None
null -> None