Skip to content

Instantly share code, notes, and snippets.

@curioustechizen
Created July 10, 2015 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curioustechizen/98652aca149352c1fcc5 to your computer and use it in GitHub Desktop.
Save curioustechizen/98652aca149352c1fcc5 to your computer and use it in GitHub Desktop.
Snippet for Visual Studio Code that created a revealing module pattern with constructor in Javascript
"Revealing Module Pattern with constructor": {
"prefix": "reveal",
"body": [
"var ${1:ModuleName} = (function () {",
" var that,",
" constr = function (${2:constr_param}) {",
" that = this;",
" this.$2 = $2;",
" },",
"",
" ${3:privateFn} = function () {",
" var temp = that.$2;",
" };",
"",
" constr.prototype = {",
" constructor: $1,",
" $3: $3",
" };",
"",
" return constr;",
"})();"
],
"description": "An implementation of revealing module pattern with a constructor"
}
var ModuleName = (function () {
var that,
constr = function (constr_param) {
that = this;
this.constr_param = constr_param;
},
privateFn = function () {
var temp = that.constr_param;
};
constr.prototype = {
constructor: ModuleName,
privateFn: privateFn
};
return constr;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment