Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

feat: new IPLD Format API #39

Merged
merged 1 commit into from
May 8, 2019
Merged

feat: new IPLD Format API #39

merged 1 commit into from
May 8, 2019

Conversation

vmx
Copy link
Member

@vmx vmx commented Apr 21, 2019

BREAKING CHANGE: The API is now async/await based

There are numerous changes, the most significant one is that the API
is no longer callback based, but it using async/await.

For the full new API please see the IPLD Formats spec.

@vmx vmx requested a review from rvagg April 21, 2019 23:47
@ghost ghost assigned vmx Apr 21, 2019
@ghost ghost added the status/in-progress In progress label Apr 21, 2019
@codecov
Copy link

codecov bot commented Apr 24, 2019

Codecov Report

Merging #39 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #39   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      3           
  Lines          86     65   -21     
=====================================
- Hits           86     65   -21
Impacted Files Coverage Δ
src/util.js 100% <100%> (ø) ⬆️
src/index.js 100% <100%> (ø) ⬆️
src/resolver.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b7e3801...838bf6e. Read the comment docs.

const traverse = function * (node, path) {
// Traverse only objects and arrays
if (Buffer.isBuffer(node) || CID.isCID(node) || typeof node === 'string' ||
node === null) {
Copy link
Member

Choose a reason for hiding this comment

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

==

it('should return the version', (done) => {
verifyPath(fixtureBlockHeader, 'version', 4, done)
it('should return the version', async () => {
await verifyPath(fixtureBlockHeader, 'version', 4)
Copy link
Member

Choose a reason for hiding this comment

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

s/await/return

Copy link
Member

Choose a reason for hiding this comment

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

(IMO)

done()
})
const verifyError = async (block, path, error) => {
await expect(
Copy link
Member

Choose a reason for hiding this comment

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

this can be replaced with a return and probably even remove the async so it's just a simple Promise returning function

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll keep the async as I like to signal that it's returning a Promise. As it's in tests I don't mind the performance implications (in case there are any).

@rvagg
Copy link
Member

rvagg commented Apr 24, 2019

+264 −428 it's nice how much this has simplified the code

BREAKING CHANGE: The API is now async/await based

There are numerous changes, the most significant one is that the API
is no longer callback based, but it using async/await.

For the full new API please see the [IPLD Formats spec].

[IPLD Formats spec]: https://github.com/ipld/interface-ipld-format
@vmx vmx merged commit 68f3685 into master May 8, 2019
@ghost ghost removed the status/in-progress In progress label May 8, 2019
@vmx vmx deleted the ipld-format-cleanup branch May 8, 2019 12:40
@vmx vmx mentioned this pull request May 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants