{"name":"path-source","version":"0.0.1","description":"Read files in Node, or fetch URLs in browser, as standard WhatWG streams.","keywords":["fetch","stream","reader"],"homepage":"https://github.com/mbostock/path-source","license":"BSD-3-Clause","author":{"name":"Mike Bostock","url":"https://bost.ocks.org/mike"},"browser":"dist/path-source.js","main":"index.node.js","module":"index.js","repository":{"type":"git","url":"git+ssh://git@github.com/mbostock/path-source.git"},"scripts":{"prepublish":"rm -rf dist && mkdir dist && rollup --banner \"$(preamble)\" -f umd -g array-source:sources.array -n sources.path -o dist/path-source.js -- index.js && uglifyjs --preamble \"$(preamble)\" -o dist/path-source.min.js -cm -- dist/path-source.js","postpublish":"git push && git push --tags"},"devDependencies":{"package-preamble":"0.0","rollup":"0.34","uglify-js":"2"},"dependencies":{"array-source":"0.0","file-source":"0.5"},"gitHead":"ecfbbdab341710c0bbcdd13ee3ecc8e282ecdec5","bugs":{"url":"https://github.com/mbostock/path-source/issues"},"_id":"path-source@0.0.1","_shasum":"26dd2c164d7eaf2222fa81c132ab6c4195c1fc96","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.1","_npmUser":{"name":"mbostock","email":"mbostock@gmail.com"},"maintainers":[{"name":"mbostock","email":"mbostock@gmail.com"}],"dist":{"shasum":"26dd2c164d7eaf2222fa81c132ab6c4195c1fc96","tarball":"http://registry-npm.ywwl.com/path-source/download/path-source-0.0.1.tgz","integrity":"sha512-rcHSL6rKUCTjtVZy+9/i/YLloWEo5rcoV1ZuPmzqNCRfyuUPICNew1N6bN9zXqVIR6X869Oty33gc405sAe2bQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA5S5ZB/Sr+djOFOX3wgQnbj9Qg/AyKoWY57Llo683/bAiAlGeJ1Smn0+A/zxR6hmq4eA41sBeRu9q7GinO19wIArg=="}],"size":3816,"noattachment":false,"key":"/path-source/-/path-source-0.0.1.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/path-source-0.0.1.tgz_1473196482372_0.946271708002314"},"directories":{},"readme":"# path-source\n\nA [readable stream reader](https://streams.spec.whatwg.org/#readable-stream-reader) for reading files in Node or fetching URLs in browser. For example, to read a file in Node:\n\n```js\nvar path = require(\"path-source\");\n\npath(\"README.md\")\n  .then(function read(source) {\n    return source.read().then(result => {\n      if (result.done) return;\n      process.stdout.write(result.value);\n      return read(source);\n    });\n  })\n  .catch(error => console.error(error.stack));\n```\n\nSimilarly, to fetch a resource in a browser (requires [array-source](https://github.com/mbostock/array-source) if [streaming fetch](https://www.chromestatus.com/feature/5804334163951616) is not supported):\n\n```html\n<!DOCTYPE html>\n<script src=\"https://unpkg.com/array-source@0\"></script>\n<script src=\"https://unpkg.com/path-source@0\"></script>\n<script>\n\nsources.path(\"README.md\")\n  .then(function read(source) {\n    return source.read().then(result => {\n      if (result.done) return;\n      console.log(result.value);\n      return read(source);\n    });\n  })\n  .catch(error => console.error(error.stack));\n\n</script>\n```\n\n## API Reference\n\n<a name=\"path\" href=\"#path\">#</a> <b>path</b>(<i>path</i>[, <i>options</i>]) [<>](https://github.com/mbostock/path-source/blob/master/index.js \"Source\")\n\nIn Node, returns a Promise that yields a *source* for the file at the specified *path*; equivalent to [file-source](https://github.com/mbostock/file-source#file). In a browser, returns a Promise that yields a *source* for the resource at the specified *path* URL, using [streaming fetch](https://www.chromestatus.com/feature/5804334163951616) if available, and falling back to a [binary data](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data) [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest).\n\nIn Node, the following options are supported:\n\n* `highWaterMark` - the stream’s internal buffer size; defaults to 65,536\n\nIn a browser, no options are currently supported.\n\n<a name=\"source_read\" href=\"#source_read\">#</a> <i>source</i>.<b>read</b>() [<>](https://github.com/mbostock/stream-source/blob/master/read.js \"Source\")\n\nReturns a Promise for the next chunk of data from the underlying stream. The yielded result is an object with the following properties:\n\n* `value` - a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) (a [Buffer](https://nodejs.org/api/buffer.html)), or undefined if the stream ended\n* `done` - a boolean which is true if the stream ended\n\n<a name=\"source_cancel\" href=\"#source_cancel\">#</a> <i>source</i>.<b>cancel</b>() [<>](https://github.com/mbostock/slice-source/blob/master/cancel.js \"Source\")\n\nReturns a Promise which is resolved when the underlying stream has been destroyed.\n","publish_time":1473196482607,"_cnpm_publish_time":1473196482607,"dist-tags":{"latest":"0.1.3"}}