Skip to content

Instantly share code, notes, and snippets.

View yejinjian's full-sized avatar
🎯
Focusing

tianwu yejinjian

🎯
Focusing
  • Hangzhou, China
View GitHub Profile
@yejinjian
yejinjian / Middleware.js
Created January 13, 2017 04:40 — forked from darrenscerri/Middleware.js
A very minimal Javascript (ES5 & ES6) Middleware Pattern Implementation
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));
});