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 8
8
- No dependency
9
9
- Accepts base64url and replace non-url compatible chars with base64 standard chars
10
10
- Adds missing padding to base64 string
11
+ - Works even on large data
11
12
- Uses modern functions and shorter solutions
12
13
- Supports ES modules, AMD, CommonJS and IIFE
13
14
@@ -79,13 +80,6 @@ async function subscribeUserToPush(registration) {
79
80
}
80
81
```
81
82
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
-
89
83
## Tests
90
84
91
85
There are no tests for the moment.
Original file line number Diff line number Diff line change @@ -40,7 +40,10 @@ const base64ToUint8Array = base64String => {
40
40
}
41
41
42
42
const 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 )
44
47
}
45
48
46
49
const uint8ArrayToBase64 = typedArrayToBase64
You can’t perform that action at this time.
0 commit comments