Last active
April 3, 2017 18:50
-
-
Save pnmcosta/802d1ac947b2a049a1b0f138c267abea to your computer and use it in GitHub Desktop.
Example CommonJS Module Wrapped by Brunch with options, private and public methods and properties
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
/** | |
* Example CommonJS Module Wrapped by Brunch with options, private and public methods | |
* Usage with defaults: require("brunch.commonjs.options.module")() | |
* Usage with options: require("brunch.commonjs.options.module")({myOptionName:false}) | |
*/ | |
"use strict"; | |
// require's and constants | |
const $ = require("jquery"); | |
// module public properties and methods | |
var me = { | |
myOptionName:true | |
} | |
me.myMethod = function(arg1){ | |
} | |
// private properties and methods | |
var someOtherVar = "woopwoop"; | |
function myPrivateMethod(){ | |
} | |
// example initialization | |
$(document).ready(function () { | |
}); | |
// example extend options (uses jQuery) and export of module | |
module.exports = function (options) { | |
if (options) | |
me = $.extend({}, me, options); | |
return me; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment