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

Commit 2c643d7

Browse files
author
Alan Shaw
committed
docs: update ping API docs
1 parent 0498390 commit 2c643d7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

SPEC/MISCELLANEOUS.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ Where:
111111

112112
| Type | Description |
113113
| -------- | -------- |
114-
| `Promise<Array>` | An array of ping response objects |
114+
| `AsyncIterable<Object>` | An async iterable that yields ping response objects |
115115

116-
an array of objects is returned, each of the form:
116+
Each yielded object is of the form:
117117

118118
```js
119119
{
@@ -128,14 +128,13 @@ Note that not all ping response objects are "pongs". A "pong" message can be ide
128128
**Example:**
129129

130130
```JavaScript
131-
const responses = await ipfs.ping('Qmhash')
132-
responses.forEach((res) => {
131+
for await (const res of ipfs.ping('Qmhash')) {
133132
if (res.time) {
134133
console.log(`Pong received: time=${res.time} ms`)
135134
} else {
136135
console.log(res.text)
137136
}
138-
})
137+
}
139138
```
140139

141140
A great source of [examples](https://github.com/ipfs/interface-ipfs-core/tree/master/src/ping) can be found in the tests for this API.

0 commit comments

Comments
 (0)