Skip to content

Run asynchronous commands synchronously by putting them in a separate process

License

Notifications You must be signed in to change notification settings

ForbesLindesay/sync-rpc

Repository files navigation

sync-rpc

Run asynchronous commands synchronously by putting them in a separate process

Build Status Dependency Status NPM version

Installation

npm install sync-rpc --save

Usage

worker.js

function init(connection) {
  // you can setup any connections you need here
  return function (message) {
    // Note how even though we return a promise, the resulting rpc client will be synchronous
    return Promise.resolve('sent ' + message + ' to ' + connection);
  }
}
module.exports = init;
const assert = require('assert');
const rpc = require('sync-rpc');

const client = rpc(__dirname + '/../test-worker.js', 'My Server');

const result = client('My Message');

assert(result === 'sent My Message to My Server');

License

MIT

About

Run asynchronous commands synchronously by putting them in a separate process

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published