Skip to content

Commit

Permalink
Add sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Oct 1, 2023
1 parent 5dece3a commit 7664e39
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,15 @@ async function listFiles(imagej, path) {
return files.map(cjStringJavaToJs);
}

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

async function mountFile(file) {
const filepath = "/str/" + file.name;
const bytes = await readFile(file);
cheerpjAddStringFile(filepath, bytes);
await sleep(1);
return filepath;
}

Expand All @@ -536,6 +541,7 @@ async function showImage(img, options) {
const filepath = "/str/" + options.name;
if (img instanceof ArrayBuffer) {
cheerpjAddStringFile(filepath, new Uint8Array(img));
await sleep(1);
return await openImage(imagej, filepath);
} else {
const formats = {
Expand All @@ -548,6 +554,7 @@ async function showImage(img, options) {
flaot64: "64-bit Real"
};
cheerpjAddStringFile(filepath, new Uint8Array(img._rvalue));
await sleep(1);
let format = formats[img._rdtype];

if (img._rshape.length === 3) {
Expand Down

0 comments on commit 7664e39

Please sign in to comment.