Created
May 10, 2011 18:12
-
-
Save trevmex/965022 to your computer and use it in GitHub Desktop.
JavaScript template to make private functions testable
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
| if (typeof NS === 'undefined' || !NS) { | |
| var NS = {}; | |
| } | |
| (function ($) { | |
| NS.Klass = function(options) { | |
| var settings = { | |
| debug: false | |
| }, | |
| private = { | |
| // Public Functions | |
| }, | |
| public = { | |
| // Private Functions | |
| }; | |
| if (options) { | |
| $.extend(settings, options); | |
| } | |
| if (settings.debug) { | |
| return $.extend({}, private, public); | |
| } else { | |
| return public; | |
| } | |
| }; | |
| })(jQuery); | |
| var myClass = new NS.Klass(); // Regular usage | |
| var myDebugClass = new NS.Klass({debug: true}); // Debug usage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment