Skip to content

Commit

Permalink
docs: minimal API
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Apr 13, 2024
1 parent 892a261 commit 406e9a8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,33 @@

> 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. <small>`ua.incr(req.headers['user-agent'])`</small><br/>
Increment the counter associated with an user agent.

- **top(n, { withScore })** — e.g. <small>`ua.top(100)`</small><br/>
Returns an array of the N ranked from from top.

- **flush** — e.g. <small>`ua.delete()`</small><br/>
Delete elements.

## License

**microlink/ua** © [microlink.io](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/ua/blob/master/LICENSE.md) License.<br>
Expand Down

0 comments on commit 406e9a8

Please sign in to comment.