pjs.fiber.wrapPromiseNoFail()





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 retunrs a Promise so that it can be called in a top-down manner within a fiber. If the promise is rejected, the error is attached to the return value. 

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 that returns an object 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 readFilePromise = require('fs-readfile-promise'); var readFile = pjs.fiber.wrapPromiseNoFail(readFilePromise); var response = readFile('./myfile'); var fileContent = ""; if (response.success) fileContent = response.output; else console.log(response.error);