How to use the progress function in progress

To help you get started, we’ve selected a few progress examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Tarnadas / smmdb / src / server / scripts / database.js View on Github external
let query = 'SELECT id,title,owner,coursetype,nintendoid,leveltype,difficulty,updatereq,hasthumbnail,hasimage,ispackage,downloadpath,' +
      'videoid,UNIX_TIMESTAMP(lastmodified) as lastmodified,UNIX_TIMESTAMP(uploaded) as uploaded FROM courses'

    // convert accounts
    let rows = (await this[mysqlConnection].execute('SELECT * FROM accounts'))[0]
    let accountIds = {}
    for (let i = 0; i < rows.length; i++) {
      let id = rows[i].id
      let account = new Account(Account.convertFromMySQL(rows[i]))
      accountIds[id] = (await this.addAccount(account)).insertedId
      account.setId()
    }

    // convert courses
    rows = (await this[mysqlConnection].execute(query))[0]
    let progress = new ProgressBar('  converting courses [:bar] :percent :etas', {
      complete: '=',
      incomplete: ' ',
      width: 40,
      total: rows.length
    })
    try {
      for (let i = 0; i < rows.length; i++) {
        let id = rows[i].id
        let courses = await Course.convertFromMySQL(rows[i])
        let thumbnail = path.join(__dirname, `../static/img/courses/${id}.pic`)
        for (let j = 0; j < courses.length; j++) {
          courses[j].owner = accountIds[courses[j].owner]
          let course = await (new Course(courses[j])).fix(thumbnail)
          await this.addCourse(course)
          await course.finalize()
          course.setId()
github cofacts / rumors-api / test / evaluation / falsePositive.js View on Github external
async function main() {
  console.log('=== False Positive Validation ===');

  const samples = parse(fs.readFileSync(NON_DB_SAMPLES), { columns: true });
  console.log('Querying user input non-db samples in DB...');

  const progress = new Progress('[:bar] :current/:total :etas', { total: samples.length });

  const allResults = await Promise.all(samples.map(({ rumor }) =>
    gql`
      query ($text: String) {
        SearchArticles(text: $text) {
          edges {
            score
            node {
              id
              text
            }
          }
        }
      }
    `({
      text: rumor,
github react-static / react-static / packages / react-static / src / utils / progress.js View on Github external
export default (total, label, options) => {
  if (!options) {
    options = {}
  }
  if (!options.format) {
    options.format = `${
      label ? `${label} ` : ''
    }[:bar] :current/:total :percent :rate/s :etas `
  }
  const stream = options.stream || process.stderr
  if (stream.isTTY && !options.forceNonTTY) {
    options.total = total
    return new Progress(options.format, options)
  }
  let curr = 0
  let percent = 0
  const start = new Date()
  return {
    tick: () => {
      curr += 1
      const ratio = Math.min(Math.max(curr / total, 0), 1)
      const value = Math.floor(ratio * 100)

      if (value >= percent + 5) {
        percent = value
        const elapsed = new Date() - start
        const eta = percent === 100 ? 0 : elapsed * (total / curr - 1)
        const rate = curr / (elapsed / 1000)
        stream.write(
github MikaAK / s3-plugin-webpack / src / index.js View on Github external
setupProgressBar(uploadFiles) {
    const progressAmount = Array(uploadFiles.length);
    const progressTotal = Array(uploadFiles.length);
    let progressTracker = 0;
    const calculateProgress = () => _.sum(progressAmount) / _.sum(progressTotal);
    const countUndefined = array => _.reduce(array, (res, value) => res += _.isUndefined(value) ? 1 : 0, 0);

    const progressBar = new ProgressBar('Uploading [:bar] :percent :etas', {
      complete: '>',
      incomplete: '∆',
      total: 100,
    });

    uploadFiles.forEach(({ upload }, i) => {
      upload.on('progress', function () {
        let definedModifier;
        let progressValue;

        progressTotal[i] = this.progressTotal;
        progressAmount[i] = this.progressAmount;
        definedModifier = countUndefined(progressTotal) / 10;
        progressValue = calculateProgress() - definedModifier;

        if (progressValue !== progressTracker) {
github zeit / now / download / src / log.js View on Github external
export function enableProgress(text) {
  assert(!bar);

  bar = new Progress(`> ${text} [:bar] :percent`, {
    stream: process.stdout,
    width: 20,
    complete: '=',
    incomplete: ' ',
    total: 100
  });
}
github expo / expo-cli / packages / expo-cli / src / exp.ts View on Github external
onStartBuildBundle: () => {
        bar = new ProgressBar('Building JavaScript bundle [:bar] :percent', {
          total: 100,
          clear: true,
          complete: '=',
          incomplete: ' ',
        });

        log.setBundleProgressBar(bar);
      },
      onProgressBuildBundle: (percent: number) => {
github astroband / astrograph / src / export-accounts.ts View on Github external
async function exportAccounts(): Promise {
  const batchSize = 1000;
  const batchesInFile = 100;
  let offset = 0;
  const accountsCount = await db.accounts.count();

  const bar = new ProgressBar("[:bar] :elapseds elapsed, eta :etas", { total: accountsCount });

  const batchesCount = Math.ceil(accountsCount / batchSize);
  let file = zlib.createGzip();

  for (let i = 0; i < batchesCount; i += 1) {
    if (i % batchesInFile === 0) {
      file.end();
      file = zlib.createGzip();

      file.pipe(fs.createWriteStream(`${dir}/${Math.ceil(i / batchesInFile)}.rdf.gz`));
    }

    const rows: IAccountTableRow[] = await db.any("SELECT * FROM accounts LIMIT $1 OFFSET $2", [batchSize, offset]);

    rows.forEach(row => {
      const account = AccountFactory.fromDb(row);
github QubitProducts / react-driver / lib / cli / standalone.js View on Github external
function progressCb (total, progress, chunk) {
    if (!bar) {
      bar = new ProgressBar(
        'selenium-standalone installation [:bar] :percent :etas',
        {
          total,
          complete: '=',
          incomplete: ' ',
          width: 20
        }
      )
    }
    bar.tick(chunk)
  }
}
github shoutem / cli / src / services / progress-bar.js View on Github external
function createProgressBar(msg, { total }) {
  return new ProgressBar(
    `   ${msg} [:bar] :percent (remaining :etas)`,
    {
      total,
      clear: true,
      width: 20,
      renderThrottle: 50
    }
  );
}
github expo / exp / src / exp.js View on Github external
onStartBuildBundle: () => {
        bar = new ProgressBar('Building JavaScript bundle [:bar] :percent', {
          total: 100,
          clear: true,
          complete: '=',
          incomplete: ' ',
        });

        log.setBundleProgressBar(bar);
      },
      onProgressBuildBundle: percent => {