# freemap

> Numeric map with a free list

Latest version **1.0.1** (published 2020-06-24) · MIT license · 0 weekly downloads

## Install

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

## 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.1 |
| Published | 2020-06-24 |
| First published | 2020-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/freemap
- Repository: https://github.com/mafintosh/freelist
- Issues: https://github.com/mafintosh/freelist/issues
- npm.io page: https://npm.io/package/freemap

## Recent versions

- 1.0.1 (latest) — 2020-06-24
- 1.0.0 — 2020-06-24

## README

# freemap

Numeric map with a free list

```
npm install freemap
```

## Usage

``` js
const FreeMap = require('freemap')

const f = new FreeMap()

const id = f.add({ hello: 'world' })
const id2 = f.add({ hello: 'verden' })

console.log(f.get(id)) // { hello: world }
console.log(f.get(id2)) // { hello: verden }
```

## API

#### `const f = new FreeMap(idOffset = 0)`

Make a new FreeMap

#### `id = f.add(value)`

Add a new value. Returns a free id from the freelist or allocates a new one. Runs in O(1)

#### `f.set(id, value)`

Update a value. Runs in O(1)

#### `value = f.get(id)`

Get a value. Runs in O(1)

#### `f.free(id)`

"Free" an id. Pushes the used id to a internal freelist. Runs in O(1)

#### `...f`

The map is iteratable. Each entry is `[id, value]` in the iterator.

## License

MIT

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