Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/microlinkhq/ua
A simple redis primitives to incr() and top() user agents
https://github.com/microlinkhq/ua
crawler redis user-agent user-agent-parser
Last synced: 4 days ago
JSON representation
A simple redis primitives to incr() and top() user agents
- Host: GitHub
- URL: https://github.com/microlinkhq/ua
- Owner: microlinkhq
- License: mit
- Created: 2023-12-21T10:13:38.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-05-07T18:55:21.000Z (6 months ago)
- Last Synced: 2024-09-18T13:12:27.274Z (about 2 months ago)
- Topics: crawler, redis, user-agent, user-agent-parser
- Language: JavaScript
- Homepage:
- Size: 43.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
![Last version](https://img.shields.io/github/tag/microlinkhq/ua.svg?style=flat-square)
[![Coverage Status](https://img.shields.io/coveralls/microlinkhq/ua.svg?style=flat-square)](https://coveralls.io/github/microlinkhq/ua)
[![NPM Status](https://img.shields.io/npm/dm/microlinkhq/ua.svg?style=flat-square)](https://www.npmjs.org/package/microlinkhq/ua)> A simple redis primitives to incr() and top() user agents.
## Install
```sh
npm install @microlink/ua
```## Usage
First, initialize the library passing a Redis instance:
```js
const Redis = require('ioredis')
const redis = new Redis()
const ua = require('@microlink/ua')(redis)
```After that, the library offers the following methods:
- **incr(userAgent)** — e.g. `ua.incr(req.headers['user-agent'])`
Increment the counter associated with an user agent.- **top(n, { withScore })** — e.g. `ua.top(100)`
Returns an array of the N ranked from from top.- **flush** — e.g. `ua.delete()`
Delete elements.## License
**microlink/ua** © [microlink.io](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/ua/blob/master/LICENSE.md) License.
Authored and maintained by [Kiko Beats](https://kikobeats.com) with help from [contributors](https://github.com/microlinkhq/queue/contributors).> [microlink.io](https://microlink.io) · GitHub [microlink.io](https://github.com/microlinkhq) · X [@microlinkhq](https://x.com/microlinkhq)