Skip to content

Instantly share code, notes, and snippets.

@255kb
Last active August 29, 2015 14:15
Show Gist options
  • Save 255kb/60f632a8adecf14c7cb5 to your computer and use it in GitHub Desktop.
Save 255kb/60f632a8adecf14c7cb5 to your computer and use it in GitHub Desktop.
Javascript library pattern (instantiable object)
/* Replace 'library' by your library name */
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
//AMD
define([], factory);
} else if (typeof module !== 'undefined' && module.exports) {
//Node.js or CommonJS
module.exports = factory();
} else {
//Global
root.library = factory();
}
}(this, function() {
'use strict';
function library(){
};
library.prototype = {
};
return library;
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment