Add Blob.arrayBuffer and Blob.text methods #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I needed Blob.arrayBuffer and Blob.text for an updated version of a CloudFlare Worker tool (forked from dollarshaveclub/cloudworker)I'm working on. The arrayBuffer is required to do Brotli de/compression (and other forms of compression) within a cloud worker.
Most of the required code already existed within the existing
Blob.slice
method. I abstracted it into its own function, calling it from within the slice method.I ran unit tests before and after. An
npm install
flat out fails without updating the chai dependencies. I updated these. Prior to creating any updates, I ran the tests and there were a few errors for code unrelated to the Blob class. Upon completion, I ran the tests again and got the same result, suggesting anything Blob related passed without error.I tried updating all of the dependencies, but Babel has changed enough that it caused the build to change (particularly the default fetch export). Those changes have obviously not been included in this PR, but I wanted there to be an awareness of them.
I've created a new npm package with these changes for my own purposes (@author.io/node-fetch), which is working well. So, if you choose not to merge this, other folks will know a place where they can still obtain these particular features.