pixel-data-js 0.37.0 → 0.38.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pixel-data-js",
3
3
  "type": "module",
4
- "version": "0.37.0",
4
+ "version": "0.38.0",
5
5
  "packageManager": "pnpm@10.33.0",
6
6
  "description": "JS Pixel and ImageData operations",
7
7
  "author": {
@@ -2,8 +2,11 @@ import type { Base64EncodedUInt8Array, ImageDataLike, SerializedImageData } from
2
2
 
3
3
  export function base64EncodeArrayBuffer(buffer: ArrayBufferLike): Base64EncodedUInt8Array {
4
4
  const uint8 = new Uint8Array(buffer)
5
- const decoder = new TextDecoder('latin1')
6
- const binary = decoder.decode(uint8)
5
+ let binary = ''
6
+
7
+ for (let i = 0; i < uint8.length; i++) {
8
+ binary += String.fromCharCode(uint8[i])
9
+ }
7
10
 
8
11
  return btoa(binary) as Base64EncodedUInt8Array
9
12
  }
@@ -11,9 +14,11 @@ export function base64EncodeArrayBuffer(buffer: ArrayBufferLike): Base64EncodedU
11
14
  export function base64DecodeArrayBuffer(encoded: Base64EncodedUInt8Array): Uint8ClampedArray<ArrayBuffer> {
12
15
  const binary = atob(encoded)
13
16
  const bytes = new Uint8ClampedArray(binary.length)
17
+
14
18
  for (let i = 0; i < binary.length; i++) {
15
19
  bytes[i] = binary.charCodeAt(i)
16
20
  }
21
+
17
22
  return bytes
18
23
  }
19
24