Created
July 10, 2015 13:52
-
-
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
This file contains 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
"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" | |
} |
This file contains 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
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