You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
489 B
JavaScript
22 lines
489 B
JavaScript
6 years ago
|
'use strict';
|
||
|
|
||
|
const progressIndicator = require("./progress-indicator");
|
||
|
|
||
|
let maxProgressValue = 10000;
|
||
|
|
||
|
module.exports = function createFakeTask(duration) {
|
||
|
let fakeProgressTracker = progressIndicator(maxProgressValue);
|
||
|
let currentProgress = 0;
|
||
|
|
||
|
function addProgress() {
|
||
|
currentProgress += 1;
|
||
|
fakeProgressTracker.report(currentProgress);
|
||
|
|
||
|
if (currentProgress < maxProgressValue) {
|
||
|
setTimeout(addProgress, duration / maxProgressValue);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return fakeProgressTracker;
|
||
|
};
|