How to use the ms function in ms

To help you get started, we’ve selected a few 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 zeit / now / packages / now-cli / src / commands / billing / index.js View on Github external
try {
        cards = await creditCards.ls();
      } catch (err) {
        console.error(error(err.message));
        return 1;
      }

      if (cards.sources.length === 0) {
        console.error(error('You have no credit cards to choose from'));
        return 0;
      }

      let cardId = args[0];

      if (cardId === undefined) {
        const elapsed = ms(new Date() - start);
        const message = `Selecting a new default payment card for ${chalk.bold(
          contextName
        )} ${chalk.gray(`[${elapsed}]`)}`;
        const choices = buildInquirerChoices(cards);

        cardId = await listInput({
          message,
          choices,
          separator: true,
          abort: 'end'
        });
      }

      // Check if the provided cardId (in case the user
      // typed `now billing set-default `) is valid
      if (cardId) {
github u-wave / core / src / plugins / booth.js View on Github external
async onStart() {
    this.locker = new RedLock([this.uw.redis]);

    const current = await this.getCurrentEntry();
    if (current && this.timeout === null) {
      // Restart the advance timer after a server restart, if a track was
      // playing before the server restarted.
      const duration = (current.media.end - current.media.start) * ms('1 second');
      const endTime = Number(current.playedAt) + duration;
      if (endTime > Date.now()) {
        this.timeout = setTimeout(
          () => this.advance(),
          endTime - Date.now(),
        );
      } else {
        this.advance();
      }
    }
  }
github nusmodifications / nusmods / api / hasura / src / config.ts View on Github external
hasuraUrl: process.env.HASURA_URL as string,
  mailApiKey: process.env.SENDGRID_API_KEY as string,
  mailAddress: 'noreply@nusmods.com',
  // Passcode for verifying accounts
  passcode: {
    verifyTimeout: ms('15m'),
    verifyLimit: 20,
    requestLimitResetTimeout: ms('5m'),
    requestLimit: 20,
  },
  // Access Token for obtaining information (aka Hasura Token)
  accessToken: {
    nameSpace: hasuraConfig.claims_namespace,
    secretKey: hasuraConfig.key,
    secretAlgorithm: hasuraConfig.type,
    lifeTime: ms('1d'),
  },
  // Refresh Token for obtaining Access Token (aka Long Lived Token)
  refreshToken: {
    secretKey: hasuraConfig.key,
    secretAlgorithm: hasuraConfig.type,
    lifeTime: ms('90d'),
  },
};

export default config;
github terascope / teraslice / packages / scripts / src / helpers / test-runner / services.ts View on Github external
async function stopService(service: Service) {
    const { name } = services[service];
    const info = await getContainerInfo(name);
    if (!info) return;

    const startTime = Date.now();
    signale.pending(`stopping service ${service}`);
    await dockerStop(name);
    signale.success(`stopped service ${service}, took ${ms(Date.now() - startTime)}`);
}
github zeit / now / packages / now-cli / src / commands / deploy / legacy.ts View on Github external
Object.keys(deployment.scale).map(dc => chalk.bold(dc))
            )}`
          );
          const verifyStamp = stamp();
          const verifyDCsGenerator = getVerifyDCsGenerator(
            output,
            now,
            deployment,
            eventsStream
          );

          for await (const _dcOrEvent of verifyDCsGenerator) {
            const dcOrEvent = _dcOrEvent as any;
            if (dcOrEvent instanceof VerifyScaleTimeout) {
              output.error(
                `Instance verification timed out (${ms(
                  dcOrEvent.meta.timeout
                )})`
              );
              output.log(
                'Read more: https://err.sh/now/verification-timeout'
              );
              await exit(1);
            } else if (Array.isArray(dcOrEvent)) {
              const [dc, instances] = dcOrEvent;
              output.log(
                `${chalk.cyan(chars.tick)} Scaled ${plural(
                  'instance',
                  instances,
                  true
                )} in ${chalk.bold(dc)} ${verifyStamp()}`
              );
github zeit / now / packages / now-cli / src / commands / certs / ls.ts View on Github external
function formatExpirationDate(date: Date) {
  const diff = date.getTime() - Date.now();
  return diff < 0
    ? chalk.gray(`${ms(-diff)} ago`)
    : chalk.gray(`in ${ms(diff)}`);
}
github shannonmoeller / ygor / packages / tasks / src / tasks.js View on Github external
return (val) => {
		const endTime = new Date();
		const duration = ms(endTime - startTime);

		logTime(endTime, `Finished '${cyan(name)}' (${magenta(duration)})`);

		return val;
	};
}
github u-wave / core / src / SocketServer.js View on Github external
`);
}

export default class SocketServer {
  connections = [];

  options = {
    onError: (socket, err) => {
      throw err;
    },
    timeout: 30,
  };

  pinger = setInterval(() => {
    this.ping();
  }, ms('10 seconds'));

  /**
   * Create a socket server.
   *
   * @param {Uwave} uw üWave Core instance.
   * @param {object} options Socket server options.
   * @param {number} options.timeout Time in seconds to wait for disconnected
   *     users to reconnect before removing them.
   */
  constructor(uw, options = {}) {
    if (!uw || !('mongo' in uw)) {
      throw new TypeError('Expected a u-wave-core instance in the first parameter. If you are '
        + 'developing, you may have to upgrade your u-wave-* modules.');
    }

    if (!options.server && !options.port) {
github zeit / now / src / providers / sh / commands / certs / ls.js View on Github external
function formatExpirationDate(date) {
  const diff = date - Date.now()
  return diff < 0
    ? chalk.gray(ms(-diff) + ' ago')
    : chalk.gray('in ' + ms(diff))
}

ms

Tiny millisecond conversion utility

MIT
Latest version published 4 years ago

Package Health Score

76 / 100
Full package analysis