mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
update test to be in actual typescript
This commit is contained in:
parent
081247e44e
commit
3666c21e7a
@ -1,42 +1,48 @@
|
||||
var ProgressBar = require('progress');
|
||||
import * as ProgressBar from 'progress';
|
||||
|
||||
/**
|
||||
* Usage example from https://github.com/tj/node-progress
|
||||
* Usage example from https://github.com/visionmedia/node-progress
|
||||
* (in Typescript)
|
||||
*/
|
||||
var bar = new ProgressBar(':bar', { total: 10 });
|
||||
var timer = setInterval(function () {
|
||||
bar.tick();
|
||||
if (bar.complete) {
|
||||
const usageBar = new ProgressBar(':bar', { total: 10 });
|
||||
const timer = setInterval(function () {
|
||||
usageBar.tick();
|
||||
if (usageBar.complete) {
|
||||
console.log('\ncomplete\n');
|
||||
clearInterval(timer);
|
||||
}
|
||||
}, 100);
|
||||
|
||||
|
||||
/**
|
||||
* Custom token example from https://github.com/tj/node-progress
|
||||
* Custom token example from https://github.com/visionmedia/node-progress
|
||||
* (in Typescript)
|
||||
*/
|
||||
var bar = new ProgressBar(':current: :token1 :token2', { total: 3 });
|
||||
|
||||
bar.tick({
|
||||
'token1': "Hello",
|
||||
'token2': "World!\n"
|
||||
});
|
||||
|
||||
bar.tick(2, {
|
||||
'token1': "Goodbye",
|
||||
'token2': "World!"
|
||||
});
|
||||
const list = [
|
||||
'image01.jpg', 'image02.jpg', 'image03.jpg', 'image04.jpg', 'image05.jpg',
|
||||
'image06.jpg', 'image07.jpg', 'image08.jpg', 'image09.jpg', 'image10.jpg'
|
||||
];
|
||||
const customTokenBar = new ProgressBar(':percent eta: :eta downloading :current/:total :file', {
|
||||
total: list.length
|
||||
});
|
||||
const customInterval = setInterval(function (){
|
||||
customTokenBar.tick({
|
||||
'file': list[customTokenBar.curr]
|
||||
})
|
||||
if (customTokenBar.complete) {
|
||||
clearInterval(customInterval)
|
||||
}
|
||||
}, 500)
|
||||
|
||||
/**
|
||||
* Interrupt example from https://github.com/visionmedia/node-progress
|
||||
* (in Typescript)
|
||||
*/
|
||||
var bar = new ProgressBar(':bar :current/:total', { total: 10 });
|
||||
var timer = setInterval(function () {
|
||||
bar.tick();
|
||||
if (bar.complete) {
|
||||
clearInterval(timer);
|
||||
} else if (bar.curr === 5) {
|
||||
bar.interrupt('this message appears above the progress bar\ncurrent progress is ' + bar.curr + '/' + bar.total);
|
||||
const interruptBar = new ProgressBar(':bar :current/:total', { total: 10 });
|
||||
const interruptTimer = setInterval(function () {
|
||||
interruptBar.tick();
|
||||
if (interruptBar.complete) {
|
||||
clearInterval(interruptTimer);
|
||||
} else if (interruptBar.curr === 5 || interruptBar.curr === 8) {
|
||||
interruptBar.interrupt('interrupt: current progress is ' + interruptBar.curr + '/' + interruptBar.total);
|
||||
}
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user