Created
August 24, 2022 02:18
-
-
Save DavidRogersDev/d4ea3059339befd864e408b135a13e5e to your computer and use it in GitHub Desktop.
CreateNamespace is a Function which can be used to Namespace your code if you are working with an old codebase.
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
// function from the old days before Modules. Was very handy if you wanted to namespace your code. | |
if (!window.createNamespace) { | |
window.createNamespace = function (name, separator, container) { | |
var o = container || window; | |
name.split(separator || '.').forEach(function (x) { | |
o = o[x] = o[x] || {}; | |
}); | |
return o; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment