refactor: add cross-environment decodeBase64 method#95
refactor: add cross-environment decodeBase64 method#95Phillip9587 wants to merge 2 commits intojshttp:masterfrom
Conversation
bee8698 to
e2854e0
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #95 +/- ##
============================================
- Coverage 100.00% 76.74% -23.26%
============================================
Files 1 1
Lines 30 43 +13
Branches 11 13 +2
============================================
+ Hits 30 33 +3
- Misses 0 10 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Will need rebasing too, but would you be able to add a benchmarks folder with the different ways to decode for posterity? That way we can quickly re-run benchmarks anytime and confirm we've got the right methods selected. |
e2854e0 to
fc15aff
Compare
|
@blakeembrey I added the benchmarks and switched the |
6cae752 to
2b6d3e0
Compare
|
@blakeembrey Any suggestions on how to fix the test coverage? |
|
We seem to be doing this in a few packages now, wdyt about a new package for base64? Or can we benchmark some existing ones too? |
|
Which other packages need base64? |
2b6d3e0 to
304497e
Compare
|
I think I've misremembered, I thought we were doing it another package but I don't see anything. As for improving coverage, how about a |
|
If you do add a separate file, we could also have it be import specific for browsers vs node vs other, instead of relying on a runtime check it'd rely on the bundler using the correct file. |
Based on #93
This PR decouples the package from Node.js APIs and adds support for browser and other runtimes. Base64 decoding now uses runtime feature detection:
Uint8Array.fromBase64()when available (modern browsers/runtimes)Buffer.from(..., 'base64')in Node.js and compatible runtimesatob()andTextDecoderas a fallback