Methods
cast
- cast<S>(guard): Optional<S>
Parameters
- guard: ((o) => boolean)
- (o): boolean
Returns boolean
equals
- equals(val, isEqual?): boolean
Parameters
- val: Optional<T>
- isEqual: ((a, b) => boolean) = strictEquals
- (a, b): boolean
Returns boolean
Returns boolean
filter
- filter(predicate): Optional<T>
Parameters
- predicate: ((v) => boolean)
- (v): boolean
Returns boolean
ifPresent
- ifPresent(consumer): {
orElse: ((f) => void);
} Parameters
- consumer: ((val) => void)
Returns {
orElse: ((f) => void);
}
isPresent
- isPresent(): boolean
Returns boolean
map
- map<O>(mapper): Optional<O>
- map<U>(mapper): Optional<U>
Parameters
- mapper: ((v) => undefined | null | U)
- (v): undefined | null | U
Returns undefined | null | U
orElse
- orElse(other): T
Returns T
orElseGet
- orElseGet(other): T
Returns T
orElseThrow
- orElseThrow(exceptionSupplier): T
Parameters
- exceptionSupplier: (() => Error)
Returns T
orNothing
- orNothing(): undefined | T
Returns undefined | T
orNull
- orNull(): null | T
Returns null | T
property
- property<K>(key): undefined | T[K]
Type Parameters
- K extends string | number | symbol
Returns undefined | T[K]
- property<K>(key, orElse): NonNullable<T[K]>
Type Parameters
- K extends string | number | symbol
toJSON
- toJSON(): undefined | T
Returns undefined | T
An implementation of https://docs.oracle.com/javase/8/docs/api/java/util/fp/Optional.html