# map-util

> Utilities that make getting prev/next values in a map easier

Latest version **2.1.1** (published 2016-03-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install map-util
pnpm add map-util
yarn add map-util
bun add map-util
```

## 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 | 2.1.1 |
| Published | 2016-03-26 |
| First published | 2016-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Evan Lucas |
| Maintainers | evanlucas |

## Links

- npm: https://www.npmjs.com/package/map-util
- Repository: https://github.com/evanlucas/map-util
- Issues: https://github.com/evanlucas/map-util/issues
- npm.io page: https://npm.io/package/map-util

## Recent versions

- 2.1.1 (latest) — 2016-03-26
- 2.1.0 — 2016-03-26
- 2.0.0 — 2016-03-21
- 1.1.1 — 2016-03-16
- 1.1.0 — 2016-03-13
- 1.0.1 — 2016-03-13
- 1.0.0 — 2016-03-13

## README

# map-util

[![Build Status](https://travis-ci.org/evanlucas/map-util.svg)](https://travis-ci.org/evanlucas/map-util)
[![Coverage Status](https://coveralls.io/repos/evanlucas/map-util/badge.svg?branch=master&service=github)](https://coveralls.io/github/evanlucas/map-util?branch=master)

Simple set of utilities that make getting the previous or next value in a map
easier.

## Install

```bash
$ npm install [--save] map-util
```

## Usage

```js
'use strict'

const utils = require('map-util')
const nextVal = utils.nextVal
const prevVal = utils.prevVal

const map = new Map()
map.set('1', '1')
map.set('2', '2')

nextVal('1', map) // => '2'
nextVal('2', map) // => null
// If we want to wrap around:
nextVal('2', map, true) // => '1'

prevVal('2', map) // => '1'
prevVal('1', map) // => null
// If we want to wrap around:
prevVal('1', map, true) // => '2'

// or to get first and last
utils.first(map)    // => ['1', '1']
utils.firstKey(map) // => '1'
utils.firstVal(map) // => '1'

utils.last(map)     // => ['2', '2']
utils.lastKey(map)  // => '2'
utils.lastVal(map)  // => '2'

// Replace the key with another key, but keep the value
utils.replace('2', '10', map)
console.log(map.get('10'))
// => '2'
```

## Test

```bash
$ npm test
```

## Author

Evan Lucas

## License

MIT (See `LICENSE` for more info)

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