Being built on top of deasync, this simple utility is to simplify the process of de-async callback functions.
$ npm install --save callsync
const callsync = require('callsync')
// Download a resource
// @param url: (String) A valid url
// @param callback: (Function) a function (err, result) to process result
function download(url, callback){
console.log('Downloading url = ' + url + '...')
var content = 'hi hi hi' // just fake it
callback(null, content)
}
var res = callsync( download, null, ['https://github.com/anhldbk/callsync'] )
// err = res[0], result = res[1]
For more usecases, have a look at ./test.js
The MIT License (MIT)