This is the code snippet. Here, I want to check if an image's width OR heigh exceeds 100, I want to return true so that I can restrict uploading such file/image to the array.
const getHeightWidth = async () => {
const reader = new FileReader();
reader.readAsDataURL(file);
await reader.addEventListener('load', async (e) => {
const image = new Image();
image.src = reader.result;
await image.addEventListener('load', function () {
const { height, width } = this;
invalidFileHeightWidth = !!((height !== 100 || width !== 100));
return invalidFileHeightWidth;
});
});
};
I tried Promise.resolve as well as a direct return statement but no luck so far