# wildmap

> A path based map with wildcard matching.

Latest version **1.0.3** (published 2018-01-17) · MIT license · 0 weekly downloads

## Install

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

## 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.3 |
| Published | 2018-01-17 |
| First published | 2015-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Alan Gutierrez |
| Maintainers | bigeasy |
| Keywords | bluey, map, path, wildcard |

## Links

- npm: https://www.npmjs.com/package/wildmap
- Repository: https://github.com/bigeasy/wildmap
- Issues: https://github.com/bigeasy/wildmap/issues
- npm.io page: https://npm.io/package/wildmap

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2018-01-17
- 2.0.0-alpha.2 (canary) — 2022-02-07
- 2.0.0-alpha.1 — 2021-10-22
- 2.0.0-alpha.0 — 2021-10-21
- 1.0.2 — 2017-12-15
- 1.0.1 — 2017-04-06
- 1.0.0 — 2016-01-21
- 0.0.2 — 2015-11-29
- 0.0.1 — 2015-11-26
- 0.0.0 — 2015-11-15

## README

A path map with wild card matching.

### Synopsis

WildMap is a multimap that maps keys to multiple values. When queried, the
values are returned as an array of values for the key.

Keys used for lookup can be applied directly using `get` to get an array of
values that exactly match that key.

Keys used for lookup can also be applied as wildcard matches using `gather` to
get an array of values that are found along the path described by the key.

```javascript
var assert = require('assert')
var WildMap = require('wildmap')

var map = new WildMap

map.add('.hello.world'.split('.'), 'hello, world one')
map.add('.hello.world'.split('.'), 'hello, world two')
map.add('.hello.earth'.split('.'), 'hello, earth')
map.add('.*.earth'.split('.'), 'star, earth')
map.add('.hello'.split('.'), 'hello, anyone')
map.add('.'.split('.'), 'root')


assert.deepEqual(map.get('.hello.world'.split('.')), [
    'hello, world one', 'hello, world two'
])

assert.deepEqual(map.match('.hello.world'.split('.')), [
    'root', 'hello, anyone', 'hello, world one', 'hello, world two'
])

assert.deepEqual(map.match('.hello.earth'.split('.')), [
    'root', 'hello, anyone', 'star, earth', 'hello, earth'
])

map.remove('.hello.world'.split('.'), 'hello, world one')

assert.deepEqual(map.match('.hello.world'.split('.')), [
    'root', 'hello, anyone', 'hello, world two'
])
```

This structure is useful for messaging. For a practical application see
[Signal](https://github.com/bigeasy/signal).


#### `map = new WildMap`

Create a new empty map.

#### `map.add(path, value)`

Add a value to the set of values at the given path.

#### `map.get(path)`

Get the set of values at the given path.

#### `map.match(pattern)`

Get a collection of all the values along the given path.

#### `map.remove(path, value)`

Remove the value if it is contained by the set at the given path.

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