Created
January 21, 2012 06:22
-
-
Save sudodo/1651686 to your computer and use it in GitHub Desktop.
JavaScript constructor module pattern skelton
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
MYAPP.namespace('MYAPP.utilities.Array'); | |
MYAPP.utilities.Array = (function () { | |
// dependencies | |
var uobj = MYAPP.utilities.object, | |
ulang = MYAPP.utilities.lang; | |
// private properties and methods... | |
var Constr; | |
// end var | |
// optionally one-time init procedures | |
// ... | |
// public API -- constructor | |
Constr = function (o) { | |
this.elements = this.toArray(o); | |
}; | |
// public API -- prototype | |
Constr.prototype = { | |
constructor: MYAPP.utilities.Array, version: "2.0", | |
toArray: function (obj) { | |
for (var i = 0, a = [], len = obj.length; i < len; i += 1) { | |
a[i] = obj[i]; } | |
return a; } | |
}; | |
// return the constructor | |
// to be assigned to the new namespace | |
return Constr; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment