Giter Club home page Giter Club logo

kuji's Introduction

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.

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
});

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

Coming next

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

Testing

To run the tests :

mocha

License

MIT

kuji's People

Contributors

kube avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.