# @jacobbubu/capped-event

> [![Build Status](https://travis-ci.org/jacobbubu/capped-event.svg)](https://travis-ci.org/jacobbubu/capped-event) [![Coverage Status](https://coveralls.io/repos/github/jacobbubu/capped-event/badge.svg)](https://coveralls.io/github/jacobbubu/capped-event)

Latest version **1.2.1** (published 2019-11-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jacobbubu/capped-event
pnpm add @jacobbubu/capped-event
yarn add @jacobbubu/capped-event
bun add @jacobbubu/capped-event
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2019-11-19 |
| First published | 2019-11-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 1 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | jacobbubu |
| Maintainers | jacobbubu |

## Links

- npm: https://www.npmjs.com/package/@jacobbubu/capped-event
- Repository: https://github.com/jacobbubu/capped-event
- Homepage: https://github.com/jacobbubu/capped-event#readme
- Issues: https://github.com/jacobbubu/capped-event/issues
- npm.io page: https://npm.io/package/@jacobbubu/capped-event

## Dependencies (1)

- [@jacobbubu/scuttlebutt-pull](https://npm.io/package/@jacobbubu/scuttlebutt-pull.md) ^1.4.0

## Recent versions

- 1.2.1 (latest) — 2019-11-19
- 1.2.0 — 2019-11-18
- 1.1.0 — 2019-11-18
- 1.0.0 — 2019-11-17

## README

# @jacobbubu/capped-event

[![Build Status](https://travis-ci.org/jacobbubu/capped-event.svg)](https://travis-ci.org/jacobbubu/capped-event)
[![Coverage Status](https://coveralls.io/repos/github/jacobbubu/capped-event/badge.svg)](https://coveralls.io/github/jacobbubu/capped-event)
[![npm](https://img.shields.io/npm/v/@jacobbubu/capped-event.svg)](https://www.npmjs.com/package/@jacobbubu/capped-event/)

> A derived class from ReliableEvent in [scuttlebutt-pull](https://github.com/jacobbubu/scuttlebutt-pull) that provides basic cache management capabilities.

## Intro.

The `ReliableEvent` in [scuttlebutt-pull](https://github.com/jacobbubu/scuttlebutt-pull) has not provided cache mechanism.

You can only push events into the instance of `ReliableEvent`, but there is no way to remove them.

In `CappedEvent`, we fire a notification when the items count for some event reached a `warningLine` that is setting by the `options` you passed through the construction.

For removing items from cache, we provide to methods:

- `pruneBefore(before: number, key: string)`: prune the items before xxx milliseconds.
- `pruneTo(remain: number, key: string)`: just keep `remain` items in cache.

Please the test case for the detail.

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