Created
October 27, 2009 14:24
-
-
Save kwhinnery/219596 to your computer and use it in GitHub Desktop.
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
// #1 - Define the master library | |
var TMA = { | |
ModuleOne: { | |
importantNumber: 2, | |
doSomething: function() { | |
return importantNumber+2; | |
} | |
}, | |
ModuleTwo: { | |
someProperty: true, | |
someFunction: function() { | |
return false; | |
} | |
} | |
}; | |
var firstResult = TMA.ModuleOne.doSomething(); // ----> 4 | |
// #2 - Extend the master library, using 'aspect-oriented' strategies if necessary | |
var oldDoSomething = TMA.ModuleOne.doSomething; | |
jQuery.extend(TMA.ModuleOne,{ | |
doSomething: function() { | |
var result = oldDoSomething(); | |
return result+2; | |
} | |
}); | |
var secondResult = TMA.ModuleOne.doSomething(); // ----> 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment