This package has been deprecated

Author message:

Development of this module has been stopped.

fork-function

1.2.2 • Public • Published

fork-function Build Status js-standard-style

Fork a function to a child process.

Usage

Installation:

$ npm install fork-function

API:

forkFunction (function, callback)

Do stuff with the first function, this is passed to a newly created child process. The callback is called once the function is done (using the following pattern (err, result)), the first function is passed a function as its only argument, which when called (it accepts a single argument as the result value(s)) passes the value(s) back to the callback in the main process and ends the child process.

Example:

var forkFunction = require('fork-function')

forkFunction(function (done) {
  setTimeout(function () {
    // do some intense async work
    // ...
    // then call `done()` with some result
    done({hello: ['world']})
  }, 1500)
}, function (err, result) {
  if (err) console.error(err)
  console.log(result) // {hello: ['world']}
})

Package Sidebar

Install

npm i fork-function

Weekly Downloads

0

Version

1.2.2

License

MIT

Last publish

Collaborators

  • roryrjb