-
Notifications
You must be signed in to change notification settings - Fork 39
fix: replace node buffers with uint8arrays #117
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks the changes look good!
Would you mind updating the README to not use Buffer
, to indicate the Uint8Arrays are the way to go? I think using the global TextEncoder/Decoder
is fine in a README example.
The CI failure is real, though you could also use https://github.com/Gozala/web-encoding/ instead of ipfs-utils. |
I will if using Plus once ipfs/js-ipfs-utils#55 is merged I can remove some of the duplicated utility functions here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! I just would like to use this opportunity to rename .buffer
property:
- So it better reflects what it containts
- So that code expecting older CID breaks early rather than later.
- So we could in the future make CIDs
ArrayBufferView
s in which case we'd needbuffer
property to point to the underlyingArrayBuffer
instead.
README.md
Outdated
@@ -142,19 +158,19 @@ Property containing the CID version integer. | |||
|
|||
#### cid.multihash | |||
|
|||
Property containing the multihash buffer. | |||
Property containing the multihash `Uint8Array`. | |||
|
|||
#### cid.multibaseName | |||
|
|||
Property containing the default base to use when calling `.toString` | |||
|
|||
#### cid.buffer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should rename this property, so changes are more obvious and name isn't misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes me wince a little, because it's going to be very disruptive, but I've renamed it to .bytes
.
For what it's worth we have discussed option of using |
I've pulled out |
af9dea1
to
5c00d18
Compare
Relaxes input from requiring node `Buffer`s to being `Uint8Arrays`. This also means that the `.buffer` (now `.byte`) and `.prefix` properties have changed to be `Uint8Array`s. BREAKING CHANGES: - node `Buffer`s have been replaced with `Uint8Array`s - the `.buffer` property has been renamed to `.bytes` and is now a `Uint8Array` - the `.prefix` property is now a `Uint8Array`
5c00d18
to
cb0eba1
Compare
So, +1 in general, great to see this happening. One concern I have taking a breaking change is just wasting the opportunity to do a bit more. Knowing that we have a more substantial CID change coming in the future it would be great to get some code into this change that will make that transition a bit easier. For instance, we could add the Basically, we know that we need to move to using integers rather than strings for codec identifiers, it would be nice if we had a transitional release that accepted both so people could upgrade gradually or at least have the opportunity to do some of that migration when they migrate off of Buffer. |
Depends on: - [ ] multiformats/js-cid#117 BREAKING CHANGE: - `util.serialize` now returns a Uint8Array
I can see the temptation but I really think to deliver this change in a reasonable timeframe we should limit the scope to what's currently in this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm +1 on this but also +1 on Mikeal's ask, so see #118 for that piece of the puzzle which would be nice to slot in prior to a release of this if we can get agreement on that addition.
This module now accepts Uint8Arrays as well as node Buffers and returns Uint8Arrays. Internally it converts non-Buffers into Buffers because the ethereum libs require that. BREAKING CHANGES: - `util.serialize` returns a `Uint8Array` - `util.cid` returns `CID`s with a breaking API change - see multiformats/js-cid#117 for changes
returns Uint8Arrays. Internally it converts non-Buffers into Buffers because the ethereum libs require that. BREAKING CHANGES: - `util.serialize` returns a `Uint8Array` - `util.cid` returns `CID`s with a breaking API change - see multiformats/js-cid#117 for changes
This module now accepts Uint8Arrays as well as node Buffers and returns Uint8Arrays. Internally it converts non-Buffers into Buffers because the ethereum libs require that. BREAKING CHANGES: - `util.serialize` returns a `Uint8Array` - `util.cid` returns `CID`s with a breaking API change - see multiformats/js-cid#117 for changes
BREAKING CHANGES: - `util.cid` returns `CID`s with a breaking API change - see multiformats/js-cid#117 for changes
Removes use of node Buffer in favour of Uint8Arrays and updates all dependencies to versions that do the same. BREAKING CHANGES: - CIDs returned from `put*` methods have breaking API changes See see multiformats/js-cid#117 for changes
This module now accepts Uint8Arrays as well as node Buffers and returns Uint8Arrays. Internally it converts non-Buffers into Buffers because the ethereum libs require that. BREAKING CHANGES: - `util.serialize` returns a `Uint8Array` - `util.cid` returns `CID`s with a breaking API change - see multiformats/js-cid#117 for changes
BREAKING CHANGES: - `util.cid` returns `CID`s with a breaking API change - see multiformats/js-cid#117 for changes
Accepts and emits `Uint8Array`s instead of node `Buffer`s but converts them internally because `bitcoinjs-lib` only understands `Buffer`s. BREAKING CHANGE: - `util.serialize` returns `Uint8Array`s - `util.cid` returns `CID`s with a breaking API change - see multiformats/js-cid#117 for changes
This module now accepts Uint8Arrays as well as node Buffers and returns Uint8Arrays. Internally it converts non-Buffers into Buffers because the ethereum libs require that. BREAKING CHANGES: - `util.serialize` returns a `Uint8Array` - `util.cid` returns `CID`s with a breaking API change - see multiformats/js-cid#117 for changes
For what it's worth I would also like to slot in |
Removes use of node Buffer in favour of Uint8Arrays and updates all dependencies to versions that do the same. BREAKING CHANGES: - CIDs returned from `put*` methods have breaking API changes See see multiformats/js-cid#117 for changes
Follow up to #66 that removes node Buffers from the tests and uses version of protons that returns uint8arrays. BREAKING CHANGES: - All use of node Buffers have been replaced with Uint8Arrays - CIDs exported by this module have breaking API changes, see: multiformats/js-cid#117
Relaxes input from requiring node
Buffer
s to beingUint8Arrays
.This also means that the
.buffer
(now.byte
) and.prefix
properties have changed to beUint8Array
s.Depends on:
BREAKING CHANGES:
Buffer
s have been replaced withUint8Array
s.buffer
property has been renamed to.bytes
and is now aUint8Array
.prefix
property is now aUint8Array