Function that generates a "then" function for Promise that avoid any truthy value by throwing an error.
Falsy values: false, 0, -0, 0n, "", null, undefined, and NaN
import { falsyPromiseOrThrow } from '@helpers4/promise'Promise.resolve('good value') .then(falsyPromiseOrThrow('My custom error message')) .then(console.log)// => 'My custom error message'
the error message thrown if the data is falsy
Generated using TypeDoc
Function that generates a "then" function for Promise that avoid any truthy value by throwing an error.
Falsy values: false, 0, -0, 0n, "", null, undefined, and NaN
Example (es module)