# @gfxpulse/timeout-map

> Just like a normal Map, just with callbacks after specified time after adding elements

Latest version **1.0.2** (published 2019-11-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install @gfxpulse/timeout-map
pnpm add @gfxpulse/timeout-map
yarn add @gfxpulse/timeout-map
bun add @gfxpulse/timeout-map
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-11-08 |
| First published | 2019-11-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrej Zbín |
| Maintainers | scooty14 |
| Keywords | javascript, nodejs, npm, timeout, map |

## Links

- npm: https://www.npmjs.com/package/@gfxpulse/timeout-map
- Repository: https://github.com/AndrejZbin/timeout-map
- Homepage: https://github.com/AndrejZbin/timeout-map#readme
- Issues: https://github.com/AndrejZbin/timeout-map/issues
- npm.io page: https://npm.io/package/@gfxpulse/timeout-map

## Recent versions

- 1.0.2 (latest) — 2019-11-08
- 1.0.1 — 2019-11-08

## README

# Install

```sh
npm install @gfxpulse/timeout-map
```


# Example

```js
const TimeoutMap = require('@gfxpulse/timeout-map');

let map = new TimeoutMap([['key1', 'value1']], {
    autodelete: true,
    timeout: 5000,
    margin: 100,
    additional_arguments: ['some argument'],
    handler: function (key, value, map, additional_argument1) {
        console.log(`${key}: ${value} - ${additional_argument1}`);
        console.log(`${key} in map - ${map.has(key)}`);
    }
});

map.set('key2', 'value2', {
    autodelete: false,
});
```
Output:
```
key1: value1 - some argument
key1 in map - false
key2: value2 - some argument
key2 in map - true
```

### Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `autodelete` | `bool` | `true` | Key automatically deleted from map before handler is called |
| `timeout` | `int` | `null` | How long until handler is called (null = never) |
| `margin` | `int` | `0` | Minimum time interval between set of handler calls |
| `additional_arguments` | `array` | `[]` | Additional arguments passed to handler |
| `handler` | `Function` | `(key, value, map) => {}` | Function called after timeout. Key, value, map and additional arguments are passed as parameters |

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