isSome is a convenience shortcut to isSome
isEmpty is a convenience shortcut to isNone
Returns true if the option is None, false otherwise.
Returns true if the option is an instance of Some, false otherwise.
Returns the result of applying $f to this Option's value if
this Option is nonempty.
Returns None if this Option is empty.
Slightly different from map
in that $f is expected to
return an Option (which could be None).
const f = (x:number) => Option(undefined);
const o = Option<number>(5)
const result = o.flatMap(f).getOrElse(-1) // -1
Returns None in all cases
get throws an Error if this is a None
Returns a Some containing the result of applying $f to this $option's value if this $option is nonempty. Otherwise return $none.
const f = (x:number): number => x * 2;
const o = Option<number>(5)
const result = o.map(f).getOrElse(-1) // 10
Generated using TypeDoc
Class
None<A>
represents non-existent values of typeA
.const s: None<any> = new None<any>() const t: None<any> = Option.none const u: None<any> = Option(null) const v: None<any> = Option(undefined) const w: None<any> = Option.some(null) const x: None<any> = Option.some(undefined) const y: None<any> = Option.apply(null) const z: None<any> = Option.apply(undefined)