2.0.0 • Published 8 years ago

middleware-resolver v2.0.0

Weekly downloads
1
License
LGPL-3.0
Repository
github
Last release
8 years ago

middleware-resolver

Dependency (and semi-event) based middleware running.

Task format

A tasks/jobs list is an array containing task descriptors:

propertydescription
requiresJobs required to be finished before this one can run.
optionalJobs that, if present, should be run before this one.
beforeJobs that, if present, will only run after this job completes (reverse dependency)
notifDon't run if task is completed. Implies optional dependency
priorityPriority hint. Higher means closer to the outter/first run middleware.
taskfunction (done, next) to execute. In the function body next("result_name");

For example:

[
    {
        name: "task7",
        requires: [ "task6" ],
        optional: "task1",
	priority: 10,
        task: function (done, next) {
            // more code

            /*  Emit the task name and, optionally, any auxiliary event /
                dependency that is satisfied. The done function can be used as
                many times as practical, or not at all (eg. a case of failure).
             */
            done("task7");

            // more code
            next(); // Run the next task
            // more code
        }
    }
]

Examples

Take a look at test.js in the repository for a simple example.

Notes & license

This project is available on GitHub and npm.

The project is licensed as LGPLv3, the license file is included in the project directory.

Copyright 2015 Stefan Hamminga - prjct.net