New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

npm-count

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-count

a npm/download-counts wrapper

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

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

Keywords

npm

FAQs

Package last updated on 10 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts