truthyPromiseOrThrow
Returns a function that passes through truthy data or throws an error.
Available since v1.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
error | string | The error message to throw if data is falsy |
Returns
Section titled “Returns”function — A function that returns the data if truthy, or throws
Examples
Section titled “Examples”Pass through truthy values
Section titled “Pass through truthy values”Returns the value if truthy, throws otherwise.
Throw on falsy values
Section titled “Throw on falsy values”Throws an error when the value is falsy.
