Function: tapNone()
Call Signature
tapNone<
T>(option,fn):Option<T>
Defined in: option/tap/index.ts:77
Performs a side effect when the Option is None.
If the Option is None, calls the function. Returns the original Option unchanged.
Useful for logging missing values or debugging.
Type Parameters
T
T
Parameters
option
Option<T>
The Option to tap
fn
() => void
Side effect function
Returns
Option<T>
The original Option
Example
// Data-first
tapNone(none(), () => console.log('No value'))
// Logs: "No value"
// => None
// Data-last (in pipe)
pipe(
findUser(id),
tapNone(() => console.log('User not found')),
unwrapOr(guestUser)
)
See
tap - for side effects on Some
Call Signature
tapNone<
T>(fn): (option) =>Option<T>
Defined in: option/tap/index.ts:78
Performs a side effect when the Option is None.
If the Option is None, calls the function. Returns the original Option unchanged.
Useful for logging missing values or debugging.
Type Parameters
T
T
Parameters
fn
() => void
Side effect function
Returns
The original Option
(
option):Option<T>
Parameters
option
Option<T>
Returns
Option<T>
Example
// Data-first
tapNone(none(), () => console.log('No value'))
// Logs: "No value"
// => None
// Data-last (in pipe)
pipe(
findUser(id),
tapNone(() => console.log('User not found')),
unwrapOr(guestUser)
)
See
tap - for side effects on Some