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

feat: expose codec code and allow construction by code #118

Merged
merged 1 commit into from
Aug 4, 2020

Conversation

rvagg
Copy link
Member

@rvagg rvagg commented Aug 4, 2020

(this PR assumes #117, review should focus only on the HEAD commit please, c043bc5)

Ref: #117 (comment)

The idea here is that js-multiformats is going to require a switch to using the multicodec integer code rather than string, which does away with the need to bundle the entire multicodec table (and if you want string and you're happy to have the table then that's fine but you get to choose that). Experience shows that this is the most painful compatibility problem when switching between this library and multiformats.CID (and vice versa). Having a constructor that can take (optionally) an integer code rather than a string makes it the same constructor as multiformats.CID and exposing the code property makes it the same interface. So we can write new code that works against CID and multiformats.CID without having to worry too much. The asCID() will be icing on the cake too.

As long as we're getting an awkward breaking change into the code, we may as well make sure that anyone who has that code also has this and there's not an in-between state where there's breaking code and then there's this feature out there and you may have one and not the other. Basically it'd be nice to have this out in the wild ASAP to ease future transition and the current breaking change release seems like a good mechanism to force that.

@rvagg rvagg requested review from achingbrain, Gozala, vmx and mikeal August 4, 2020 02:15
@rvagg
Copy link
Member Author

rvagg commented Aug 4, 2020

@Gozala would appreciate some focused eyes on my flow and TS changes, I think you might have more of a clue than me on both of those

Copy link
Member

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

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

LGTM

src/index.js.flow Outdated Show resolved Hide resolved
@rvagg rvagg force-pushed the rvagg/codec-code branch from bcae555 to 845b2df Compare August 4, 2020 11:53
@rvagg
Copy link
Member Author

rvagg commented Aug 4, 2020

squashed and rebased to master

@vmx vmx merged commit 59469b6 into master Aug 4, 2020
@vmx vmx deleted the rvagg/codec-code branch August 4, 2020 12:06
Copy link
Contributor

@Gozala Gozala left a comment

Choose a reason for hiding this comment

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

I see it is merged already, but I looked at types as requested an they all look good to me.

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.

4 participants