File tree Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Original file line number Diff line number Diff line change 88- No dependency
99- Accepts base64url and replace non-url compatible chars with base64 standard chars
1010- Adds missing padding to base64 string
11+ - Works even on large data
1112- Uses modern functions and shorter solutions
1213- Supports ES modules, AMD, CommonJS and IIFE
1314
@@ -79,13 +80,6 @@ async function subscribeUserToPush(registration) {
7980}
8081```
8182
82- ## Known issues
83-
84- ``` txt
85- RangeError: Maximum call stack size exceeded
86- ```
87- This error occurs when using too large data (more than 30 kb) to encode a base64 string (e.g. ` uint8ArrayToBase64() ` and ` arrayBufferToBase64() ` ).
88-
8983## Tests
9084
9185There are no tests for the moment.
Original file line number Diff line number Diff line change @@ -40,7 +40,10 @@ const base64ToUint8Array = base64String => {
4040}
4141
4242const typedArrayToBase64 = typedArray => {
43- return base64Encode ( String . fromCharCode ( ...typedArray ) )
43+ const string = typedArray . reduce ( ( data , byte ) => {
44+ return data + String . fromCharCode ( byte )
45+ } , '' )
46+ return base64Encode ( string )
4447}
4548
4649const uint8ArrayToBase64 = typedArrayToBase64
You can’t perform that action at this time.
0 commit comments