@zingle/sync

1.0.0 • Public • Published

Sync Function

The sync function can be used to bridge async functions with traditional continuation-passing style (CPS) functions. Use the sync function to create a callback with an associated Promise which can be used as a deferred result for the callback.

Example

const fs = require("fs");
const sync = require("sync");

async function asyncReadFile(file) {
    const done = sync();        // create synchronization primitive
    fs.readFile(file, done);    // pass primitive as CPS callback
    return done.promise;        // return resulting promise
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    0
  • 0.0.2
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i @zingle/sync

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

2.58 kB

Total Files

5

Last publish

Collaborators

  • njovin
  • oleksandr.vladymyrov
  • rremer
  • lmedrano
  • llongo-medallia