@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
}

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i @zingle/sync

    Weekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    2.58 kB

    Total Files

    5

    Last publish

    Collaborators

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