meaningPromiseOrThrow
Returns a function that passes through meaningful data or throws an error. Data is considered meaningless if it is null, undefined, empty string, empty object, or empty array.
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 meaningless |
Returns
Section titled “Returns”function — A function that returns the data if meaningful, or throws
Examples
Section titled “Examples”Pass through meaningful values
Section titled “Pass through meaningful values”Returns the value if it is not empty (null, undefined, empty string, empty object, empty array).
Throw on empty values
Section titled “Throw on empty values”Throws when the value is null, undefined, empty string, empty object, or empty array.
