This program is designed to work in tandum with the EXEC to provide a library to support a multi-tasking system. This does nothing meaningful outside of context
Last updated 2 years ago by defiantcaptain .
MIT · Original npm · Tarball · package.json
$ cnpm install @defiantcaptain/spork-js 
SYNC missed versions from official npm registry.


Not designed for external conusmption as its usage won't make much sense.

 Spork.$('main.js').fork(1, (it) => {
     return ["bob"];
 }).join((results) => {
     process.send({event: 'done', results: results});
 }).error((err) => {

$('main.js') is the script to be executed, with Spork Spork::fork(n, callback) representing the number of main.js arguments to execute, and the callback designed to provide string[] as arguments to the program. join is called when all forked processes are completed, and the error is designed to provide details about the failure. start finalizes the process and beings the forking process formally.

start must always be invoked last, but fork, join and error can be added to the Spork in any order.

Objects and Whatnot


Interface to prevent objects from being reused. A Spork is intended to be used once only.

Spork implements IDisposable

Class that implements the forking logic.

  • static $(script : string) takes a string that is the script to be executed.
  • get eventID() : string is a uuidv1 of the Spork for mapping purposes.
  • isDisposed() : boolean is true if the object has been disposed. The object disposes itself.
  • join ((...) => void) is invoked when all forks are done.
  • error((...) => void) is invoked if there is a detected and expected error.
  • fork(n:number, (iteration) => string[]) is the forking operation that takes a number of iterations n and a closer that is invoked on each iteration to great a list of strings that serve as arguments.
  • start() to begin the forking process.
  • result(instanceID : string, value : any) is a callback to be invoked when a particular forked event has a result; each forked process as an instanceID for the fork.

All public facing functions, if invoked on a disposed object, will throw an error string this is dead. This object is not designed for reuse.

###Events SporkEvents.JOIN dispatched when all forks are done. SporkEvents.ERROR dispatched when an error happens. SporkProcessEvents.FORK_ME dispatched when we ask the governing application for forks. SporkProcessEvents.DONE is dispatched when a spawned process is complete.

###SporkHandler Namespace Contains a mapping object SporkMap that is a hash of outlying events. This is global, and each individual Spork deals with specific instances.

Current Tags

  • 1.1.4                                ...           latest (2 years ago)

1 Versions

  • 1.1.4                                ...           2 years ago
Maintainers (1)
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 2
Dependencies (3)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |