# map-age-cleaner

> Automatically cleanup expired items in a Map

Latest version **0.2.0** (published 2021-08-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install map-age-cleaner
pnpm add map-age-cleaner
yarn add map-age-cleaner
bun add map-age-cleaner
```

## Health

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

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

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2021-08-23 |
| First published | 2018-08-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=7.6 |
| Dependencies | 1 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 19 |
| Author | Sam Verschueren |
| Maintainers | samverschueren |
| Keywords | map, age, cleaner, maxage, expire, expiration, expiring |

## Links

- npm: https://www.npmjs.com/package/map-age-cleaner
- Repository: https://github.com/SamVerschueren/map-age-cleaner
- Homepage: https://github.com/SamVerschueren/map-age-cleaner#readme
- Issues: https://github.com/SamVerschueren/map-age-cleaner/issues
- npm.io page: https://npm.io/package/map-age-cleaner

## Dependencies (1)

- [p-defer](https://npm.io/package/p-defer.md) ^1.0.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2021-08-23
- 0.1.3 — 2018-11-13
- 0.1.2 — 2018-09-06
- 0.1.1 — 2018-08-22
- 0.1.0 — 2018-08-21

## README

# map-age-cleaner

![CI](https://github.com/SamVerschueren/map-age-cleaner/workflows/CI/badge.svg) [![codecov](https://codecov.io/gh/SamVerschueren/map-age-cleaner/badge.svg?branch=master)](https://codecov.io/gh/SamVerschueren/map-age-cleaner?branch=master)

> Automatically cleanup expired items in a Map


## Install

```
$ npm install map-age-cleaner
```


## Usage

```js
import mapAgeCleaner = require('map-age-cleaner');

const map = new Map([
	['unicorn', {data: '🦄', maxAge: Date.now() + 1000}]
]);

mapAgeCleaner(map);

map.has('unicorn');
//=> true

// Wait for 1 second...

map.has('unicorn');
//=> false
```

> **Note**: Items have to be ordered ascending based on the expiry property. This means that the item which will be expired first, should be in the first position of the `Map`.


## API

### mapAgeCleaner(map, [property])

Returns the `Map` instance.

#### map

Type: `Map`

Map instance which should be cleaned up.

#### property

Type: `string`<br>
Default: `maxAge`

Name of the property which olds the expiry timestamp.


## Related

- [expiry-map](https://github.com/SamVerschueren/expiry-map) - A `Map` implementation with expirable items
- [expiry-set](https://github.com/SamVerschueren/expiry-set) - A `Set` implementation with expirable keys
- [mem](https://github.com/sindresorhus/mem) - Memoize functions


## License

MIT © [Sam Verschueren](https://github.com/SamVerschueren)


---

<div align="center">
	<b>
		<a href="https://tidelift.com/subscription/pkg/npm-map-age-cleaner?utm_source=npm-map-age-cleaner&utm_medium=referral&utm_campaign=enterprise">Get professional support for this package with a Tidelift subscription</a>
	</b>
	<br>
	<sub>
		Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
	</sub>
</div>

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