Flatry
Flatry (flat try) converting promise or function to flat array response with [err, result]
.
Inspired by golang style error handling without try/catch.
Install
npm install flatry# or yarn add flatry
Use
;// orconst flatry = ;
Examples
Asynchronous (async/await)
// Beforeasync { try const categories = await app$axiossections; return categories ; catch err return ; } // Afterasync { const err res = await ; if err return ; return categories: ressections ;}
Synchronous
// Beforelet result = false;try result = catch error consoleconsole; // Afterconst err result = ;if err consoleconsole;