npm-count
Version:
a npm/download-counts wrapper
127 lines (87 loc) • 3.89 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</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">Home</h1>
<h3> </h3>
<section>
<article><h2>Npm Count</h2><p align="right">
<a href="https://npmjs.org/package/npm-count">
<img src="https://img.shields.io/npm/v/npm-count.svg?style=flat-square">
</a>
<a href="https://travis-ci.org/59naga/npm-count">
<img src="http://img.shields.io/travis/59naga/npm-count.svg?style=flat-square">
</a>
<a href="https://codeclimate.com/github/59naga/npm-count/coverage">
<img src="https://img.shields.io/codeclimate/github/59naga/npm-count.svg?style=flat-square">
</a>
<a href="https://codeclimate.com/github/59naga/npm-count">
<img src="https://img.shields.io/codeclimate/coverage/github/59naga/npm-count.svg?style=flat-square">
</a>
<a href="https://gemnasium.com/59naga/npm-count">
<img src="https://img.shields.io/gemnasium/59naga/npm-count.svg?style=flat-square">
</a>
</p>
<blockquote>
<p>a <a href="https://github.com/npm/download-counts">npm/download-counts</a> wrapper</p>
</blockquote>
<p><a href="https://cdn.berabou.me/npm-count/docs/">API Documentation</a></p>
<h2>Usage</h2><pre class="prettyprint source lang-bash"><code>npm install npm-count</code></pre><pre class="prettyprint source lang-js"><code>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);
})
));</code></pre><p>becomes:</p>
<pre class="prettyprint source lang-js"><code>// 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 } ]</code></pre><h2>Development</h2><pre class="prettyprint source lang-bash"><code>git clone https://github.com/59naga/npm-count.git
cd npm-count
npm test</code></pre><h2>License</h2><p><a href="http://59naga.mit-license.org/">MIT</a></p></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>