How to use pretty-ms - 10 common examples

To help you get started, we’ve selected a few pretty-ms 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 guybedford / es-module-shims / bench / index.js View on Github external
return;
	}

	console.log(`> Cold: ${c.bold.green(ms(firstRun.duration))}`);

	// warm up
	let i = n;
	while (i--) run(code, file);

	// take average
	i = n;
	let total = 0;
	while (i--) total += run(code, file).duration;

	const avg = total / n;
	console.log(`> Warm: ${c.bold.green(ms(avg))} (average of ${n} runs)`);
}
github xxhomey19 / take-a-break / src / index.ts View on Github external
stayAwake.prevent(err => {
    if (err) {
      console.error(err);
    }
  });

  if (turnOff) {
    turnOffScreen();
  }

  console.log();
  console.log(chalk.bold.green('Time remaining: '));

  const duration: number = minutes * 60 * 1000;
  const spinner = ora({
    text: prettyMs(duration, { secDecimalDigits: 0 }),
    spinner: 'clock',
    interval: 80,
  }).start();

  timer.start(duration);

  timer.on('tick', currentTime => {
    spinner.text = prettyMs(currentTime, {
      secDecimalDigits: 0,
    });
  });

  timer.on(
    'done',
    (): void => {
      spinner.succeed(chalk.bold("Time's up"));
github mlaursen / react-md / packages / generator / src / index.ts View on Github external
async function run(commandName: string, promiseFn: () => Promise) {
  console.log(`Starting ${commandName}...`);
  console.log();
  const startTime = now();
  await promiseFn();
  console.log("Completed in %s", prettyMS(now() - startTime));
  console.log();
}
github tungv / jerni / packages / heq-client / src / logger / chalk-reporter.js View on Github external
export default (level, data) => {
  const prefix = PREFIXES[level] || PREFIXES.SILLY;
  const handler = handlers[data.type] || unknownTypeLogger;
  const now = Date.now();
  const relativeClose = now - lastLogTime <= 1000;
  const shouldLogDelta = relativeClose && now - lastFullTime <= 5000;
  const timeStr = shouldLogDelta
    ? ` +${prettyMs(now - lastLogTime)}`.padStart(29, '-')
    : format(now);

  if (!shouldLogDelta) lastFullTime = now;

  lastLogTime = now;

  console.log(`${prefix} ${chalk.italic.dim(timeStr)}:`, handler(data.payload));
};
github axross / tap-diff / sources / index.js View on Github external
const handleComplete = result => {
    const finishedAt = Date.now();

    println();
    println(
      chalk.green(`passed: ${result.pass}  `) +
      chalk.red(`failed: ${result.fail || 0}  `) +
      chalk.white(`of ${result.count} tests  `) +
      chalk.dim(`(${prettyMs(finishedAt - startedAt)})`)
    );
    println();

    if (result.ok) {
      println(chalk.green(`All of ${result.count} tests passed!`));
    } else {
      println(chalk.red(`${result.fail || 0} of ${result.count} tests failed.`));
      stream.isFailed = true;
    }

    println();
  };
github go-gitea / gitea / web_src / js / features / stopwatch.js View on Github external
async function updateStopwatchData(data) {
  const watch = data[0];
  const btnEl = $('.active-stopwatch-trigger');
  if (!watch) {
    btnEl.addClass('hidden');
  } else {
    const {repo_owner_name, repo_name, issue_index, seconds} = watch;
    const issueUrl = `${AppSubUrl}/${repo_owner_name}/${repo_name}/issues/${issue_index}`;
    $('.stopwatch-link').attr('href', issueUrl);
    $('.stopwatch-commit').attr('action', `${issueUrl}/times/stopwatch/toggle`);
    $('.stopwatch-cancel').attr('action', `${issueUrl}/times/stopwatch/cancel`);
    $('.stopwatch-issue').text(`${repo_owner_name}/${repo_name}#${issue_index}`);
    $('.stopwatch-time').text(prettyMilliseconds(seconds * 1000));
    updateStopwatchTime(seconds);
    btnEl.removeClass('hidden');
  }

  return !!data.length;
}
github compulim / BotFramework-MockBot / src / index.ts View on Github external
server.get('/', async (_, res) => {
  const message = `MockBot v4 is up since ${ prettyMs(Date.now() - up) } ago, processed ${ numActivities } activities.`;
  const separator = new Array(message.length).fill('-').join('');

  res.set('Content-Type', 'text/plain');
  res.send(JSON.stringify({
    human: [
      separator,
      message,
      separator
    ],
    computer: {
      numActivities,
      up
    }
  }, null, 2));
});
github saucelabs / speedo / src / utils.js View on Github external
export const sanitizeMetric = function (metric, value) {
    if (SCORE_METRICS.includes(metric)) {
        const scoreValue = value < 1 ? Math.round(value * 100) : value
        return scoreValue + '/100'
    }

    if (MB_UNIT_METRICS.includes(metric)) {
        return (value / 10 ** 6).toFixed(2) + 'MB'
    }

    if (NO_UNIT_METRICS.includes(metric)) {
        return value
    }

    return value ? prettyMs(value) : value
}
github electron-userland / electron-forge / packages / utils / async-ora / src / ora.ts View on Github external
  const timing = () => (startTime ? `-- after ${`${prettyMs(Date.now() - startTime)}`.cyan}` : null);
  const fake: OraImpl = {
github ArkEcosystem / core / packages / core-p2p / src / guard.ts View on Github external
private determinePunishment(peer, offence: IOffence): IPunishment {
        if (this.isRepeatOffender(peer)) {
            offence = this.offences.REPEAT_OFFENDER;
        }

        const until = dato()[offence.period](offence.number);
        const untilDiff = until.diff(dato());

        this.logger.debug(
            `Suspended ${peer.ip} for ${prettyMs(untilDiff, {
                verbose: true,
            })} because of "${offence.reason}"`,
        );

        return {
            until,
            reason: offence.reason,
            weight: offence.weight,
        };
    }
}

pretty-ms

Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`

MIT
Latest version published 3 months ago

Package Health Score

82 / 100
Full package analysis

Popular pretty-ms functions