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

refactor: convert bitswap tests to use async/await #391

Closed

Conversation

alanshaw
Copy link
Contributor

NOTE: the PRs for ipfs/js-ipfs#1670 are being merged into the feat/async-iterators branch. Once they're all in we can merge them into master.


This simply refactors the bitswap tests to use async/await and updates the documentation to remove callback support and propose a better method for documenting the parameters and return values.

depends on #390

NOTE: the PRs for ipfs/js-ipfs#1670 are being merged into the `feat/async-iterators` branch. Once they're all in we can merge them into master.

---

This simply refactors the bitswap tests to use async/await and updates the documentation to remove callback support and propose a better method for documenting the parameters and return values.

depends on #390

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
**Example:**
| Type | Description |
|------|-------------|
| `Promise<{`<br/>&nbsp;&nbsp;`Keys<Array<Object>>`<br/>`}>` | The list of CIDs wanted by the peer. Each object in the array has a single property "/" a string CID. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems weird, html inside inline code block just to add new lines and space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know 😢. I would like this to be clearer when viewed as markdown but I don't know how right now. Unfortunately multi-line code blocks in a table aren't possible. If you have any ideas for how to format this in markdown so that it reads clearly when rendered then please comment!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've recently also started to use tables for parameters (for js-ipld). But I'll move away from that again. I find tables hard to read if you just read the unrendered Markdown.

The signature is quite complicated, I actually missed that it is an object containing a single field called Keys. I found that clearer in the old docs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've recently also started to use tables for parameters (for js-ipld). But I'll move away from that again. I find tables hard to read if you just read the unrendered Markdown.

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will think up a better way to layout this information that is readable rendered or not.


// { Keys: [{ '/': 'QmHash' }] }
```js
const list = await ipfs.bitswap.wantlist()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this return an iterator instead of a list?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in general we should either return single values or iterators of single values, never lists of single values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, the wantlist could get really big so an iterator makes sense.

never lists of single values

Do you think this should always be true? I think we should return async iterators where it makes sense to "stream" the output but I wouldn't have thought it would be necessary for something like ipfs.bootstrap.list, for example...but could be persuaded for the sake of consistency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we talking iterable ? or really async iterator ?

@momack2 momack2 added this to In Progress in ipfs/js-ipfs May 10, 2019
@momack2 momack2 added this to In Progress in ipfs/js-waffle May 10, 2019
@alanshaw alanshaw closed this Nov 19, 2019
@alanshaw
Copy link
Contributor Author

superseded by #547

@alanshaw alanshaw deleted the refactor/async-iterators-bitswap branch November 19, 2019 17:39
@hsanjuan hsanjuan removed this from In Progress in ipfs/js-ipfs Apr 27, 2020
@hsanjuan hsanjuan removed this from In Progress in ipfs/js-waffle Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants