{"_id":"edmond","_rev":"5-4e8f18155cc8cfeb6b820decb95e017d","name":"edmond","description":"Simple JavaScript router for web applications.","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"edmond","description":"Simple JavaScript router for web applications.","version":"0.1.0","author":{"name":"František Hába","email":"hello@frantisekhaba.com"},"devDependencies":{"nodeunit":"0.5.1"},"keywords":["pushState","popState","html5","router","route","routes"],"homepage":"https://github.com/Baggz/Edmond","repository":{"type":"git","url":"git://github.com/Baggz/Edmond.git"},"engines":{"node":">= 0.3.0"},"bugs":{"email":"hello@frantisekhaba.com","url":"https://github.com/Baggz/Edmond/issues"},"licenses":[{"type":"MIT","url":"https://github.com/Baggz/Edmond/blob/master/README.md"}],"scripts":{"test":"nodeunit tests/"},"_npmUser":{"name":"baggz","email":"hello@frantisekhaba.com"},"_id":"edmond@0.1.0","dependencies":{},"_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.4.11","_defaultsLoaded":true,"dist":{"shasum":"98a9919ea69e9f2db16650f964bdbb75f257e8e2","tarball":"https://registry.npmjs.org/edmond/-/edmond-0.1.0.tgz","integrity":"sha512-UQVRM4EdKLaWFy+5ypmBQSflcMI3/7JZkio74AFJITj4Xrw/ERMsuzVjjerB1QR3k2z6vtBkNZrR82QIiaiTBQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGonib+X6AwCe6Ay0X5YehAb2v4/LTW0x23YbT0FsPe1AiAd+h101ApCdT58BSKKYeZ+04m0VyOm1QkKdIU1UxABvw=="}]},"maintainers":[{"name":"baggz","email":"hello@frantisekhaba.com"}]}},"readme":"# Edmond\n\nEdmond is simple JavaScript router for web applications. Although Edmond was originally designed for use in the browser, it can also be used with Node.js.\n\n### Features\n\n* Edmond has **no dependencies**\n* **AMD compatible**, you can load it via [RequireJS](https://github.com/jrburke/requirejs)\n* Ultra lightweight, **under 1 KB**\n* Fully **documented**\n\n## Quick Start\n\n1. Add a new route\n\n    ```javascript\n    edmond.addRoute('/users/:id', function(request) {\n\n      // Do something...\n\n    });\n    ```\n\n2. Listen to the ‘error’ event\n\n    ```javascript\n    edmond.on('error', function(message) {\n\n      // Do something...\n\n    });\n    ```\n\n3. Dispatch the route\n\n    ```javascript\n    edmond.dispatchRoute('/users/123');\n    ```\n\n    *Please see the [Tips](#tips) section for more information about implementing HTML5 history.*\n\n## Download\n\nReleases are available for download from GitHub.\n\n| **Version** | **Description** | **Size** | **Action** |\n|:------------|:----------------|:---------|:-----------|\n| `edmond.js` | *uncompressed, with comments* | 1 KB | [Download](https://raw.github.com/Baggz/Edmond/master/src/edmond.js) |\n| `edmond.min.js` | *compressed, without comments* | 1 KB | [Download](https://raw.github.com/Baggz/Edmond/master/dist/edmond.min.js) |\n\n<a name=\"tips\"></a>\n# Tips\n\n## HTML5 History\n\n1. First of all, we need to add a new event listener\n\n    ```javascript\n    window.addEventListener('popState', function() {\n      edmond.dispatchRoute(window.location.pathname);\n    });\n    ```\n\n2. Secondly, add a new event listener to the `dispatch` event\n\n    ```javascript\n    edmond.on('dispatch', function(path) {\n      history.pushState({}, null, path);\n    });\n    ```\n\n# Documentation\n\n**Methods**\n\n* [addRoute](#addRoute)\n* [dispatchRoute](#dispatchRoute)\n* [on](#on)\n\n**Objects**\n\n* [request](#request)\n\n<a name=\"addRoute\"></a>\n## AddRoute\n\n### addRoute(route, fn1[, fn2, fn3, ...])\n\nIn `route` you can use placeholders (*for instance `:username`*) which are then available as `request.params`.\n\nThe callback `fn` gets two arguments `request` and `next` where `request` is a `request` object (see [request](#request) for more information) and the second argument `next` allows you to move to the next callback (if defined).\n\n**Example**\n\n```javascript\nedmond.addRoute('/users/:username', function(request, next) {\n\n  alert('Hello ' + request.username + '!');\n\n});\n```\n\n<a name=\"dispatchRoute\"></a>\n## DispatchRoute\n\n### dispatchRoute(path)\n\n**Example**\n\n```javascript\nedmond.dispatchRoute('/users/123/delete');\n```\n\n<a name=\"on\"></a>\n## On\n\n### on(event, listener)\n\n**Events**\n\n* `error`\n* `dispatch`\n\n**Example**\n\n```javascript\nedmond.on('error', function(message) {\n\n  // Do something...\n\n});\n```\n\n<a name=\"request\"></a>\n## Request\n\n```javascript\n{\n  params: {\n    ...\n  },\n  query: {\n    ...\n  },\n  path: ...\n  hash: ...\n}\n```\n\n**Example**\n\n```javascript\n{\n  params: {\n    id: 123,\n    action: 'delete'\n  },\n  query: {\n    filter: 'recent'\n  },\n  path: '/users/123/delete?filter=recent#top'\n  hash: '#top',\n  route: '/users/:id/:action'\n}\n```\n\n# Running Tests\n\n```\n$ npm tests/\n```\n\n# License\n\n(The MIT License)\n\nCopyright (c) 2011 František Hába &lt;hello@frantisekhaba.com&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","maintainers":[{"name":"baggz","email":"hello@frantisekhaba.com"}],"time":{"modified":"2022-06-16T05:28:53.707Z","created":"2011-11-16T23:47:04.791Z","0.1.0":"2011-11-16T23:47:06.754Z"},"author":{"name":"František Hába","email":"hello@frantisekhaba.com"},"repository":{"type":"git","url":"git://github.com/Baggz/Edmond.git"}}