peerjs-rpc-mock
v1.0.0
Published
Mock for peerjs-rpc, mainly built for nodejs simulations
Downloads
2
Maintainers
Readme
peerjs-rpc-mock
Mock for peerjs-rpc, mainly built for nodejs simulations
Installation
npm install relekang/peerjs-rpc-mock
Usage
Either just use it directly:
var RPC = require('peerjs-rpc-mock');
var n1 = new RPC('n1', {});
var n2 = new RPC('n2', {add: function (a, b, callback) { callback(a + b); }});
n1.invoke('n2', 'add', [40, 2])
.then(function(result) {
console.log(result);
});
//=> 42
or use mock-require before requiring your dependencies using peerjs-rpc
var mr = require('mock-require');
mr('peerjs-rpc', require('peerjs-rpc-mock'));
var YourModule = require('your-module');
MIT © Rolf Erik Lekang