pjs.fiber.wrapPromise()





This API is deprecated, starting in Profound.js 6. If running Profound.js 6 or higher, use async/await instead. See here for an example.

This API wraps a JavaScript function that returns a Promise so that it can be called in a top-down manner within a fiber.  

Parameters

  • JavaScript function that returns a Promise

  • (optional) the value of "this" provided for calls to the returned function. Note: This parameter is only available in Profound.js 4.8.2 or higher.

Return Value

Top-down function

Exception Handling

If the promise is rejected, an error is thrown.

Example

Run fs.readFile in a fiber
const readFilePromise = require('fs-readfile-promise'); var readFile = pjs.fiber.wrapPromise(readFilePromise); var fileContent = readFile('./myfile');