forked from doowb/download-stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (51 loc) · 1.41 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*!
* download-stats <https://github.com/doowb/download-stats>
*
* Copyright (c) 2016, Brian Woodward.
* Licensed under the MIT License.
*/
'use strict';
var calc = require('./lib/calculate');
var utils = require('./lib/utils');
var get = require('./lib/get');
var stats = {};
/**
* Get a range of download counts for the specified repository.
* This method returns a stream of raw data
* in the form of `{ day: '2016-01-10', downloads: 123456 }`.
*
* ```js
* var start = new Date('2016-01-09');
* var end = new Date('2016-01-10');
* stats.get(start, end, 'micromatch')
* .on('error', console.error)
* .on('data', function(data) {
* console.log(data);
* })
* .on('end', function() {
* console.log('done.');
* });
* // { day: '2016-01-09', downloads: 53331 }
* // { day: '2016-01-10', downloads: 47341 }
* ```
*
* @param {Date} `start` Start date of stream.
* @param {Date} `end` End date of stream.
* @param {String} `repo` Repository to get downloads for. If `repo` is not passed, then all npm downloads for the day will be returned.
* @return {Stream} Stream of download data.
* @api public
* @name get
*/
stats.get = get;
/**
* Calculate object containing methods to calculate stats on arrays of download counts.
* See [calculate][#calculate] api docs for more information.
*
* @api public
* @name calc
*/
stats.calc = calc;
/**
* Exposes `stats`
*/
module.exports = stats;