0.1.0 • Published 11 years ago
sak-forkarguments v0.1.0
Sak-fork-arguments
Version 0.1.0
Encode a value to be passed in forking a process and then decoded and used.
Created by Thomas de Zeeuw, thomasdezeeuw@gmail.com (https://thomasdezeeuw.nl/).
Released under a MIT license.
Exports
encode
Function
Encode arguments to pass when forking a process.
Example
// Master process
var options = {port: 8000, env: 'production'}
, encoded = encode(options)
, child = cp.fork('./my-child-script.js', encoded);
Params
Name | Description | Type |
---|---|---|
data | The data to pass to the forked process. |
Return
Description | Type |
---|---|
An array with encoded data, ready to be passed to the forking function. | Array |
decode
Function
Decode arguments that are passed to a forked process.
Example
// Child process
var options = decode(process.argv.slice(2));
console.log('options', options); // options {port: 8000, env: 'production'}
Params
Name | Description | Type |
---|---|---|
args | The array from process.argv.slice(2), dropping the path to node bin and the file. | Array |
Return
Description | Type |
---|---|
The date passed to the forked process. | Object |
0.1.0
11 years ago