Code Monkey home page Code Monkey logo

jade-flow's Introduction

jade-flow

A powerful control flow model described by jade syntax.Inspired by koa.

You can write middleware/task in the same way as koa middleware.

Control flow in Koa

As we all know in koa, the control flow goes like this:

Let's say it looks like a U shape:

Once the flow reaches the bottom of the middleware stack, it has to go back along the way it comes.

What's the difference in jade-flow

It provides much more flexibilities and allows the control flow go like a W shape as below:

pic a:

or pic b:

Actually, you can make it whatever you want. All you need is a XML file to descirbe it.

For pic a as shown above, we can describe the flow like this:

middleware1
  middleware2
    middleware3
  middleware3

For pic b as shown above, we can describe the flow like this:

middleware1
  middleware2
middleware2
  middleware3

If you want it to behave as koa style, just describe it like this:

middleware1
middleware2
middleware3

Why jade?

Because it is convienient to write XML using its syntax. By using its lexer and parser, we can get the AST and analize what the flow is composed of.

Install

$ npm install jade-flow

Example

In real world, we can use this control flow model to handle multiple tasks that combined together to accomplish one goal, e.g. front end assets build includes tasks such as concat, sass(less), minify, uglify and so on.

Lisence

MIT

jade-flow's People

Contributors

luckydrq avatar

Stargazers

 avatar

Watchers

 avatar  avatar

jade-flow's Issues

一个例子

write
bundle
modular
static

a.js -> jquery

  • static: 找到a.js
  • modular: 转换成amd模块
  • bundle: 分析依赖,发现依赖jquery
  • static: 找到jquery
  • modular: 把jquery转换成amd模块
  • write: 写到a_bundle.js

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.