https://github.com/rawnly/easy-registry
Easy NPM Registry API module
https://github.com/rawnly/easy-registry
javascript node nodejs npm registry
Last synced: 28 days ago
JSON representation
Easy NPM Registry API module
- Host: GitHub
- URL: https://github.com/rawnly/easy-registry
- Owner: rawnly
- Created: 2017-02-13T18:17:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-17T20:39:20.000Z (about 9 years ago)
- Last Synced: 2024-12-28T09:43:23.551Z (over 1 year ago)
- Topics: javascript, node, nodejs, npm, registry
- Language: JavaScript
- Size: 52.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Easy Registry

> Easy tool for [NPM Registry][registry]
This module provides to give you information about a **npm** module.
You can grab downloads and `date` informations. You can also use [this module](https://github.com/jstrace/chart) to create beautiful chars.
## Install
**NPM**
```bash
$ npm install easy-registry --save
```
**YARN**
```bash
$ yarn add easy-registry
```
## Usage
```js
// Modules
const chart = require('chart');
const chili = require('chili-js');
const Package = require('easy-registry')
// Variables
const myModule = new Package('myModule')
// The magic happens
myModule.day((err, infos) => {
let downloads = infos.map(info => {
return info.downloads
});
downloads.sort((a, b) => {
return a - b
});
const ch = chart(downloads, {
width: 70,
height: 30
});
console.log(ch);
});
```
> With Callback
```javascript
// Modules
const chart = require('chart');
const chili = require('chili-js');
const Package = require('easy-registry')
// Variables
const myModule = new Package('myModule')
// The magic happens
myModule.day().then(infos => {
const downloads = infos.map(info => {
return info.downloads
});
// .sum() is a `chili-js` function!
console.log(`Total: ${downloads.sum()}`);
}).catch(err => {
throw new Error(err)
})
```
> With Promises
View the [full example](samples/example.js) for more informations about `data manipulation`.
## API
1. `.day(callback)` - Get datas about the last day.
2. `.week(callback)` - Get datas about the last week.
3. `.month(callback)` - Get datas about the last month.
4. `.year(callback)` - Get datas about the last year.
5. `.total(callback)` - Get datas from `1 Jan 1000` to the `current day`.
## Modules in the examples
- [chili-js](https://github.com/rawnly/chili-js) - Useful NodeJs variables and functions
- [jstrace/chart](https://github.com/jstrace/chart) - Ansi charts for nodejs
---
> Made with :heart: by [@Rawnly](https://github.com/rawnly)
[registry]: https://registry.npmjs.org