Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
feat: Add offset/length arguments to files.cat
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored and daviddias committed Apr 24, 2018
1 parent 1f889d3 commit 17967c1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/files/cat-pull-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ module.exports = (send) => {
}
}

send({ path: 'cat', args: hash, buffer: opts.buffer }, (err, stream) => {
const query = {
offset: opts.offset,
length: opts.length
}

send({ path: 'cat', args: hash, buffer: opts.buffer, qs: query }, (err, stream) => {
if (err) { return p.end(err) }

p.resolve(toPull(stream))
Expand Down
7 changes: 6 additions & 1 deletion src/files/cat-readable-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ module.exports = (send) => {
}
}

send({ path: 'cat', args: hash, buffer: opts.buffer }, (err, stream) => {
const query = {
offset: opts.offset,
length: opts.length
}

send({ path: 'cat', args: hash, buffer: opts.buffer, qs: query }, (err, stream) => {
if (err) { return pt.destroy(err) }

pump(stream, pt)
Expand Down
7 changes: 6 additions & 1 deletion src/files/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ module.exports = (send) => {
}
}

send({ path: 'cat', args: hash, buffer: opts.buffer }, (err, stream) => {
const query = {
offset: opts.offset,
length: opts.length
}

send({ path: 'cat', args: hash, buffer: opts.buffer, qs: query }, (err, stream) => {
if (err) { return callback(err) }

stream.pipe(bl((err, data) => {
Expand Down

0 comments on commit 17967c1

Please sign in to comment.