0.0.4 • Published 10 years ago

kuji v0.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

kuji

###Asynchronous Control Flow library for Node.

Browsers are not supported yet, it will be added later.

##Control Flow

###kuji.inline kuji.inline runs tasks in-line:

Inline Timeline Example

var kuji = require('kuji');

kuji.inline([
  function (next) {
    next();
  },
  function (next) {
    next();
  },
  function (next) {
    next();
  },
  function (next) {
    next();
  }
]);

###kuji.parallel kuji.parallel runs tasks in parallel and goes to the final callback when all tasks finished:

Parallel Timeline Example

var kuji = require('kuji');

kuji.parallel([
  function (next) {
    next();
  },
  function (next) {
    next();
  },
  function (next) {
    next();
  },
  function (next) {
    next();
  }
], function () {
  // This will be executed when all will be finished
});

###kuji.graph

kuji.graph permits you to easily run tasks graphs:

Graph Timeline Example

You can see that D will be executed once its dependencies (A and B) are finished, permitting you to be sure that the data you need from these tasks will be available.

For the moment you need to use a closure to share data between tasks, but this will be patched in the next few days.

var kuji = require('kuji'),
    dependsOn = kuji._dependsOn;

kuji.graph({
  a: function (next) {
    next()
  },
  b: function (next) {
    next();
  },
  c: function (next) {  
    next();
  },
  d: dependsOn(['a', 'b'], function (next) {
    next();
  }),
  e: dependsOn(['d', 'c'], function (next) {
    next();
  })
}, function () {
  // This will be executed at the end of your graph
});

##Coming next

  • Error handling through next()
  • Passing values through next()
  • Benchmark
  • Perfomance optimization

##Testing To run the tests :

mocha

##License MIT

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago