I'm writing a library and I'm not sure how to keep things secret (I don't want my constructors to be available as global objects).
// This is a no-no.
var SecretObj = function() { ... }
SecretLib.prototype.SecretObj = SecretObj;
But of course, I can do this :
// This is a no-no.
SecretLib.prototype.SecretObj = function() { ... }
// Its even worse when I have more
// prototypes on the SecretObj. Ex :
SecretLib.prototype.SecretObj.prototype.wowitslong = function() { ... }
But then again it's not good enough, so I did this :
// For more short code.
var SecretLib.fn = SecretLib.prototype;
(function(){
var SecretObj = function() { ... }
SecretObj.fn = SecretObj.prototype;
// And then
SecretObj.fn.finally = function() { ... }
// And to finish
SecretLib.fn.SecretObj = SecretObj;
})()
// But then, it becomes quite messy to write :
SecretLib.SecretObj.finally
// Or something like
SecretLib.SecretObj.InnerSecretObj.omg();
I don't know if it's good enough or if there is a better way. Thanks for your help.