downloads v0.1.0
downloads

Retrieve npm download stats for the specified repository or maintainer.
Install
Install with npm:
$ npm install --save downloadsUsage
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:repoEmitsrepoevent 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:reposEmitsreposevent when the maintainers repositories have been retrieved. Emits the maintainer name and the repository array.emits:repoEmitsrepoevent for each repository after the repository's download counts are available.emits:maintainerEmitsmaintainerevent 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 && verbRunning tests
Install dev dependencies:
$ npm install -d && npm testAuthor
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.