work

Got a thousand jobs to do? Get an execution plan!

npm install work
1 downloads in the last week
11 downloads in the last month

NPM version Dependency Status Analytics

under construction

Work

Got a thousand jobs to do? Get an execution plan! Work provides a means to build a hierarchy of jobs, executed in the order, and with the strategy provided. Build your own dashboard to monitor events / progress or use the one built it. Work makes use of the Composite Pattern.

Synopsis

var work = require("work");
var housework = new work.Job({ name: "housework" }).add([
    {
        name: "play music", 
        parallel: true,
        command: launchPlaylist,
        args: "Al Green"
    },
    { 
        name: "wash dishes",
        command: wash,
        args: [ pots, pans, cutlery ],
        onProgress: {
            name: "change music",
            commandSync: function(){
                // half way through washing the dishes
                if (this.progress.percentComplete == 50){
                    launchPlaylist("Metal");
                }
            }
        },
        onComplete: [
            {
                name: "wipe worktops",
                command: wash,
                args: [ worktops ],
                onSuccess: {
                    name: "procrastinate",
                    command: postFacebookStatus,
                    args: "I'm a model parent and my kids are clever. "
                }
            }
        ]
    },
    {
        name: "mop floor",
        command: wash,
        args: [ kitchenFloor, hallFloor ]
    }
]);

// get to work, monitoring progress on stdout
housework.monitor(process.stdout).run();

Install

$ npm install work

Test

$ git clone https://github.com/75lb/work.git
$ cd work
$ npm test

NPM

npm loves you