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

Commit 06668d2

Browse files
committed
docs: switch to returning streams instead of callbacks
1 parent b8904f1 commit 06668d2

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

SPEC/FILES.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* [files.stat](#filesmkdir)
2020
* [files.rm](#filesrm)
2121
* [files.read](#filesread)
22+
* [files.readReadableStream](#filesreadreadablestream)
23+
* [files.readPullStream](#filesreadpullstream)
2224
* [files.write](#fileswrite)
2325
* [files.mv](#filesmv)
2426
* [files.flush](#filesflush)
@@ -761,7 +763,7 @@ ipfs.files.read('/hello-world', (err, buf) => {
761763
762764
##### `Go` **WIP**
763765

764-
##### `JavaScript` - ipfs.files.readReadableStream(path, [options], [callback])
766+
##### `JavaScript` - ipfs.files.readReadableStream(path, [options])
765767

766768
Where:
767769

@@ -770,16 +772,13 @@ Where:
770772
- `offset` is an Integer with the byte offset to begin reading from.
771773
- `count` is an Integer with the maximum number of bytes to read.
772774

773-
`callback` must follow the `function (err, stream) {}` signature, where `err` is an Error if the operation was not successful and `stream` is a [`ReadableStream`][rs] with the contents of `path`.
774-
775-
If no `callback` is passed, a promise is returned.
775+
Returns a [`ReadableStream`][rs] with the contents of `path`.
776776

777777
**Example:**
778778

779779
```JavaScript
780-
ipfs.files.readReadableStream('/hello-world', (err, stream) => {
781-
stream.on('data', (buf) => console.log(buf.toString('utf8')))
782-
})
780+
const stream = ipfs.files.readReadableStream('/hello-world')
781+
stream.on('data', (buf) => console.log(buf.toString('utf8')))
783782

784783
// Hello, World!
785784
```
@@ -790,7 +789,7 @@ ipfs.files.readReadableStream('/hello-world', (err, stream) => {
790789
791790
##### `Go` **WIP**
792791

793-
##### `JavaScript` - ipfs.files.readPullStream(path, [options], [callback])
792+
##### `JavaScript` - ipfs.files.readPullStream(path, [options])
794793

795794
Where:
796795

@@ -799,20 +798,16 @@ Where:
799798
- `offset` is an Integer with the byte offset to begin reading from.
800799
- `count` is an Integer with the maximum number of bytes to read.
801800

802-
`callback` must follow the `function (err, stream) {}` signature, where `err` is an Error if the operation was not successful and `stream` is a [`PullStream`][ps] with the contents of `path`.
803-
804-
If no `callback` is passed, a promise is returned.
801+
Returns a [`PullStream`][ps] with the contents of `path`.
805802

806803
**Example:**
807804

808805
```JavaScript
809-
ipfs.files.readPullStream('/hello-world', (err, stream) => {
810-
pull(
811-
stream,
812-
through(buf => console.log(buf.toString('utf8'))),
813-
collect(err => {})
814-
)
815-
})
806+
pull(
807+
ipfs.files.readPullStream('/hello-world'),
808+
through(buf => console.log(buf.toString('utf8'))),
809+
collect(err => {})
810+
)
816811

817812
// Hello, World!
818813
```

0 commit comments

Comments
 (0)