From 7fd182e1b227f5ec11011ab246239ccd699248dd Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 21 Mar 2018 18:11:41 +0000 Subject: [PATCH] doc: Documents the begin/end arguments to ipfs.files.cat and friends --- SPEC/FILES.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/SPEC/FILES.md b/SPEC/FILES.md index f63f9c8d..1c7dea36 100644 --- a/SPEC/FILES.md +++ b/SPEC/FILES.md @@ -161,9 +161,9 @@ pull( ##### `Go` **WIP** -##### `JavaScript` - ipfs.files.cat(ipfsPath, [callback]) +##### `JavaScript` - ipfs.files.cat(ipfsPath, [options], [callback]) -ipfsPath can be of type: +`ipfsPath` can be of type: - [`cid`][cid] of type: - [Buffer][b], the raw Buffer of the cid @@ -173,6 +173,10 @@ ipfsPath can be of type: - '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt' - 'QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt' +`options` is an optional object that may contain the following keys: + - `offset` is an optional byte offset to start the stream at + - `count` is an optional number of bytes to read from the stream + `callback` must follow `function (err, file) {}` signature, where `err` is an error if the operation was not successful and `file` is a [Buffer][b] If no `callback` is passed, a promise is returned. @@ -197,9 +201,9 @@ A great source of [examples][] can be found in the tests for this API. ##### `Go` **WIP** -##### `JavaScript` - ipfs.files.catReadableStream(ipfsPath) -> [Readable Stream][rs] +##### `JavaScript` - ipfs.files.catReadableStream(ipfsPath, [options]) -> [Readable Stream][rs] -ipfsPath can be of type: +`ipfsPath` can be of type: - [`cid`][cid] of type: - [Buffer][b], the raw Buffer of the cid @@ -209,6 +213,10 @@ ipfsPath can be of type: - '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt' - 'QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt' +`options` is an optional object that may contain the following keys: + - `offset` is an optional byte offset to start the stream at + - `count` is an optional number of bytes to read from the stream + Returns a [Readable Stream][rs] with the contents of the file. @@ -225,9 +233,9 @@ A great source of [examples][] can be found in the tests for this API. ##### `Go` **WIP** -##### `JavaScript` - ipfs.files.catPullStream(ipfsPath) -> [Pull Stream][rs] +##### `JavaScript` - ipfs.files.catPullStream(ipfsPath, [options]) -> [Pull Stream][rs] -ipfsPath can be of type: +`ipfsPath` can be of type: - [`cid`][cid] of type: - [Buffer][b], the raw Buffer of the cid @@ -237,6 +245,10 @@ ipfsPath can be of type: - '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt' - 'QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt' +`options` is an optional object that may contain the following keys: + - `offset` is an optional byte offset to start the stream at + - `count` is an optional number of bytes to read from the stream + Returns a [Pull Stream][ps] with the contents of the file. ```JavaScript