Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
init() {
const { file, options } = this;
if (!isBlob(file)) {
this.fail(new Error('The first argument must be a File or Blob object.'));
return;
}
const mimeType = file.type;
if (!isImageType(mimeType)) {
this.fail(new Error('The first argument must be an image File or Blob object.'));
return;
}
if (!URL || !FileReader) {
this.fail(new Error('The current browser does not support image compression.'));
return;
}
return new Promise((resolve, reject) => {
if (!isBlob(file)) {
reject(new Error('The first argument must be a File or Blob object.'));
return;
}
const mimeType = file.type;
if (!isImageType(mimeType)) {
reject(new Error('The first argument must be an image File or Blob object.'));
return;
}
if (!URL && !FileReader) {
reject(new Error('The current browser does not support image compression.'));
return;
}