* omg it’s compiling

* example actually works

* Expose compression level options

* Disable crypto and path module emulation in webpack

* Update README

* Remove small image

* Use -O3 on optipng

* Free memory after copy

* Handle unexpected file reader return types

* Rename level label to effort
This commit is contained in:
Surma
2018-09-04 16:49:45 +01:00
committed by Jake Archibald
parent 170d75482e
commit 54ad30a7ed
19 changed files with 1832 additions and 10 deletions

View File

@@ -106,10 +106,13 @@ export function canDecodeImage(data: string): Promise<boolean> {
}
export function blobToArrayBuffer(blob: Blob): Promise<ArrayBuffer> {
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.addEventListener('load', () => {
resolve(fileReader.result);
if (fileReader.result instanceof ArrayBuffer) {
return resolve(fileReader.result);
}
reject(Error('Unexpected return type'));
});
fileReader.readAsArrayBuffer(blob);
});