Created
November 11, 2013 04:31
-
-
Save anonymous/7407896 to your computer and use it in GitHub Desktop.
Small, moderately scale-able library boilerplate using an immediately invoked object expression
This file contains hidden or 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
!{ | |
//convenience methods here for create and expose via this | |
create: function(options){ | |
//constructor logic here | |
var created = Object.create(this.fn); | |
var args = [].slice.call(arguments); | |
this.plugins.forEach(function(plugin){ | |
plugin.apply(created, args); | |
}); | |
return created; | |
}, | |
fn:{//prototype methods here | |
}, | |
expose:function(NameSpace, window, document, plugins){ | |
window[NameSpace] = this;//This can be tweaked for whatever | |
this.document = document; | |
this.plugins = plugins; | |
} | |
}.expose("LibraryNamespaceHere", window, document, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment