Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

yejinjian

🎯
Focusing
View GitHub Profile
@yejinjian
yejinjian / Middleware.js
Created Jan 13, 2017 — forked from darrenscerri/Middleware.js
A very minimal Javascript (ES5 & ES6) Middleware Pattern Implementation
View Middleware.js
var Middleware = function() {};
Middleware.prototype.use = function(fn) {
var self = this;
this.go = (function(stack) {
return function(next) {
stack.call(self, function() {
fn.call(self, next.bind(self));
});