Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-fibers-synchronize-helper

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-fibers-synchronize-helper

helper for synchronize promise and callback

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

node-fibers-synchronize-helper

This helper uses synchronize module (https://www.npmjs.com/package/synchronize) and helps to manage promises and callbacks, you will be able to synch code and catch exceptions

Promise management:

var synchProm = require('node-fibers-synchronize-helper')
 
var testSynch = function () {
    try{
    //promise function call
        var db = synchProm.executePromiseFiberFn(MongoClient, MongoClient.connect, url)
    //get synch object and call promise function
        var dbProm = synchProm.getSynchPromiseObj(db);
        var stats = dbProm.executePromiseFiber(db.stats)

    //cursor.toArray promise version
        var cursor = collection_test.find({});
        var resProm = synchProm.executePromiseFiberFn(cursor, cursor.toArray)



    }catch(e){
        console.log(e)
    }

}


synchProm.executeSynch(testSynch, function (err, res) {
    if (err)
        console.log("err", err)
    else
        console.log("OK:", JSON.stringify(res, null, 4))
})

Callback management:

var synchProm = require('node-fibers-synchronize-helper')
 
var testSynch = function () {
    try{

    //cursor.toArray callback version
        cursor = collection_test.find({});
        var resCb = synchProm.executeFiberFn(cursor, cursor.toArray)
        assert.notEqual(null, resCb);

    //callback with param
        resCb = synchProm.executeFiberFn(cursor, cursor.count, true, {
            skip: 1
        })

    //multiparam result callback
        var resMultiCb = synchProm.executeFiberFnMultiParamCb(this, multiParamCB, ['res1', 'res2'], "a", "b", "c")   


    }catch(e){
        console.log(e)
    }

}


synchProm.executeSynch(testSynch, function (err, res) {
    if (err)
        console.log("err", err)
    else
        console.log("OK:", JSON.stringify(res, null, 4))
})

Keywords

FAQs

Package last updated on 20 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc