justo-sync

0.1.1 • Public • Published

NPM version Build Status Dependency Status devDependency Status

A synchronizer.

Proudly made with ♥ in Valencia, Spain, EU.

Install

npm install justo-sync

Use

const sync = require("justo-sync");

The package is a function to run an asynchronous function synchronously. This function is:

function sync(fn : function(done)) : object

sync runs the given function and it returns the value returned by the asynchronous function. The asynchronous function must run its done parameter when ended:

done()               //sync() returns undefined
done(error)          //sync() throws error
done(undefined, res) //sync() returns the result

Examples

const sync = require("justo-sync");

//sync() will finish throwing an error
sync(function(done) {
  done(new Error("This is the error message."));
});

//sync() will finish returning a value
sync(function(done) {
  done(undefined, "the value to return by sync()");
});

Readme

Keywords

none

Package Sidebar

Install

npm i justo-sync

Homepage

justojs.org

Weekly Downloads

1

Version

0.1.1

License

none

Last publish

Collaborators

  • justojs