public
Created

A short dependency container for javascript / node applications

  • Download Gist
NodeJs example .js
JavaScript
1 2 3 4 5 6 7 8 9
> var sb = new ServiceBox();
> sb.msg = "Hello World";
> var handler = sb.wrap(function (prefix) {
... console.log(prefix);
... console.log(this.msg);
... });
> handler("this is the prefix");
this is the prefix
Hello World
ServiceBox.js
JavaScript
1 2 3 4 5 6 7 8
var ServiceBox = function () {
var self = this;
this.wrap = function (func) {
return function () {
return func.apply(self, arguments);
}
}
};

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.