tm-result
v0.1.0
Published
The common result object library
Downloads
5
Readme
tm-result
Return and process results of functions or api calls as a JS object.
The common result object format is
{ status, result, [data], [messages] }
status
String with possible two values 'ok' or 'nok'(means not ok).result
String which should be equal to 'ok' ifstatus
is 'ok', or should contain details about why result is not ok.data
could be any value and contains a result data.messages
Array of messages for 'nok' results(can be passed as a rest arguments to the genNOk method).
Installation
npm i tm-result
Functions
genOk
Generates 'OK' result object.genNOk
Generates 'not OK' result object.isOk
Checks if passed arg is an 'OK' result object.isNOk
Checks if passed arg is a 'not OK' result object.