How to use millify - 10 common examples

To help you get started, we’ve selected a few millify 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 badgen / badgen.net / api / docker.ts View on Github external
return {
      subject: 'docker',
      status: 'unknown topic',
      color: 'grey'
    }
  }

  /* eslint-disable camelcase */
  const endpoint = `https://hub.docker.com/v2/repositories/${scope}/${name}`
  const { pull_count, star_count } = await got(endpoint).then(res => res.body)

  switch (topic) {
    case 'stars':
      return {
        subject: 'docker stars',
        status: millify(star_count),
        color: 'blue'
      }
    case 'pulls':
      return {
        subject: 'docker pulls',
        status: millify(pull_count),
        color: 'blue'
      }
  }
}
github badgen / badgen.net / api / docker.ts View on Github external
/* eslint-disable camelcase */
  const endpoint = `https://hub.docker.com/v2/repositories/${scope}/${name}`
  const { pull_count, star_count } = await got(endpoint).then(res => res.body)

  switch (topic) {
    case 'stars':
      return {
        subject: 'docker stars',
        status: millify(star_count),
        color: 'blue'
      }
    case 'pulls':
      return {
        subject: 'docker pulls',
        status: millify(pull_count),
        color: 'blue'
      }
  }
}
github cncf / landscapeapp / src / components / Summary.js View on Github external
const getText = ({summary}) => {
  if (!summary.total) {
    return 'There are no cards matching your filters';
  }
  const cardsText = summary.total === 1 ? 'card' : 'cards';
  const startText = `You are viewing ${formatNumber(summary.total)} ${cardsText} with a total`;
  const starsSection = summary.stars ? `of ${formatNumber(summary.stars)} stars` : null;
  const marketCapSection = summary.marketCap ? `market cap of $${millify(summary.marketCap)}` : null;
  const fundingSection = summary.funding ? `funding of $${millify(summary.funding)}` : null;
  if (!marketCapSection && !fundingSection && !starsSection) {
    return `You are viewing ${formatNumber(summary.total)} ${cardsText}.`;
  }

  const parts = [starsSection, marketCapSection, fundingSection].filter( (x) => !!x);
  const startPartsText = _.slice(parts, 0, -1).join(', ');
  const lastPart = _.slice(parts, -1)[0];
  const text = [startPartsText, lastPart].filter( (x) => !!x).join(' and ');
  return `${startText} ${text}.`;
}
github cncf / landscapeapp / tools / fundingHistoryPage.js View on Github external
result.forEach(item => {
  const delta = item.currentAmount - (item.previousAmount || 0);
  const text = `${item.name} got funding of $${millify(delta)}, now totalling $${millify(item.currentAmount)}, on ${item.date}`;
  feed.addItem({
    title: text,
    id: `${item.name}${item.date}`,
    link: item.url,
    description: text,
    content: text,
    date: new Date(Date.parse(item.date)),
    updated: new Date(Date.parse(item.date))
  });
});
github badgen / badgen.net / api / packagist.ts View on Github external
return {
        subject: 'suggesters',
        status: millify(packageMeta.suggesters),
        color: 'green'
      }
    case 'n':
    case 'name':
      return {
        subject: 'packagist',
        status: packageMeta.name,
        color: 'green'
      }
    case 'ghs':
      return {
        subject: 'stars',
        status: millify(packageMeta.github_stars),
        color: 'green'
      }
    case 'ghw':
      return {
        subject: 'watchers',
        status: millify(packageMeta.github_watchers),
        color: 'green'
      }
    case 'ghf':
      return {
        subject: 'forks',
        status: millify(packageMeta.github_forks),
        color: 'green'
      }
    case 'ghi':
      return {
github badgen / badgen.net / endpoints / apm.ts View on Github external
subject: `apm`,
        status: version(meta.releases.latest),
        color: versionColor(meta.releases.latest)
      }
    }
    case 'license': {
      return {
        subject: 'license',
        status: meta.versions[meta.releases.latest].license || 'unknown',
        color: 'blue'
      }
    }
    case 'downloads': {
      return {
        subject: 'downloads',
        status: millify(meta.downloads),
        color: 'green'
      }
    }
    case 'stars': {
      return {
        subject: 'stars',
        status: millify(meta.stargazers_count),
        color: 'green'
      }
    }
    default: {
      return {
        subject: 'apm',
        status: 'unknown',
        color: 'grey'
      }
github badgen / badgen.net / api / rubygems.ts View on Github external
async function handler ({ topic, gem }: PathArgs) {
  const endpoint = `https://rubygems.org/api/v1/gems/${gem}.json`
  const response = await got(endpoint).then(res => res.body)

  switch (topic) {
    case 'dt':
      return {
        subject: 'downloads',
        status: millify(response.downloads),
        color: 'green'
      }
    case 'dv':
      return {
        subject: 'downloads',
        status: millify(response.version_downloads) + '/version',
        color: 'green'
      }
    case 'n':
      return {
        subject: 'rubygems',
        status: response.name,
        color: 'green'
      }
    case 'p':
      return {
        subject: 'platform',
        status: response.platform,
        color: 'green'
      }
    default:
      return {
github badgen / badgen.net / api / rubygems.ts View on Github external
async function handler ({ topic, gem }: PathArgs) {
  const endpoint = `https://rubygems.org/api/v1/gems/${gem}.json`
  const response = await got(endpoint).then(res => res.body)

  switch (topic) {
    case 'dt':
      return {
        subject: 'downloads',
        status: millify(response.downloads),
        color: 'green'
      }
    case 'dv':
      return {
        subject: 'downloads',
        status: millify(response.version_downloads) + '/version',
        color: 'green'
      }
    case 'n':
      return {
        subject: 'rubygems',
        status: response.name,
        color: 'green'
      }
    case 'p':
      return {
github badgen / badgen.net / api / packagist.ts View on Github external
case 'name':
      return {
        subject: 'packagist',
        status: packageMeta.name,
        color: 'green'
      }
    case 'ghs':
      return {
        subject: 'stars',
        status: millify(packageMeta.github_stars),
        color: 'green'
      }
    case 'ghw':
      return {
        subject: 'watchers',
        status: millify(packageMeta.github_watchers),
        color: 'green'
      }
    case 'ghf':
      return {
        subject: 'forks',
        status: millify(packageMeta.github_forks),
        color: 'green'
      }
    case 'ghi':
      return {
        subject: 'issues',
        status: millify(packageMeta.github_open_issues),
        color: 'green'
      }
    case 'license':
      return {
github badgen / badgen.net / api / chrome-web-store.ts View on Github external
async function handler ({ topic, id }: PathArgs) {
  const meta = await webstore.detail({ id })
  switch (topic) {
    case 'v':
      return {
        subject: 'chrome web store',
        status: version(meta.version),
        color: versionColor(meta.version)
      }
    case 'users':
      return {
        subject: 'users',
        status: millify(parseInt(meta.users.replace(/,/g, ''))),
        color: 'green'
      }
    case 'price':
      return {
        subject: 'price',
        status: meta.price,
        color: 'green'
      }
    case 'rating':
      return {
        subject: 'rating',
        status: `${Number(meta.rating.average).toFixed(2)}/5`,
        color: 'green'
      }
    case 'stars':
      return {

millify

Converts long numbers to pretty, human-readable strings

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis

Popular millify functions