Skip to content

Instantly share code, notes, and snippets.

@j3lte
Created September 9, 2013 12:48
Show Gist options
  • Select an option

  • Save j3lte/6495129 to your computer and use it in GitHub Desktop.

Select an option

Save j3lte/6495129 to your computer and use it in GitHub Desktop.
/**
* j3lte namespace object.
* Creates the j3lte object without overriding previous instances of it.
*/
var j3lte = (j3lte === undefined) ? {} : j3lte;
j3lte.namespace = function () {
var a = arguments, o = null, i, j, d;
for (i = 0; i < a.length; i = i + 1) {
d = ("" + a[i]).split(".");
o = j3lte;
// j3lte is implied, so it is ignored if it is included
for (j = (d[0] === "j3lte") ? 1 : 0; j < d.length; j = j + 1) {
o[d[j]] = o[d[j]] ||
{};
o = o[d[j]];
}
}
return o;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment