Skip to content

Commit

Permalink
refactor: rewrite example app to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
keindev committed Jan 3, 2022
1 parent db5abe7 commit 9d94a56
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions example/app.js → example/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import TaskTree from '../lib/index.js';
/* eslint-disable */
import TaskTree from '../src/TaskTree';

const tree = TaskTree.tree();

// start task tree log update in terminal
Expand All @@ -17,19 +19,23 @@ let once = false;
const promises = [50, 75, 200].map((ms, i) => {
return new Promise(resolve => {
const handle = setInterval(() => {
if (once) {
if (bars[i].percent >= 50) {
bars[i].skip();
const bar = bars[i];

if (bar) {
if (once) {
if (bar.percent >= 50) {
bar.skip();
} else {
bar.fail();
}
} else {
bars[i].fail();
once = bar.tick(Math.random() * 10).isCompleted;
}
} else {
once = bars[i].tick(Math.random() * 10).isCompleted;
}

if (once) {
clearInterval(handle);
resolve();
resolve('');
}
}, ms);
});
Expand Down

0 comments on commit 9d94a56

Please sign in to comment.