{"id":21578369,"url":"https://github.com/brianlima/namespaces.js","last_synced_at":"2025-03-18T07:31:41.753Z","repository":{"id":2246402,"uuid":"3201105","full_name":"BrianLima/Namespaces.js","owner":"BrianLima","description":"Javascript Namespace Controller","archived":false,"fork":false,"pushed_at":"2012-01-14T02:58:19.000Z","size":79,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T14:17:22.619Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BrianLima.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-17T16:46:19.000Z","updated_at":"2016-01-15T20:19:50.000Z","dependencies_parsed_at":"2022-09-09T18:00:24.673Z","dependency_job_id":null,"html_url":"https://github.com/BrianLima/Namespaces.js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrianLima%2FNamespaces.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrianLima%2FNamespaces.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrianLima%2FNamespaces.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrianLima%2FNamespaces.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BrianLima","download_url":"https://codeload.github.com/BrianLima/Namespaces.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244177648,"owners_count":20410993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T13:10:21.250Z","updated_at":"2025-03-18T07:31:41.720Z","avatar_url":"https://github.com/BrianLima.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Namespaces.js\n=============\nNamespaces.js helps you to organize complex Javascript namespaces. Featuring:\n\n * Event handlers\n * Asynchronous namespace loading\n * Callbacks\n * Cache control\n\nUsage\n-----\n\n### Configuring\nThere's just two options to customize Namespaces.js.\n\n * `Namespaces.baseUrl` (**Required**): Sets the base url which `Namespaces.js` will look for plugins. \u003cbr/\u003e\nExample: Setting `Namespaces.baseUrl` to `/MyScripts` and importing namespace `Foo.bar` will result in a `GET` operation to `/MyScripts/Foo/bar.js`\n * `Namespaces.stopCaching` (Optional. Default: `false`): If set to `true`, it will force requested pages not to be cached by the browser.\n\n\n### Creating a namespace:\n#### 1st way (less cool)\n\n    Namespaces(\"foo.bar\"); // Creates namespace foo.bar\n    foo.bar.log = function(message) {\n        if(console) console.log(message);\n    }\n    foo.bar.log(\"hello, world!\"); // Prints \"hello, world\" on console, if available.\n\n#### 2nd way (pretty groovy)\n\n    Namespaces(\"foo.bar\", {\n        log: function(message) {\n            if(console) console.log(message);\n        }\n    });\n    foo.bar.log(\"hello, world\"); // Prints \"hello, world\" on console, if available.\n\n### Importing an existent namespace\nImporting namespaces is pretty easy, you just need to specify which one you want to import.\n\n    Namespaces.import(\"foo.bar.test\"); // Imports foo/bar/test.js into document.\n\nAfter this point, you can access any `foo.bar.test`'s property or method.\n\n#### Using callbacks\nYou can also set callbacks (for success and error), which will be executed after the namespace gets imported.\n\n    Namespaces.import(\"foo.bar.inexistent\", function() {\n        foo.bar.log(\"imported successfully\");\n    }, function() {\n        foo.bar.log(\"something miserable happened.\");\n    });\n\n**Note:** Using callbacks will force `Namespaces.js` to make an Asynchronous HTTP request, while otherwise, a normal HTTP request is made.\n\n### Using event listeners\nIs possible to assign callback functions to a determined event using `addEventListener` and `removeEventListener` functions.\n\n#### Assigning events\n\n    Namespaces.addEventHandler(\"importFailed\", function(event) {\n        foo.bar.log(\"Failed to import namespace \" + event.Namespace);\n    });\n    // That anonymous function is called when an import operation fails. \n    // It also provides some event information, under the event argument.\n\n#### Removing an event assignment\n\n    Namespaces.removeEventHandler(\"importFailed\", function(event) {\n        foo.bar.log(\"Failed to import namespace \" + event.Namespace);\n    });\n    // Note that when removing an event assignment, you must provide the same parameters when assigning it.\n    \n\nLicense Information\n===================\n\nCopyright (c) 2012, Victor Gama de Oliveira.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice,\n  this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice,\n  this list of conditions and the following disclaimer in the documentation\n  and/or other materials provided with the distribution.\n\n* Neither the name of Victor Gama de Oliveira nor the names of its\n  contributors may be used to endorse or promote products derived from this\n  software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrianlima%2Fnamespaces.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrianlima%2Fnamespaces.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrianlima%2Fnamespaces.js/lists"}