Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section
Column
width25%

Parameters


  • asynchronous function
  • this argument (optional)
    (info) Typically, the parent object of the function is passed; this is required if internally the function uses the this keyword.
Column
width25%

Alternative Parameters


  • object containing asynchronous functions
Column
width25%

Return Value


A top-down function is returned.

Column
width25%

Exception Handling


If the callback receives an error object, an error is thrown.

Shortcut

pjs.wrap() is a shortcut for pjs.fiber.wrap().

Examples

Code Block
titleWrap fs.readFile in a fiber
const fs = require('fs');
var readFile = pjs.fiber.wrap(fs.readFile);
var text = readFile("somefile.txt", 'utf8');
Code Block
languagejavascript
titleWrap all fs API in a fiber
const fs = pjs.fiber.wrap(require('fs'));
var text = fs.fiber.readFile("somefile.txt", 'utf8');

...