{"name":"file-source","version":"0.6.0","description":"Read binary files in chunks, on demand, with promises.","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'","postpublish":"git push && git push --tags"},"dependencies":{"stream-source":"0.3"},"devDependencies":{"tape":"4"},"gitHead":"fda76bc5e044810f4ef3d6c51cb5d5922fd1ab36","bugs":{"url":"https://github.com/mbostock/file-source/issues"},"_id":"file-source@0.6.0","_shasum":"90a5634f08bbb116b32c962d0ff908a67da4c7ab","_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":"90a5634f08bbb116b32c962d0ff908a67da4c7ab","tarball":"http://registry-npm.ywwl.com/file-source/download/file-source-0.6.0.tgz","integrity":"sha512-OsDO2gBuuOPFo9LENhGYPfw/jZSUdr7539lMkraiHFsSZ2CoZ9/VysGDGXC2adPj6HgrEwJggs5TL5KsLoSCgg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDcmNnZoRbKuvOgDDCd5BZ0SYUx99AuhISUWHVvusADeAIgHyQeNvVpyPqL/Zp4Qle2Pi64ITTqGAr/gEKK0xMzgmo="}],"size":2392,"noattachment":false,"key":"/file-source/-/file-source-0.6.0.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/file-source-0.6.0.tgz_1473268540798_0.08217929978854954"},"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":1473268542993,"_cnpm_publish_time":1473268542993,"dist-tags":{"latest":"0.6.1"}}