Nanotechnology Promises Much
    Have ideas to improve npm?Join in the discussion! »

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

    Keywords

    none

    Install

    npm i @zingle/sync

    DownloadsWeekly Downloads

    0

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    2.58 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar
    • avatar