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

feat: accept Uint8Arrays input in place of Buffers #88

Merged
merged 8 commits into from
Jul 30, 2020

Conversation

Gozala
Copy link
Contributor

@Gozala Gozala commented Jul 22, 2020

This pull request relaxes input type from Buffer to Uint8Array. It does however depends on multiformats/js-multibase#61

Copy link
Member

@vmx vmx left a comment

Choose a reason for hiding this comment

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

I've the same questions as @rvagg (thanks for bringing it up) multiformats/js-multibase#61 (comment):

Does the require('util') mean we need to include it in the dependencies list to make sure we have it available for webpack@5?

Could you please add a test that is using a Buffer as input, to make sure it still works?

Am I correct that this change depends on multiformats/js-multibase#61?

@Gozala
Copy link
Contributor Author

Gozala commented Jul 22, 2020

I've the same questions as @rvagg (thanks for bringing it up) multiformats/js-multibase#61 (comment):

I'm not sure what changes with webpack@5 but:

  1. It is only in tests
  2. It is only relevant for <=node@10 I think. So if we don't care testing in older versions of node, I can remove it.

Could you please add a test that is using a Buffer as input, to make sure it still works?

Ok, I'll do that

Am I correct that this change depends on multiformats/js-multibase#61?

Yep, as description said 🤓

@Gozala
Copy link
Contributor Author

Gozala commented Jul 22, 2020

  • Have test run with both Buffer and Uint8Array inputs.

    Could you please add a test that is using a Buffer as input, to make sure it still works?

  • Imported web-encodings library to deal with that

    Does the require('util') mean we need to include it in the dependencies list to make sure we have it available for webpack@5?

@Gozala Gozala requested a review from vmx July 22, 2020 23:16
@mikeal
Copy link

mikeal commented Jul 22, 2020

If it’s only in tests it’s probably fine, the primary concern is that bundlers are not injecting polyfills for Node.js anymore.

At some point we may even want it out of the tests, and we should all be getting in the habit of working without Node.js stdlib as much as possible, but it’s not a blocker.

We’ve cut Node.js v10 elsewhere but I’m not 100% sure what our dependencies have done that rely on this library.

@Gozala
Copy link
Contributor Author

Gozala commented Jul 23, 2020

If it’s only in tests it’s probably fine, the primary concern is that bundlers are not injecting polyfills for Node.js anymore.

At some point we may even want it out of the tests, and we should all be getting in the habit of working without Node.js stdlib as much as possible, but it’s not a blocker.

We’ve cut Node.js v10 elsewhere but I’m not 100% sure what our dependencies have done that rely on this library.

web-encoding should take care of providing TextEncoder / TextDecoder across the board. And it's tested on node v10 as well as 12 and 14

Copy link
Member

@vmx vmx left a comment

Choose a reason for hiding this comment

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

Overall looks good, but I think there is a superfluous file, see inline.

src/index.js Outdated Show resolved Hide resolved
src/index.js Show resolved Hide resolved
src/util.js Outdated Show resolved Hide resolved
test/index.spec.js Outdated Show resolved Hide resolved
test/index.spec.js Show resolved Hide resolved
@Gozala Gozala requested a review from vmx July 23, 2020 15:23
test/index.spec.js Outdated Show resolved Hide resolved
Copy link
Member

@vmx vmx left a comment

Choose a reason for hiding this comment

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

See previous inline comment.

@Gozala Gozala requested a review from vmx July 24, 2020 17:50
Copy link
Member

@vmx vmx left a comment

Choose a reason for hiding this comment

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

Approved, though I'd like CI to run and be green before it is merged.

@Gozala
Copy link
Contributor Author

Gozala commented Jul 25, 2020

Approved, though I'd like CI to run and be green before it is merged.

Once #89 lands, I can run CI tests.

@achingbrain
Copy link
Member

Once #89 lands, I can run CI tests.

This has landed now and the tests are all green, but for the future you could have used that branch as the merge base for this PR which would have let you run CI before it was merged.

@hugomrdias hugomrdias changed the title Accept Uint8Arrays input in place of Buffers feat: accept Uint8Arrays input in place of Buffers Jul 30, 2020
@hugomrdias hugomrdias merged commit 4bc2a05 into multiformats:master Jul 30, 2020
@Gozala Gozala deleted the uint8array branch July 30, 2020 21:46
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.

5 participants