Simple NameSpace Base Class

A simple base class for instancing and extending upon a namespace.

JavaScript

window.NameSpace = window.Ns = (function () {

        var internal = {
            document: window.document,
            navigator: window.navigator,
            location: window.location,
            $: $,
            homeUrl: 'Main.html',
            methods: ['register'],
            uniqueIdCount: 0,
            protectedmethods: ['register', 'deregister', 'getGlobalProp', 'setGlobalProp']
        };

        var external = {};

        internal.makeNameSpace = function (externalCollection, internalCollection) {
            internalCollection = internalCollection || {
                document: internal.document,
                navigator: internal.navigator,
                location: internal.location,
                $: internal.$,
                homeUrl: 'Main.html',
                methods: ['register'],
                uniqueIdCount: 0,
                protectedmethods: ['register', 'deregister', 'getGlobalProp', 'setGlobalProp']
            };
            externalCollection = externalCollection || {};

            externalCollection.register = externalCollection.register ||
                function (name, obj, isProtected) {
                    /// <summary>
                    ///   Register an Object in the ChemSW namespace
                    /// </summary>
                    /// <param name="name" type="String"> Name of the object </param>
                    /// <param name="obj" type="Object"> Object to pass </param>
                    /// <param name="isProtected" type="Boolean"> If true, the object cannot be removed from the namespace </param>
                    /// <returns type="Boolean">True if the object name did not already exist in the namespace.</returns>
                    var succeeded = false;
                    if (internalCollection.methods.indexOf(name) === -1) {
                        internalCollection.methods.push(name);
                        obj[name] = true; //for shimming our own instanceof
                        if...