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.
cvm/lib/tasks/fake-task.js

22 lines
489 B
JavaScript

'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;
};