pjs.fiber.wrapAllNoFail()
This API is deprecated, starting in Profound.js 6. If running Profound.js 6 or higher, use Node's util.promisify() and async/await instead. See here for an example.
This API wraps all asynchronous functions attached to an object so that these functions can be called in a top-down manner within a fiber. The wrapped functions are attached to a property named 'fiber'. If the asynchronous call fails, no error is thrown; instead, it is attached to the return value.
This API is synonymous to pjs.fiber.wrapNoFail() used with objects.
The API assumes that the asynchronous functions accept a callback as the last parameter in the following format:
function(error, response)Â
This is typical for almost all asynchronous Node.js requests.Â
Parameter
Object
Return Value
An object with wrapped functions that return objects with the following properties:
success (true or false)
error (error object if success is false)
output (response output if success is true)
Exception Handling
No exceptions are thrown by this API.
Example
Run fs.readFile in a fiber
const fs = pjs.fiber.wrapAll(require('fs'));
var response = fs.fiber.readFile("somefile.txt", 'utf8');
var text = "";
if (response.success) text = response.output;
else console.log(response.error);