This is sort of what closures are meant to avoid, but I'm wondering if there's a way to a add a method to a closure. Basically I have a js file library that I'd like to augment for a specific client by adding a new method.
I have a js file called library:
var LIBRARY = (function(){
var name;
return {
setName: function(n) { name = n; }
}());
but for a new client I want to give them a new js file that will just augment LIBRARY, adding a new function:
function(first, last){
name = first + " " + last;
}
I don't want to have to modify the library js though. Is there any way to append this function to LIBRARY so that the function has the necessary access to the name variable?