Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- console.clear();
- var cl = function(text){ console.log(text); }
- Sandbox.modules = {};
- Sandbox.modules.returnNumbers = function(MYAPP) {
- MYAPP.return100 = function() {return 100;};
- };
- Sandbox.modules.returnLetters = function(MYAPP) {
- MYAPP.returnABC = function() {return "ABC";};
- };
- function Sandbox() {
- var args = Array.prototype.slice.call(arguments); //Put the arguments
- var callback = args.pop(); //The last argument is the callback
- var requiredmodules = args; //The remaining arguments are the require
- for (i=0; i< requiredmodules.length; i++) {
- Sandbox.modules[requiredmodules[i]](this);
- }
- callback(this);
- }
- //Finally here is an example of usage
- new Sandbox('returnNumbers', 'returnLetters', function (MYAPP) {
- console.log(MYAPP.return100());
- console.log(MYAPP.returnABC());
- });
Advertisement
Add Comment
Please, Sign In to add comment