Skip to content

Instantly share code, notes, and snippets.

View riyaz-ali's full-sized avatar
:octocat:

Riyaz Ali riyaz-ali

:octocat:
View GitHub Profile
@riyaz-ali
riyaz-ali / Middleware.js
Last active February 13, 2018 17:51 — forked from darrenscerri/Middleware.js
A very minimal Javascript (ES5) Middleware Pattern Implementation
let Middleware = function() { };
// executes the middlewares supplying initial args to the first middleware
// this function returns a Promise which gets resolved after the last middleware is executed
Middleware.prototype.exec = function() {
let args = Array.prototype.slice.call(arguments);
let that = this
return new Promise(function(resolve /*,reject */){
let pr = this;
let end = function(){