process-calls
v0.1.10
Published
Make promisses and callbacks synchronous
Downloads
33
Maintainers
Readme
Table of Contents
ProcessCalls
Performs synchronization and resolution of callbacks and promises. It works only server-side with NodeJs 5.0.0 or higher.
####Examples of use
####ES6
import fs from 'fs';
import ProcessCalls from 'process-calls';
var myValue = ProcessCalls.receiveProc(fs.readdir,'./');
console.log(myValue);
import ProcessCalls from 'process-calls';
let myPromisse = new Promise(function (resolve, reject) {
setTimeout(() => {
try {
resolve("return string")
} catch (ex) {
reject("is bad status");
}
}, 5000);
});
var myValue = ProcessCalls.receiveProc(myPromisse);
console.log(myValue);
####ES5
var fs = require('fs');
var ProcessCalls = require('process-calls');
var myValue = ProcessCalls.default.receiveProc(fs.readdir,'./');
console.log(myValue);
var ProcessCalls = require('process-calls');
var myPromisse = new Promise(function (resolve, reject) {
setTimeout(function () {
try {
resolve("return string");
} catch (ex) {
reject("is bad status");
}
}, 5000);
});
var myValue = ProcessCalls.default.receiveProc(myPromisse);
console.log(myValue);
receiveProc
Function responsible for initiating the process of handling the waiting for the callbacks and promises.
Parameters
target
object => Function that generates a promise or callbackparams
any (optional, default[]
)