Giter Club home page Giter Club logo

chain's Introduction

chain

A middleware chain for plugins based only on async/await and dependency injections

Table of Contents

Features

  • extremely simple: the API exposes only two function : .use() and .run() !
  • chainability: isn't that obvious, it's a chain, so all calls can be chained onto the previous one !
  • simple semantic: to succeed, all links of the chain must give back a result, a single exception and the chain is broken !
  • dependency injection: give all of your plugins all the goodies they want (free logger, free context, free tools...) so that they will require less dependencies !
  • recursivity: a chain can be given to another chain and become a single link in a new process
  • tracability: the api enforces giving chains and plugins a name so that every single step of execution can be very traceable !
  • no dependency: yep

Motivations

adios callback hell and outdated libraries

There is a great deal of chain middlewares around there. So why a new one ? The answer to this question is quite simple : to go forward !, and to get rid of all the outdated libraries that were based on the callback(err, ..) paradigm (otherwise known as callback-hell) We think that this programmatic paradigm has served node.JS well (pretty well in fact as it radically redefined the asynchronous way of thinking for programmers), but now that a powerful replacement is available natively in the form of the async/await statements, it's time to leave that past in the dust...

So, simply told : the chain middleware does not support the callback(err, what) paradigm.

dependency injections

That's the other strongest motivation for this library : a lot of these other libraries totally forgot another key point of interest of using a middleware framework : the freebies !

I mean,

Installation

You'll need Node.js 8 or higher then, type in the console and in your project's directory :

npm install --save chain

or

yarn add chain

Example

Now, let's write a simple program that (...)

const chain = require('chain')

// let's write the most simple chain
chain('hello', {ensurePluginName: false}).use(str => str + ' World').use(console.log).run('Hello')

chain's People

Contributors

zipang avatar

Stargazers

 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.