use buffer first, add changelog
This commit is contained in:
parent
e66b3c8c5c
commit
ca664cb1a0
2 changed files with 7 additions and 6 deletions
1
changelogs/unreleased/1264-dark64
Normal file
1
changelogs/unreleased/1264-dark64
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Optimize `zokrates-js` library size
|
|
@ -18,17 +18,17 @@ import pako from "pako";
|
||||||
|
|
||||||
let bytes;
|
let bytes;
|
||||||
|
|
||||||
if (typeof atob === 'function') {
|
if (typeof Buffer === "function") {
|
||||||
|
bytes = Buffer.from(encoded, "base64");
|
||||||
|
} else if (typeof atob === "function") {
|
||||||
const binary = atob(encoded);
|
const binary = atob(encoded);
|
||||||
bytes = new Uint8Array(binary.length);
|
bytes = new Uint8Array(binary.length);
|
||||||
|
|
||||||
for (let i = 0; i < binary.length; i++) {
|
for (let i = 0; i < binary.length; i++) {
|
||||||
bytes[i] = binary.charCodeAt(i);
|
bytes[i] = binary.charCodeAt(i);
|
||||||
}
|
}
|
||||||
} else if (typeof Buffer === 'function') {
|
|
||||||
bytes = Buffer.from(encoded, 'base64');
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Unsupported platform');
|
throw new Error("Unsupported platform");
|
||||||
}
|
}
|
||||||
|
|
||||||
const imports = getImports();
|
const imports = getImports();
|
||||||
|
|
Loading…
Reference in a new issue