{"_id":"pathematics","_rev":"1745659","name":"pathematics","description":"Parse urls and with Express-like url segments","dist-tags":{"latest":"0.1.1"},"maintainers":[{"name":"scottcorgan","email":"scottcorgan@gmail.com"}],"time":{"modified":"2026-11-19T14:25:51.000Z","created":"2014-05-07T22:52:06.230Z","0.1.1":"2014-05-07T23:17:17.647Z","0.1.0":"2014-05-07T22:52:06.230Z"},"users":{},"author":{"name":"Scott Corgan"},"repository":{"type":"git","url":"https://github.com/scottcorgan/pathematics.git"},"versions":{"0.1.1":{"name":"pathematics","version":"0.1.1","description":"Parse urls and with Express-like url segments","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha test/"},"repository":{"type":"git","url":"https://github.com/scottcorgan/pathematics.git"},"keywords":["path","segements","url","wildcard","route"],"author":{"name":"Scott Corgan"},"license":"MIT","bugs":{"url":"https://github.com/scottcorgan/pathematics/issues"},"homepage":"https://github.com/scottcorgan/pathematics","dependencies":{"pathetic":"~0.3.1","reverend":"~0.2.0"},"devDependencies":{"mocha":"~1.18.2","chai":"~1.9.1"},"_id":"pathematics@0.1.1","_shasum":"0f35d306485d1c6bfd164e837c0fda6e06dd0ff9","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"scottcorgan","email":"scottcorgan@gmail.com"},"maintainers":[{"name":"scottcorgan","email":"scottcorgan@gmail.com"}],"dist":{"shasum":"0f35d306485d1c6bfd164e837c0fda6e06dd0ff9","tarball":"http://registry-npm.ywwl.com/pathematics/download/pathematics-0.1.1.tgz","integrity":"sha512-tneXi3TEFdscGAKIj9RV7zcdsWux1u7oNrnL0T1SwGWVXS1sqMvmJmVQDYIllaugIZogbQKzoVgv8wMeT5jjPA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCnXq63NePNV31n105XoFI/VBkxSC52aSoNDyyhVV0BUgIgUUIHQaRZWJKkWr3bioLp7t68PA5SM7Len4Rp5oSlTsc="}],"size":2291,"noattachment":false,"key":"/pathematics/-/pathematics-0.1.1.tgz"},"publish_time":1399504637647,"_cnpm_publish_time":1399504637647},"0.1.0":{"name":"pathematics","version":"0.1.0","description":"Parse urls and with Express-like url segments","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha test/"},"repository":{"type":"git","url":"https://github.com/scottcorgan/pathematics.git"},"keywords":["path","segements","url","wildcard","route"],"author":{"name":"Scott Corgan"},"license":"MIT","bugs":{"url":"https://github.com/scottcorgan/pathematics/issues"},"homepage":"https://github.com/scottcorgan/pathematics","dependencies":{"pathetic":"~0.3.1","reverend":"~0.2.0"},"devDependencies":{"mocha":"~1.18.2","chai":"~1.9.1"},"_id":"pathematics@0.1.0","_shasum":"0f618bdbdfd54030bcd402cc1323152fdba495fc","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"scottcorgan","email":"scottcorgan@gmail.com"},"maintainers":[{"name":"scottcorgan","email":"scottcorgan@gmail.com"}],"dist":{"shasum":"0f618bdbdfd54030bcd402cc1323152fdba495fc","tarball":"http://registry-npm.ywwl.com/pathematics/download/pathematics-0.1.0.tgz","integrity":"sha512-PYaxKkbwaJ0wBP5lLy54YIhaRHcM64A5nUJ/qbjyZ6mSC9zlck53GFHAFm/omRxU8mRefGLq84GhpbU5FeULhQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGLD95S5svAAL+8Sh2nuBEvv3GYJsok/20w6eUDFnnrbAiEAjwOCcD/Hr1/xAR8FN/Bg9/raZG55sV9Z82pIX8mWRrw="}],"size":2129,"noattachment":false,"key":"/pathematics/-/pathematics-0.1.0.tgz"},"publish_time":1399503126230,"_cnpm_publish_time":1399503126230}},"readme":"# pathematics\n\nParse urls and with Express-like url segments\n\n## Install\n\n```\nnpm install pathematics --save\n```\n\n## Usage\n\nEach segement in the source key of the map is injected into the destination value of the map. The map determins which key/value pair to use by comparing the url passed into the method with the map keys.\n\n```js\nvar pathematics = require('pathematics');\nvar routesMap = {\n  '/some/:segemented/route': '/new/route/:segmented'\n};\n\nvar url = pathematics(routesMap, '/some/custom/route');\n\nconsole.log(url); // OUTPUTS: /new/route/custom\n```\n\nYou can also partialize the function to reuse the object map\n\n```js\nvar pathematics = require('pathematics');\nvar routesMap = {\n  '/some/:segemented/route': '/new/route/:segmented'\n};\n\nvar paths = pathematics(routesMap);\nvar url = paths('/some/custom/route');\n\nconsole.log(url); // OUTPUTS: /new/route/custom\n```\n\nParseing route segements with custom meta data is also available. If the value if the key/value pair in the object map is an object, it expects the parameter of `url` to define the target path with segements.\n\n```js\nvar pathematics = require('pathematics');\nvar routesMap = {\n  '/some/:segemented/route': {\n    url: '/new/route/:segmented',\n    metaData: 'something'\n  }\n};\n\nvar data = pathematics.withMeta(routesMap, '/some/custom/route');\n\nconsole.log(data);\n\n/*\nOUTPUTS:\n\n{\n  url: '/new/route/custom',\n  meta: {\n    url: '/new/route/:segmented',\n    metaData: 'something'\n  }\n}\n*/\n```\n\n## API\n\n### pathematics(objectMap[, url]);\n\nGenerates the parsed url with segments if the url is provided or returns a parsing funciton if no url is provided initially.\n\n* `objectMap` - and object with key values pairs that define routes with segments to match against\n* `url` - the url to compare and parse with the `objectMap`\n\n### pathematics.withMeta(objectMap[, url]);\n\nAllows you to pass optional meta data around with route segements with the object map.\n\n## Run Tests\n\n```\nnpm install\nnpm test\n```","_attachments":{},"homepage":"https://github.com/scottcorgan/pathematics","bugs":{"url":"https://github.com/scottcorgan/pathematics/issues"},"license":"MIT"}