# redleaf

> Model for all authentication of user

Latest version **1.4.3** (published 2017-02-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install redleaf
pnpm add redleaf
yarn add redleaf
bun add redleaf
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score; declining downloads.

## Facts

| | |
|---|---|
| Version | 1.4.3 |
| Published | 2017-02-10 |
| First published | 2016-10-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | yes |
| Author | David Alejandro Londoño |
| Maintainers | davidlondono |

## Links

- npm: https://www.npmjs.com/package/redleaf
- Repository: https://github.com/redleaf-redis/RedLeaf
- Homepage: https://github.com/redleaf-redis/RedLeaf#readme
- Issues: https://github.com/redleaf-redis/RedLeaf/issues
- npm.io page: https://npm.io/package/redleaf

## Dependencies (6)

- [debug](https://npm.io/package/debug.md) 2.2.0
- [rimraf](https://npm.io/package/rimraf.md) 2.5.4
- [bluebird](https://npm.io/package/bluebird.md) 3.4.6
- [babel-cli](https://npm.io/package/babel-cli.md) 6.18.0
- [babel-preset-node6](https://npm.io/package/babel-preset-node6.md) 11.0.0
- [babel-preset-stage-3](https://npm.io/package/babel-preset-stage-3.md) 6.17.0

## Recent versions

- 1.4.3 (latest) — 2017-02-10
- 1.4.2 — 2017-02-10
- 1.4.1 — 2017-02-10
- 1.4.0 — 2017-02-10
- 1.3.3 — 2017-02-10
- 1.3.2 — 2017-02-10
- 1.3.1 — 2017-02-06
- 1.3.0 — 2017-01-30
- 1.2.4 — 2016-10-27
- 1.2.3 — 2016-10-26
- 1.2.2 — 2016-10-26
- 1.2.1 — 2016-10-24
- 1.2.0 — 2016-10-24
- 1.1.6 — 2016-10-18
- 1.1.5 — 2016-10-18
- … 5 more at https://npm.io/package/redleaf/versions

## README

# RedLeaf 
[![Build Status](https://travis-ci.org/redleaf-redis/RedLeaf.svg?branch=master)](https://travis-ci.org/redleaf-redis/RedLeaf)
[![Test Coverage](https://codeclimate.com/github/redleaf-redis/RedLeaf/badges/coverage.svg)](https://codeclimate.com/github/redleaf-redis/RedLeaf)
[![Code Climate](https://codeclimate.com/github/luin/ioredis/badges/gpa.svg)](https://codeclimate.com/github/luin/ioredis)
[![codecov](https://codecov.io/gh/redleaf-redis/RedLeaf/branch/master/graph/badge.svg)](https://codecov.io/gh/redleaf-redis/RedLeaf)
[![npm](https://img.shields.io/npm/dm/redleaf.svg?maxAge=2592000)](https://www.npmjs.com/package/redleaf)
[![Dependency Status](https://david-dm.org/redleaf-redis/RedLeaf.svg)](https://david-dm.org/redleaf-redis/RedLeaf)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)


## Installation

`npm install redleaf`

## Usage
```js
import redleaf from 'redleaf';
```
### ZList

create a sorted set

| Param | Type | Description |
| --- | --- | --- |
| key | `String` | key of the list |
| server | `ioredis` | server instance of ioredis |

```javascript
import { ZList } from 'redleaf';
import Redis from 'ioredis';

const redisServer = new Redis();
const list = new ZList('listKey', redisServer)
```
#### list.add({ score, member }) => ` Promise<0|1>`
[ZADD](http://redis.io/commands/zadd)

| Param | Type | Description |
| --- | --- | --- |
| score | `Number` | score of member |
| member | ` String ` | value to add on list |

```javascript
list.add({
	member: 'one',
	score: 1,
	})
list.add({
	member: 'two',
	score: 2,
	})
```

#### score(member) => ` Promise< Number > `
[ZSCORE](http://redis.io/commands/zscore)

| Param | Type | Description |
| --- | --- | --- |
| member | ` String ` | value to ask for its score |

```javascript
list.score('one') // 1
list.scrose('three') // -1
```

#### remove(member) => ` Promise<1|2> `
[ZREM](http://redis.io/commands/zrem)

| Param | Type | Description |
| --- | --- | --- |
| member | `String ` | value to remove from set |

```javascript
list.remove('one') // 1
list.remove('four') // 0
```
#### scan(cursor) => ` Promise< {pointer: String, data: [{ member, score }] } > `
[ZSCAN](http://redis.io/commands/zscan)

| Param | Type | Description |
| --- | --- | --- |
| cursor | `String` | to iterate over set |

#### rangeByScore(ops) => ` Promise<[{ member, score }]> `
[ZRANGEBYSCORE](http://redis.io/commands/zrangebyscore)

[ZREVRANGEBYSCORE](http://redis.io/commands/zrevrangebyscore)

| Param | Type | Default |Description |
| --- | --- | --- | --- |
| [ops] | `String` | `{}` | |
| [ops.range] | `String` | `{}` | range to get the items |
| [ops.range.min] | `String` | `"-inf"` | score minimun to get items |
| [ops.range.max] | `String` | `"+inf"` | score maximun to get items|
| [ops.limit] | ` String ` |  | ammount max to bring on request |
| [ops.reverse] | ` Boolean ` | `false` | to use ZREVRANGEBYSCORE or not |

```javascript
list.rangeByScore() // [ {member: 'one', score: 1 }, { member: 'two', score: 2 }]
list.rangeByScore({
	range: {
		min: 1,
		max: 5
	},
	limit: 1,
	reverse: true
}); // [ { member: 'two', score: 2 }]

```
## Features to have

### License: MIT

---
_Source: https://npm.io/package/redleaf · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
