npm-count

a npm/download-counts wrapper

Usage no npm install needed!

<script type="module">
  import npmCount from 'https://cdn.skypack.dev/npm-count';
</script>

README

Npm Count

a npm/download-counts wrapper

API Documentation

Usage

npm install npm-count
import npmCount from 'npm-count';

npmCount.fetchLastDay()
.then((lastday) => (
  npmCount.fetchTrending(lastday)
  .then((trending) => {
    // sort by downloads desc, name asc
    trending.sort((a, b) => {
      switch (true) {
        case a.downloads > b.downloads: return -1;
        case a.downloads < b.downloads: return 1;
        default:
          switch (true) {
            case a.name > b.name: return -1;
            case a.name < b.name: return 1;
            default: return 0;
          }
      }
    });

    const top10 = trending.slice(0, 10).map(({ name, downloads }) => ({ name, downloads }));
    console.log(lastday, top10);
  })
));

becomes:

// 2016-03-09
// [ { name: 'accepts', downloads: 383431 },
//   { name: 'js-yaml', downloads: 355826 },
//   { name: 'tough-cookie', downloads: 320130 },
//   { name: 'babel-core', downloads: 182993 },
//   { name: 'ast-types', downloads: 171452 },
//   { name: 'babylon', downloads: 167286 },
//   { name: 'recast', downloads: 159671 },
//   { name: 'invariant', downloads: 100457 },
//   { name: 'ansi-escapes', downloads: 93092 },
//   { name: 'babel-types', downloads: 86348 } ]

Development

git clone https://github.com/59naga/npm-count.git
cd npm-count
npm test

License

MIT