{"_id":"path-proxy","_rev":"244635","name":"path-proxy","description":"A path proxy object constructor","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"jclem","email":"jonathan@jclem.net"}],"time":{"modified":"2021-06-03T16:02:04.000Z","created":"2013-12-12T09:58:04.939Z","1.0.0":"2014-01-09T02:56:51.144Z","0.1.1":"2013-12-13T19:50:11.964Z","0.1.0":"2013-12-12T10:24:12.099Z","0.0.0":"2013-12-12T09:58:04.939Z"},"users":{"zeke":true},"author":{"name":"Jonathan Clem"},"repository":{"type":"git","url":"https://github.com/jclem/path-proxy"},"versions":{"1.0.0":{"name":"path-proxy","version":"1.0.0","description":"A path proxy object constructor","main":"index.js","scripts":{"test":"./node_modules/jasmine-node/bin/jasmine-node spec"},"repository":{"type":"git","url":"https://github.com/jclem/path-proxy"},"keywords":["node","proxy"],"author":{"name":"Jonathan Clem"},"license":"MIT","bugs":{"url":"https://github.com/jclem/path-proxy/issues"},"dependencies":{"inflection":"~1.3.0"},"devDependencies":{"jasmine-node":"~1.11.0"},"readmeFilename":"README.md","homepage":"https://github.com/jclem/path-proxy","_id":"path-proxy@1.0.0","dist":{"shasum":"18e8a36859fc9d2f1a53b48dee138543c020de5e","size":2685,"noattachment":false,"key":"/path-proxy/-/path-proxy-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/path-proxy/download/path-proxy-1.0.0.tgz"},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"jclem","email":"jonathan@jclem.net"},"maintainers":[{"name":"jclem","email":"jonathan@jclem.net"}],"directories":{},"publish_time":1389236211144,"_cnpm_publish_time":1389236211144,"_hasShrinkwrap":false},"0.1.1":{"name":"path-proxy","version":"0.1.1","description":"A path proxy object constructor","main":"index.js","scripts":{"test":"./node_modules/jasmine-node/bin/jasmine-node spec"},"repository":{"type":"git","url":"https://github.com/jclem/path-proxy"},"keywords":["node","proxy"],"author":{"name":"Jonathan Clem"},"license":"MIT","bugs":{"url":"https://github.com/jclem/path-proxy/issues"},"dependencies":{"inflection":"~1.3.0"},"devDependencies":{"jasmine-node":"~1.11.0"},"readmeFilename":"README.md","_id":"path-proxy@0.1.1","dist":{"shasum":"2651abb488cd2f127897b66e5aa75ebc69bf0d3d","size":2645,"noattachment":false,"key":"/path-proxy/-/path-proxy-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/path-proxy/download/path-proxy-0.1.1.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"jclem","email":"jonathan@jclem.net"},"maintainers":[{"name":"jclem","email":"jonathan@jclem.net"}],"directories":{},"publish_time":1386964211964,"_cnpm_publish_time":1386964211964,"_hasShrinkwrap":false},"0.1.0":{"name":"path-proxy","version":"0.1.0","description":"A path proxy object constructor","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/jclem/path-proxy"},"keywords":["node","proxy"],"author":{"name":"Jonathan Clem"},"license":"MIT","bugs":{"url":"https://github.com/jclem/path-proxy/issues"},"dependencies":{"inflection":"~1.3.0"},"readmeFilename":"README.md","_id":"path-proxy@0.1.0","dist":{"shasum":"2d2a1646865859128937e35bb4fcc704fc09d1cd","size":2252,"noattachment":false,"key":"/path-proxy/-/path-proxy-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/path-proxy/download/path-proxy-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"jclem","email":"jonathan@jclem.net"},"maintainers":[{"name":"jclem","email":"jonathan@jclem.net"}],"directories":{},"publish_time":1386843852099,"_cnpm_publish_time":1386843852099,"_hasShrinkwrap":false},"0.0.0":{"name":"path-proxy","version":"0.0.0","description":"A path proxy object constructor","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/jclem/path-proxy"},"keywords":["node","proxy"],"author":{"name":"Jonathan Clem"},"license":"MIT","bugs":{"url":"https://github.com/jclem/path-proxy/issues"},"dependencies":{"inflection":"~1.3.0"},"readmeFilename":"README.md","_id":"path-proxy@0.0.0","dist":{"shasum":"a367f935d635f907cb6f4f844252b0a4609b4d9f","size":2009,"noattachment":false,"key":"/path-proxy/-/path-proxy-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/path-proxy/download/path-proxy-0.0.0.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"jclem","email":"jonathan@jclem.net"},"maintainers":[{"name":"jclem","email":"jonathan@jclem.net"}],"directories":{},"publish_time":1386842284939,"_cnpm_publish_time":1386842284939,"_hasShrinkwrap":false}},"readme":"# path-proxy\n\nGiven an group of paths (say, from an API schema), you might need to create a\nset of proxy objects for interacting with those paths. This is the situation I\nfound myself in while working on the [Node client for the Heroku API][heroku_client].\n\nGiven a set of paths and a base constructor function, path-proxy will create a\nnetwork of logical proxy objects based on the paths and attach it to the\nconstructor's prototype.\n\n## Install\n\n```sh\nnpm install path-proxy --save\n```\n\n## Usage\n\n```javascript\nvar pathProxy = require('path-proxy');\n\nfunction ApiClient() {}\n\npathProxy.proxy(ApiClient, [\n  \"/foo\",\n  \"/foo/{id}/bar\"\n]);\n\nvar client = new ApiClient();\nclient.foo(\"qux\").bar();\n```\n\nThis may not appear all that useful—they're mostly just empty functions—until you\nstart mucking around with their prototypes:\n\n```javascript\nvar BarProxy = pathProxy.pathProxy(ApiClient, \"/foo/{id}/bar\");\nBarProxy.prototype.sayHello = function () {\n  console.log(\"hello\");\n};\n\nclient.foo(\"qux\").bar().sayHello(); // Logs \"hello\".\n```\n\nThey also have access to a few useful attributes:\n\n```javascript\nvar baz = client.foo(\"qux\").bar(\"baz\");\nbaz.params;       // [\"qux\", \"baz\"]\nbaz.pathSegments; // [\"foo\", \"qux\", \"bar\", \"baz\"]\nbaz.path;         // \"/foo/qux/bar/baz\"\n```\n\nAnd can access the instance of the base constructor they're based off of:\n\n```javascript\nApiClient.prototype.delete = function (path, callback) {\n  var message = this.name + \" deleted at \" + path;\n  callback(message);\n};\n\nvar client = new ApiClient();\nclient.name = \"Jonathan\";\n\nBarProxy.prototype.delete = function (callback) {\n  this.base.delete(this.path, callback);\n};\n\n// This:\nclient.foo(\"qux\").bar(\"baz\").delete(function (message) {\n  // message == \"Jonathan deleted at /foo/qux/bar/baz\"\n});\n\n// Is equivalent to this:\nclient.delete(\"/foo/qux/bar/baz\", function (message) {\n  // message == \"Jonathan deleted at /foo/qux/bar/baz\"\n});\n```\n\n## Tests\n\npath-proxy uses jasmine-node for tests. To run them:\n\n```sh\n$ npm install\n$ npm test\n```\n\n[heroku_client]: https://github.com/heroku/node-heroku-client\n","_attachments":{},"readmeFilename":"README.md","homepage":"https://github.com/jclem/path-proxy","bugs":{"url":"https://github.com/jclem/path-proxy/issues"},"license":"MIT"}