Simple class that represents either a success or failure.
yarn add @corollarium/retvaljs
const Retval = require('@corollarium/retvaljs');
Builds a Retval
object with the following properties:
retvalObj.status = status
retvalObj.message = message
- for
data
:- if is a single object then merge it with the
Retval
object - else if is a single value then
retvalObj.data = data[0]
- else if has any value then
retvalObj.data = data
- if is a single object then merge it with the
Throws an exception, with retval.message
as the message, if retval.status === false
.
Equivalent to new Retval(true, 'message', ...data)
Equivalent to new Retval(false, 'message', ...data)
yarn run test
yarn run lint