{"name":"xhr-write-stream","version":"0.1.2","description":"writable ordered stream of xhr requests","main":"index.js","browserify":"browser.js","directories":{"example":"example","test":"test"},"dependencies":{"ordered-emitter":"~0.1.0","concat-stream":"~0.1.0"},"repository":{"type":"git","url":"git://github.com/substack/xhr-write-stream.git"},"homepage":"https://github.com/substack/xhr-write-stream","keywords":["xhr","http","browser","ajax"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"license":"MIT","readme":"# xhr-write-stream\n\nWrite data in the browser and receive a properly ordered stream in node from\nmultiple incoming requests.\n\nThis module only goes one way, from the browser to node. Use libraries like\n[shoe](http://github.com/substack/shoe) to create full duplex streams between\nthe browser and node.\n\n# example\n\nbrowser code:\n\n``` js\nvar xws = require('xhr-write-stream');\n\nvar ws = xws('/robots');\nws.write('beep boop');\nws.write('!!!');\nws.end();\n```\n\nserver code:\n\n``` js\nvar http = require('http');\nvar ecstatic = require('ecstatic')(__dirname + '/static');\nvar xws = require('xhr-write-stream')();\n\nvar server = http.createServer(function (req, res) {\n    if (req.url === '/robots') {\n        req.pipe(xws(function (stream) {\n            stream.pipe(process.stdout, { end : false });\n        }));\n        req.on('end', res.end.bind(res));\n    }\n    else ecstatic(req, res)\n});\nserver.listen(5000);\n```\n\nbundle up the browser code with\n[browserify](https://github.com/substack/node-browserify):\n\n```\n$ browserify browser.js -o static/bundle.js\n```\n\nthen toss down a script tag for the bundle:\n\n``` html\n<script src=\"bundle.js\"></script>\n```\n\nRun the server and visit the page in the browser:\n\n```\n$ node server.js\nbeep boop!!!\n```\n\n# browser methods\n\n``` js\nvar xws = require('xhr-write-stream')\n```\n\n## var ws = xws(path)\n\nReturn a writable stream that sends an xhr request to `path` on every `write()`.\n\nThe xhr requests are turned back into a single readable stream on the server\nside.\n\n# server methods\n\n``` js\nvar createXWS = require('xhr-write-stream')\n```\n\n## var xws = createXWS(opts={})\n\nCreate a new `xws` stream pool.\n\n`opts.timeout` is the time in milliseconds to wait for connection activity\nbefore dropping the connection and removing the stream. Default value: 60*1000\n\n## var ws = xws(cb)\n\nReturn a writable stream `ws` that you can pipe request data into from multiple\nincoming xhr requests on the browser-side.\n\n`cb(stream)` is called with a readable `stream` that aggregates data in order\nwith the data from each xhr request.\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install xhr-write-stream\n```\n\nThis module makes use of\n[http-browserify](https://github.com/substack/http-browserify)\nfor the xhr-compatibility. If you just `require('xhr-write-stream')` in your\nbrowser code using [browserify](https://github.com/substack/node-browserify),\neverything will just work™.\n\n# license\n\nMIT\n","_id":"xhr-write-stream@0.1.2","dist":{"shasum":"e357848e0d039b411fdd5b3bf81be47ee5ce26aa","tarball":"http://registry-npm.ywwl.com/xhr-write-stream/download/xhr-write-stream-0.1.2.tgz","integrity":"sha512-KLYqF/tkuGjHovIX5GjPPas+Ij1xxnIJG3v4Z73hQhKErm5rOqZSLV0lYxigPueDCOogf9jbey5WXrkPtr8gLQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDLq5mqtFPZIFUjCuoiH5dbn9ORXwfFbhB3HE8IGaptiAiEAoA3p94+A6XBMY6h5EKoiwy+xIq2vBxocd5WA9/5f2sY="}],"size":3390,"noattachment":false,"key":"/xhr-write-stream/-/xhr-write-stream-0.1.2.tgz"},"_npmVersion":"1.1.59","_npmUser":{"name":"substack","email":"mail@substack.net"},"maintainers":[{"name":"substack","email":"mail@substack.net"}],"publish_time":1353980557222,"_cnpm_publish_time":1353980557222,"dist-tags":{"latest":"0.1.2"}}