Js.NullUtility functions on null
Provides functionality for dealing with the 'a Js.null type
type +'a t = 'a Js.nullLocal alias for 'a Js.null
val return : 'a -> 'a tConstructs a value of 'a Js.null containing a value of 'a
val empty : 'a tThe empty value, null
val getUnsafe : 'a t -> 'aval getExn : 'a t -> 'aMaps the contained value using the given function
If 'a Js.null 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
let maybeGreetWorld (maybeGreeting: string Js.null) =
Js.Null.bind maybeGreeting ~f:(fun greeting -> greeting ^ " world!")val iter : f:('a -> unit) Js.Fn.arity1 -> 'a t -> unitIterates over the contained value with the given function
If 'a Js.null contains a value, that value is unwrapped and applied to the given function.
let maybeSay (maybeMessage: string Js.null) =
Js.Null.iter maybeMessage ~f:(fun message -> Js.log message)val fromOption : 'a option -> 'a tMaps 'a option to 'a Js.null
| Some a | -> | return a |
| None | -> | empty |
val toOption : 'a t -> 'a optionMaps 'a Js.null to 'a option
| return a | -> | Some a |
| empty | -> | None |