0.1.0 • Published 4 years ago
sidewalk v0.1.0
Sidewalk
Sidewalk allows you to require
a module into a separated process, and interact with it seamlessly. Multi-processing has never been this easy!
Install
const sidewalk = require("sidewalk");
Usage
Heres a side by side comparison of require
and sidewalk
:
Suppose you have a module
calc.js
// calc.js exports.add = function(x, y, callback) { callback(null, x + y); }
Use
require
to load it into the current processconst calc = require("./calc.js"); calc.add(1, 2, function(err, result) { console.log(result); });
Or use
sidewalk
to load it into a separated processconst calc = sidewalk("./calc.js").expose(["add"]); calc.add(1, 2, function(err, result) { console.log(result); });
Limitations
Sidewalk uses the built-in JSON based IPC, so it can NOT pass functions, regexes, errors, etc.
Remember to
expose
the method names first, or use theexec(func, arg1, arg2, ..., [callback])
API instead.> Theres no wildcard getters without using the `--harmony` flag, we might switch to a ES6 `Proxy` implementation later, and forget about the `expose`!
License
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (c) 2016 Yichao 'Peak' Ji
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.