{"name":"file-source","version":"0.1.1","description":"Read binary files.","keywords":["binary","file","reader","fs"],"homepage":"https://github.com/mbostock/file-source","license":"BSD-3-Clause","author":{"name":"Mike Bostock","url":"https://bost.ocks.org/mike"},"main":"index.js","repository":{"type":"git","url":"git+ssh://git@github.com/mbostock/file-source.git"},"scripts":{"test":"tape 'test/**/*-test.js'"},"devDependencies":{"tape":"4"},"gitHead":"4f11330e9794262b945eaaa10e66aebfe8bd15ff","bugs":{"url":"https://github.com/mbostock/file-source/issues"},"_id":"file-source@0.1.1","_shasum":"5407ca982e689ff4ea5bba9468a1d3aad5df2304","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.1","_npmUser":{"name":"mbostock","email":"mbostock@gmail.com"},"maintainers":[{"name":"mbostock","email":"mike@ocks.org"}],"dist":{"shasum":"5407ca982e689ff4ea5bba9468a1d3aad5df2304","tarball":"http://registry-npm.ywwl.com/file-source/download/file-source-0.1.1.tgz","integrity":"sha512-H6zR1z0xfOS7CHEKpW1+NxNQE916Sp/imVEYHrvSBG9q51IqIY8FLZ+1uYesQJAr0OR1qVt3Tab274fDPVTYEA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDycpmH0sLje5eA2NodwooQnwOxheTymt6E44ffsdJQvwIgb7IHPYp+0EBEEZbBi9iBbL0JIQhCzWsC+WFulfLlLwY="}],"size":7557,"noattachment":false,"key":"/file-source/-/file-source-0.1.1.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/file-source-0.1.1.tgz_1472754186752_0.6445263680070639"},"directories":{},"readme":"# file-source\n\nA [sliceable](https://github.com/mbostock/slice-source), [readable stream reader](https://streams.spec.whatwg.org/#readable-stream-reader) implementation on top of a Node [file read stream](https://nodejs.org/api/fs.html#fs_fs_createreadstream_path_options). This library allows you to write code that takes a *source* as input, and can work with either native readable streams or Node streams. For example:\n\n```js\nvar file = require(\"file-source\");\n\nfile(\"README.md\")\n  .then(function read(source) {\n    return source.slice(40).then(value => {\n      if (value == null) return;\n      process.stdout.write(value);\n      return read(source);\n    });\n  })\n  .catch(error => console.error(error.stack));\n```\n\n## API Reference\n\n<a name=\"file\" href=\"#file\">#</a> <b>file</b>(<i>path</i>[, <i>options</i>]) [<>](https://github.com/mbostock/file-source/blob/master/index.js \"Source\")\n\nReturns a Promise that yields a *source* for the file at the specified *path* when the underlying file is open. The following options are allowed:\n\n* `highWaterMark` - the stream’s internal buffer size; defaults to 65,536\n\n<a name=\"source_slice\" href=\"#source_slice\">#</a> <i>source</i>.<b>slice</b>(<i>length</i>) [<>](https://github.com/mbostock/stream-source/blob/master/slice.js \"Source\")\n\nReturns a Promise for the next chunk of data from the underlying stream, yielding a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) (a [Buffer](https://nodejs.org/api/buffer.html)) of *length* bytes, or the remaining bytes of the underlying stream if the underlying stream has more than zero but fewer than *length* bytes remaining, or null when no bytes remain in the stream.\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":1472754186989,"_cnpm_publish_time":1472754186989,"dist-tags":{"latest":"0.6.1"}}