npm-count
Version:
a npm/download-counts wrapper
80 lines (58 loc) • 2 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: fetchLastDay.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: fetchLastDay.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>// dependencies
import request from 'request';
import Promise from 'bluebird';
// private
const requestAsync = Promise.promisify(request);
const api = 'https://api.npmjs.org/downloads/point/last-day/';
/**
* fetch the api.npmjs.org's lastday
*
* @module fetchLastDay
* @returns {promise<string>} "YYYY-MM-DD"
* @see https://github.com/watilde/npm/issues/4#issuecomment-193541204
*/
export default () => (
requestAsync(api, {
json: true,
gzip: false,
})
.then(({ body }) => {
if (body.error) {
return {};// {"error":"no stats for this package for this period (0002)"}
}
return body.start;
})
);
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-fetchBulkQuery.html">fetchBulkQuery</a></li><li><a href="module-fetchLastDay.html">fetchLastDay</a></li><li><a href="module-fetchPublications.html">fetchPublications</a></li><li><a href="module-fetchTrending.html">fetchTrending</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Mar 10 2016 02:45:20 GMT+0000 (UTC)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>