Created
June 26, 2012 12:45
-
-
Save aspyct/2995609 to your computer and use it in GitHub Desktop.
A short dependency container for javascript / node applications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ServiceBox = function () { | |
var self = this; | |
this.wrap = function (func) { | |
return function () { | |
return func.apply(self, arguments); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment