Wraps a transform function to passes nullish values (null and undefined)
through unchanged instead of applying the transform.
Remarks
This is intended to solve the same problem as the Maybe monad in other functional languages
and libraries. It allows you to use nullish for error conditions, and to pass
potentially nullish values safely through a pipeline even when the individual functions
do not accept them as input.
Wraps a
transform
function to passes nullish values (null
andundefined
) through unchanged instead of applying the transform.Remarks
This is intended to solve the same problem as the Maybe monad in other functional languages and libraries. It allows you to use nullish for error conditions, and to pass potentially nullish values safely through a pipeline even when the individual functions do not accept them as input.
Example