Interface: Nothing<T>
A Nothing
instance is the absent variant instance of the Maybe
type, representing the presence of a value which may be absent. For a full discussion, see the module docs.
Extends
Omit
<MaybeImpl
<T
>,"value"
>
Type Parameters
T
T
The type which would be wrapped in a Just
variant of the Maybe
.
Properties
isJust
isJust:
false
Overrides
Omit.isJust
isNothing
isNothing:
true
Is the Maybe
a Nothing
?
Overrides
Omit.isNothing
variant
readonly
variant:"Nothing"
Distinguish between the Just
and Nothing
variants.
Overrides
Omit.variant
Methods
and()
and<
U
>(mAnd
):Maybe
<U
>
Method variant for and
Type Parameters
U
U
Parameters
mAnd
Maybe
<U
>
Returns
Maybe
<U
>
Inherited from
Omit.and
andThen()
Call Signature
andThen<
U
>(andThenFn
):Maybe
<U
>
Method variant for andThen
Type Parameters
U
U
Parameters
andThenFn
(t
) => Maybe
<U
>
Returns
Maybe
<U
>
Inherited from
Omit.andThen
Call Signature
andThen<
R
>(andThenFn
):Maybe
<ValueFor
<R
>>
Method variant for andThen
Type Parameters
R
R
extends AnyMaybe
Parameters
andThenFn
(t
) => R
Returns
Maybe
<ValueFor
<R
>>
Inherited from
Omit.andThen
ap()
ap<
A
,B
>(this
,val
):Maybe
<B
>
Method variant for ap
Type Parameters
A
A
B
B
extends object
Parameters
this
Maybe
<(val
) => B
>
val
Maybe
<A
>
Returns
Maybe
<B
>
Inherited from
Omit.ap
equals()
equals(
comparison
):boolean
Method variant for equals
Parameters
comparison
Maybe
<T
>
Returns
boolean
Inherited from
Omit.equals
get()
get<
K
>(key
):Maybe
<NonNullable
<T
[K
]>>
Method variant for get
If you have a Maybe
of an object type, you can do thatMaybe.get('a key')
to look up the next layer down in the object.
type DeepOptionalType = {
something?: {
with?: {
deeperKeys?: string;
}
}
};
const fullySet: DeepType = {
something: {
with: {
deeperKeys: 'like this'
}
}
};
const deepJust = Maybe.of(fullySet)
.get('something')
.get('with')
.get('deeperKeys');
console.log(deepJust); // Just('like this');
const partiallyUnset: DeepType = { something: { } };
const deepEmpty = Maybe.of(partiallyUnset)
.get('something')
.get('with')
.get('deeperKeys');
console.log(deepEmpty); // Nothing
Type Parameters
K
K
extends string
| number
| symbol
Parameters
key
K
Returns
Maybe
<NonNullable
<T
[K
]>>
Inherited from
Omit.get
map()
map<
U
>(mapFn
):Maybe
<U
>
Method variant for map
Type Parameters
U
U
extends object
Parameters
mapFn
(t
) => U
Returns
Maybe
<U
>
Inherited from
Omit.map
mapOr()
mapOr<
U
>(orU
,mapFn
):U
Method variant for `mapOr`
Type Parameters
U
U
Parameters
orU
U
mapFn
(t
) => U
Returns
U
Inherited from
Omit.mapOr
mapOrElse()
mapOrElse<
U
>(orElseFn
,mapFn
):U
Method variant for mapOrElse
Type Parameters
U
U
Parameters
orElseFn
() => U
mapFn
(t
) => U
Returns
U
Inherited from
Omit.mapOrElse
match()
match<
U
>(matcher
):U
Method variant for match
Type Parameters
U
U
Parameters
matcher
Matcher
<T
, U
>
Returns
U
Inherited from
Omit.match
or()
or(
mOr
):Maybe
<T
>
Method variant for or
Parameters
mOr
Maybe
<T
>
Returns
Maybe
<T
>
Inherited from
Omit.or
orElse()
Call Signature
orElse(
orElseFn
):Maybe
<T
>
Method variant for orElse
Parameters
orElseFn
() => Maybe
<T
>
Returns
Maybe
<T
>
Inherited from
Omit.orElse
Call Signature
orElse<
R
>(orElseFn
):Maybe
<ValueFor
<R
>>
Method variant for orElse
Type Parameters
R
R
extends AnyMaybe
Parameters
orElseFn
() => R
Returns
Maybe
<ValueFor
<R
>>
Inherited from
Omit.orElse
toJSON()
toJSON():
MaybeJSON
<unknown
>
Method variant for toJSON
Returns
MaybeJSON
<unknown
>
Inherited from
Omit.toJSON
toString()
toString():
string
Method variant for toString
Returns
string
Inherited from
Omit.toString
unwrapOr()
unwrapOr<
U
>(defaultValue
):T
|U
Method variant for unwrapOr
Type Parameters
U
U
Parameters
defaultValue
U
Returns
T
| U
Inherited from
Omit.unwrapOr
unwrapOrElse()
unwrapOrElse<
U
>(elseFn
):T
|U
Method variant for unwrapOrElse
Type Parameters
U
U
Parameters
elseFn
() => U
Returns
T
| U
Inherited from
Omit.unwrapOrElse