pjs.fiber.wrapAll()
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'.
This API is synonymous to pjs.fiber.wrap() 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
Exception Handling
If the callback receives an error object, this error is thrown.
Example
Run fs.readFile in a fiber
const fs = pjs.fiber.wrapAll(require('fs'));
var text = fs.fiber.readFile("somefile.txt", 'utf8');
Alternative syntax
var fs = require('fs');
pjs.fiber.wrap(fs);
var text = fs.fiber.readFile("somefile.txt", 'utf8');