Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

azuki-trusty / azk   deb

Repository URL to install this package:

Version: 0.5.1 

/ usr / lib / azk / node_modules / q-io / http-apps / chain.js


module.exports = Chain;
function Chain(end) {
    var self = Object.create(Chain.prototype);
    self.end = end || function (next) {
        return next;
    };
    return self;
};

Chain.prototype.use = function (App /*, ...args*/) {
    if (!App) throw new Error("App is not defined after " + this.app);
    var args = Array.prototype.slice.call(arguments, 1);
    var self = this;
    this.end = (function (End) {
        return function Self(next) {
            if (self.end !== Self && !next) throw new Error("App chain is broken after " + App);
            return End(App.apply(null, [next].concat(args)));
        };
    })(this.end);
    this.app = App;
    return this;
};