GithubHelp home page GithubHelp logo

task-group's Introduction

task-group

Node module to run a graph of tasks. This makes it super easy to manage groups of tasks that have dependencies, while running everything asynchronously and in parallel.

Example

var taskGroup = require('task-group');

taskGroup()
    .task('dir', function(done) {
        fs.mkdir('my-dir', done);
    })

    // The `file` task must have the `dir` task completed before it runs
    .task('file', ['dir'], function(done) {
        fs.writeFile('my-dir/file', 'Test file', done);
    })

    // Runs the `file` task, which depends on the `dir` task
    .run('file', function(err) {
        // `err` contains the error if an error occurred in any of the tasks that
        // were run.
    })

    // Runs all tasks
    .run(function(err) {

    })

    // Run multiple tasks
    .run(['file', ...], function(err) {

    });

Reference

taskGroup()

This returns a new task group, which has the #task and #run methods. The module exports this function directly.

The returned object's methods can be chained for more concise code.

#task(name, [dependencies], [action])

This method registers a task with the specified name. The name must be a string. Dependencies can be specified as an array containing the names of tasks that must be run before this task. If dependencies is omitted, it is assumed that there are not dependencies. action is a function that will be called when the task is to be run. It will be provided a callback function that it must call when the task is complete, optionally passing an error to it.

#run([tasks], [callback])

Runs the specified tasks. tasks can be a single string or an array of strings specifying all the tasks to run. If tasks is null or omitted, it will run all the registered tasks. callback is a function that is called when all tasks are complete, with the first parameter being the error if an error occured, or null.

License

MIT License. See the LICENSE file.

task-group's People

Contributors

conradz avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.