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
|
@@ -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
|
-
|
|
6
|
-
|
|
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
|
|