{"_id":"nsdeclare","_rev":"6-b9cd7986491974db7568456211b2a5aa","name":"nsdeclare","description":"Safely declare a namespace using dot notation","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.0":{"name":"nsdeclare","version":"0.0.0","description":"Safely declare a namespace using dot notation","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/lazd/nsdeclare.git"},"keywords":["namespace","declare","declaration"],"author":{"name":"Larry Davis","email":"lazdnet@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/lazd/nsdeclare/issues"},"homepage":"https://github.com/lazd/nsdeclare","devDependencies":{"mocha":"~1.17.1","should":"~3.1.3"},"_id":"nsdeclare@0.0.0","dist":{"shasum":"c3b1aad07cfb5b206ad1875443a4e32917964c72","tarball":"https://registry.npmjs.org/nsdeclare/-/nsdeclare-0.0.0.tgz","integrity":"sha512-EUY7U5d+2T8kVwFWcoS91bH6cb58756zIwnXU/4j+5Ipc+UvtJ4e9HZyxFn/4eE8dXJLsC6Zkc+FWfPM2VLAog==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDThAIj56v2Xgr9EfNqG9aB7CoX9mtm7zgPvGV1G0VJHgIhAN/2lK36q4OBZsFC/hXLRdU/dVjZBQq8T345a7SRb6Bx"}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"lazd","email":"lazdnet@gmail.com"},"maintainers":[{"name":"lazd","email":"lazdnet@gmail.com"}]},"0.1.0":{"name":"nsdeclare","version":"0.1.0","description":"Safely declare a namespace using dot notation","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/lazd/nsdeclare.git"},"keywords":["namespace","declare","declaration"],"author":{"name":"Larry Davis","email":"lazdnet@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/lazd/nsdeclare/issues"},"homepage":"https://github.com/lazd/nsdeclare","devDependencies":{"mocha":"~1.21.3","should":"~4.0.4"},"_id":"nsdeclare@0.1.0","_shasum":"10daa153642382d3cf2c01a916f4eb20a128b19f","_from":".","_npmVersion":"1.4.7","_npmUser":{"name":"lazd","email":"lazdnet@gmail.com"},"maintainers":[{"name":"lazd","email":"lazdnet@gmail.com"}],"dist":{"shasum":"10daa153642382d3cf2c01a916f4eb20a128b19f","tarball":"https://registry.npmjs.org/nsdeclare/-/nsdeclare-0.1.0.tgz","integrity":"sha512-Wb+BpXFfacpp1cgrQoO5Q2wKHACuMlUE6uayGFFLF3yVuXejBp5Rflk991hWvTQbUuQslXTIvBNOHqYTvzBSjA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCFM0PLP0v/dBDRKpzu0xtw3HZnjPkZyNimSfGRzLS95gIgWozK751xP44jxQLs8b5C3vE+pGwsF6iJeIQatqjtW1c="}]}}},"readme":"# nsdeclare [![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis]\n> Safely declare a namespace using dot notation\n\n## Usage\n\n```js\nvar declare = require('nsdeclare');\n\nvar declaration = declare('MyApp.Templates');\n```\n\nResult:\n```js\nthis[\"MyApp\"] = this[\"MyApp\"] || {};\nthis[\"MyApp\"][\"Templates\"] = this[\"MyApp\"][\"Templates\"] || {};\n```\n\n## Options\n\nOptions can be passed as the second argument to `nsdeclare`.\n\n### value\nType: `String`\n\nBy passing `options.value`, you can use `nsdeclare` to both declare and safely assign properties of a namespace:\n\n```js\nvar declare = require('nsdeclare');\n\nvar declaration = declare('MyApp.Templates.Main', { value: 'function() { return \"Main\"; }' });\n```\n\nResult:\n```js\nthis[\"MyApp\"] = this[\"MyApp\"] || {};\nthis[\"MyApp\"][\"Templates\"] = this[\"MyApp\"][\"Templates\"] || {};\nthis[\"MyApp\"][\"Templates\"][\"Main\"] = function() { return \"Main\"; };\n```\n\n### declared\nType: `Object`\n\nTo avoid redeclaration, you can pass a list of already declared namespace parts as `options.declared`:\n\n```js\nvar declare = require('nsdeclare');\n\nvar options = {\n  declared: {\n    'MyApp': true\n  }\n};\n\nvar declaration = [\n  declare('MyApp.Views', options),\n  declare('MyApp.Templates', options),\n  declare('MyApp.Models', options),\n  declare('MyApp.Collections', options)\n].join('\\n');\n```\n\nResult:\n```js\nthis[\"MyApp\"][\"Views\"] = this[\"MyApp\"][\"Views\"] || {};\nthis[\"MyApp\"][\"Templates\"] = this[\"MyApp\"][\"Templates\"] || {};\nthis[\"MyApp\"][\"Models\"] = this[\"MyApp\"][\"Models\"] || {};\nthis[\"MyApp\"][\"Collections\"] = this[\"MyApp\"][\"Collections\"] || {};\n```\n\nNote that, if you don't pass `options.declared` and a namespace part is already declared, `nsdeclare` will not overwrite it.\n\n### separator\nType: `String`\n\nDefault: `'\\n'`\n\nIf you would like to separate declaration parts with something other than `\\n`, you can pass it as `options.separator`:\n\n```js\nvar declare = require('nsdeclare');\n\nvar declaration = declare('MyApp.Templates', { separator: '' });\n```\n\nResult:\n```js\nthis[\"MyApp\"] = this[\"MyApp\"] || {};this[\"MyApp\"][\"Templates\"] = this[\"MyApp\"][\"Templates\"] || {};\n```\n\n### root\nType: `String`\n\nDefault: `'this'`\n\nBy default, `nsdeclare` will declare namespaces within the `this` object (which defaults to `window` in browser environments). You can change this behavior with `options.root`:\n\n```js\nvar declare = require('nsdeclare');\n\nvar declaration = declare('MyApp.Templates', { root: 'global' });\n```\n\nResult:\n```js\nglobal[\"MyApp\"] = global[\"MyApp\"] || {};\nglobal[\"MyApp\"][\"Templates\"] = global[\"MyApp\"][\"Templates\"] || {};\n```\n\n### response\nType: `String`  \nDefault: `declaration`\n\nBy default, `nsdeclare` will return the declaration as a string. In some cases, you might want additional details such as a safe reference to the namespace itself. Passing `response: 'details'` will cause `nsdeclare` to return an object with the following properties:\n\n  * `namespace` - The namespace itself as a `String`\n  * `declaration` - The declaration of the namespace as a `String`\n\n```js\nvar declare = require('nsdeclare');\n\nvar declaration = declare('MyApp.Templates', { response: 'object' });\n```\n\nResult:\n```js\n{\n  namespace: 'this[\"MyApp\"][\"Templates\"]',\n  declaration: 'this[\"MyApp\"] = this[\"MyApp\"] || {};\\nthis[\"MyApp\"][\"Templates\"] = this[\"MyApp\"][\"Templates\"] || {};'\n}\n```\n\n[travis]: http://travis-ci.org/lazd/nsdeclare\n[travis-image]: https://secure.travis-ci.org/lazd/nsdeclare.png?branch=master\n\n[npm-url]: https://npmjs.org/package/nsdeclare\n[npm-image]: https://badge.fury.io/js/nsdeclare.png\n","maintainers":[{"name":"lazd","email":"lazdnet@gmail.com"}],"time":{"modified":"2022-06-22T11:41:05.437Z","created":"2014-03-07T21:45:32.298Z","0.0.0":"2014-03-07T21:45:32.298Z","0.1.0":"2014-07-28T05:35:20.921Z"},"homepage":"https://github.com/lazd/nsdeclare","keywords":["namespace","declare","declaration"],"repository":{"type":"git","url":"git://github.com/lazd/nsdeclare.git"},"author":{"name":"Larry Davis","email":"lazdnet@gmail.com"},"bugs":{"url":"https://github.com/lazd/nsdeclare/issues"},"license":"MIT","readmeFilename":"README.md"}