npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

downloads

v0.1.0

Published

Retrieve npm download stats for the specified repository or maintainer.

Downloads

178

Readme

downloads NPM version NPM downloads Linux Build Status

Retrieve npm download stats for the specified repository or maintainer.

Install

Install with npm:

$ npm install --save downloads

Usage

var downloads = require('downloads');

API

.repo

Retieve the download stats for the specified repository. The results are an array of download object that contain the day and downloads count for that day: [{day: '2016-11-12', downloads: 12345}]. This method will also emit a repo event on the downloads object when the downloads are available.

Example

downloads.repo('micromatch', function(err, results) {
  if (err) return console.error(err);
  console.log(results);
});
//=> [
//=>   { day: '2016-11-12', downloads: 94699 },
//=>   { day: '2016-11-11', downloads: 264382 },
//=>   { day: '2016-11-10', downloads: 309356 },
//=>   { day: '2016-11-09', downloads: 290557 },
//=>   { day: '2016-11-08', downloads: 316004 },
//=>   ...
//=> ]

Params

  • name {String}: Name of the repository to get download counts for.
  • options {Object}: Additional options.
  • cb {Function}: Optional callback function to get the results. If not provided, a promise is returned.
  • returns {Promise}: If no callback function is provided, a promise is returned that will yield the results array.

Events

  • emits: repo Emits repo event when downloads are available. Emits the repo name and download count array.

.maintainer

Retrieve the download stats for all of the repositories maintained by the specified maintainer. The results are an object where the key is the repository name and the value is an array of download counts. This is the same array returned by the repo method. This method will also emit a repos event when the repos have been retrieved for the maintainer and a maintainer event when all of the downloads have been retrieved and the final results object is available.

Example

downloads.maintainer('doowb', function(err, results) {
  if (err) return console.error(err);
  console.log(results);
});
//=> {
//=>   "add-collaborator": [...],
//=>   "accountdown-token": [...],
//=>   "add-banner": [...],
//=>   "align-text": [...],
//=>   "JSONStream": [...],
//=>   "anchors": [...],
//=>   "announcement": [...],
//=>   ...
//=> }

Params

  • name {String}: Name of the maintainer to retrieve download counts for.
  • options {Object}: Additional options to control how the downloads are gathered.
  • options.limit {Number}: Specify how many repositories can be processed concurrently. Defaults to 1.
  • cb {Function}: Optional callback function to get the results. If not provied, a promise is returned.
  • returns {Promise}: If no callback function is provied, a promise is returned that with yield the results object.

Events

  • emits: repos Emits repos event when the maintainers repositories have been retrieved. Emits the maintainer name and the repository array.
  • emits: repo Emits repo event for each repository after the repository's download counts are available.
  • emits: maintainer Emits maintainer event when all of the download counts for all of the maintainer's repositories are available.

About

Related projects

npm-api: Base class for retrieving data from the npm registry. | homepage

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for avice on opening issues, pull requests, and coding standards.

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Brian Woodward

License

Copyright © 2016, Brian Woodward. Released under the MIT license.


This file was generated by verb-generate-readme, v0.2.0, on November 13, 2016.