# big-leak

> Leaky bucket implementation

Latest version **0.0.8** (published 2021-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install big-leak
pnpm add big-leak
yarn add big-leak
bun add big-leak
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2021-06-24 |
| First published | 2021-06-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | nemanjan00 |
| Maintainers | nemanjan00 |

## Links

- npm: https://www.npmjs.com/package/big-leak
- Repository: git@github.com:nemanjan00/big-leak
- npm.io page: https://npm.io/package/big-leak

## Dependencies (1)

- [dataman](https://npm.io/package/dataman.md) ^0.0.10

## Recent versions

- 0.0.8 (latest) — 2021-06-24
- 0.0.7 — 2021-06-24
- 0.0.6 — 2021-06-24
- 0.0.5 — 2021-06-24
- 0.0.4 — 2021-06-16
- 0.0.3 — 2021-06-16
- 0.0.2 — 2021-06-16
- 0.0.1 — 2021-06-15

## README

# big-leak 🌊

[![Build Status](https://travis-ci.org/nemanjan00/big-leak.svg?branch=master)](https://travis-ci.org/nemanjan00/big-leak)

[Leaky bucket](https://en.wikipedia.org/wiki/Leaky_bucket) implementation

## Table of contents

<!-- vim-markdown-toc GFM -->

* [Installation](#installation)
	* [NPM](#npm)
	* [Yarn](#yarn)
* [Usage](#usage)
* [Authors](#authors)

<!-- vim-markdown-toc -->

## Installation

### NPM

```bash
npm install big-leak --save
```

### Yarn

```bash
yarn add big-leak
```

## Usage

```javascript
const limiter = require("big-leak")({
	url: "memory://", // Dataman connection url
	prefix: "leaky:", // Redis key prefix
	delimiter: ":", // Redix key delimiter
	initialValue: 0, // How full do you want bucket to be?
	maxValue: 20, // How much do you want bucket to be able to fill up?
	refillTime: 24 * 60 * 60 * 1000, // 1-day - how often should bucket be filled up
	refillAmount: 20, // How much should bucket be refilled each refill time
	updateType: "float" // Do you want to refill bucket less thatn refillAmount?
});

const limit = limiter.limit("send-request", 123);

const sendRequest = limit.wrapper((url) => {
	console.log("Sending request");

	return Promise.resolve();
});

Array(50).fill(true).reduce((prev) => prev.then(sendRequest), Promise.resolve());
```

## Authors

* [nemanjan00](https://github.com/nemanjan00)

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