@shgysk8zer0/polyfills 0.3.12 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/array.js CHANGED
@@ -280,7 +280,10 @@ if (! (Array.isTemplateObject instanceof Function)) {
280
280
  */
281
281
  if (! (Uint8Array.prototype.toHex instanceof Function)) {
282
282
  Uint8Array.prototype.toHex = function toHex() {
283
- return Array.from(this).map(n => n.toString(16).padStart('0', 2)).join('');
283
+ return Array.from(
284
+ this,
285
+ n => n.toString(16).padStart('0', 2)
286
+ ).join('');
284
287
  };
285
288
  }
286
289
 
@@ -288,7 +291,16 @@ if (! (Uint8Array.prototype.toBase64 instanceof Function)) {
288
291
  Uint8Array.prototype.toBase64 = function toBase64({ alphabet = 'base64' } = {}) {
289
292
  if (alphabet === 'base64') {
290
293
  // @todo Figure out encoding specifics
291
- return btoa(String.fromCodePoint(...this));
294
+ //return btoa(String.fromCodePoint(...this));
295
+ const chunkSize = 0x8000; // 32,768 bytes per chunk
296
+ let str = '';
297
+
298
+ for (let i = 0; i < this.length; i += chunkSize) {
299
+ const chunk = this.subarray(i, i + chunkSize);
300
+ str += String.fromCharCode.apply(null, chunk);
301
+ }
302
+
303
+ return btoa(str);
292
304
  // return btoa(new TextDecoder().decode(this));
293
305
  } else if (alphabet === 'base64url') {
294
306
  return this.toBase64({ alphabet: 'base64' }).replaceAll('+', '-').replaceAll('/', '_');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgysk8zer0/polyfills",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "A collection of JavaScript polyfills",