js promise demo
sleep
js
function sleep (time) {
return new Promise((resolve) => {
setTimeout(resolve, time)
});
}
readFile
js
async function readFile(fileBlob: Blob) {
return new Promise((resolve) => {
const reader = new FileReader();
reader.readAsText(fileBlob);
reader.onloadend = () => resolve(reader.result);
})
}