# prefix-matches

> Find matching keys in a given object, for a given prefix string

Latest version **1.0.1** (published 2017-05-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install prefix-matches
pnpm add prefix-matches
yarn add prefix-matches
bun add prefix-matches
```

## 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 | 2017-05-26 |
| First published | 2016-05-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Rowan Oulton |
| Maintainers | kentcdodds, rowanoulton |
| Keywords | prefix, autocomplete, object |

## Links

- npm: https://www.npmjs.com/package/prefix-matches
- Repository: https://github.com/rowanoulton/prefix-matches
- Homepage: https://github.com/rowanoulton/prefix-matches#readme
- Issues: https://github.com/rowanoulton/prefix-matches/issues
- npm.io page: https://npm.io/package/prefix-matches

## Dependencies (2)

- [is-object](https://npm.io/package/is-object.md) ^1.0.1
- [starts-with](https://npm.io/package/starts-with.md) ^1.0.2

## Recent versions

- 1.0.1 (latest) — 2017-05-26
- 1.0.0 — 2017-05-21
- 0.0.9 — 2016-05-03
- 0.0.8 — 2016-05-03
- 0.0.7 — 2016-05-03
- 0.0.6 — 2016-05-02
- 0.0.5 — 2016-05-02
- 0.0.4 — 2016-05-02
- 0.0.3 — 2016-05-02
- 0.0.2 — 2016-05-02
- 0.0.1 — 2016-05-02

## README

Prefix Matches
---

Find matching keys in a given object, for a given prefix string

**Warning**: experimental

## Installation

	npm i --save prefix-matches

then, in your scripts:

```js
const prefixMatches = require('prefix-matches')
```

## Example

```js
const prefixMatches = require('prefix-matches')

// Resolves simple cases
prefixMatches('w', {
	watch: 'watch things',
	build: 'build things'
}) // => [{ watch: 'watch things' }]

// Does not flatten result set
prefixMatches('w', {
	watch: {
		js: 'watch javascript',
		css: 'watch css'
	},
	build: 'build things'
}) // => [{ watch: { js: 'watch javascript', css: 'watch css' }}]

// Resolves nested prefixes
prefixMatches('w.j', {
	watch: {
		js: 'watch javascript',
		css: 'watch css'
	},
	write: {
		js: 'write javascript'
	}
}) // => [{ 'watch.js': 'watch javascript' }, { 'write.js': 'write javascript' }]

// ... and so on
prefixMatches('b.f.j', {
	build: {
		frontend: {
			js: 'build javascript',
			css: 'build css'
		}
	}
}) // => [{ 'build.frontend.js': 'build javascript' }]
```

## Why?

To attempt better prefixing support for the [package-scripts](https://github.com/kentcdodds/p-s) project.

## Tests

A basic test suite has been authored in [AVA](https://github.com/sindresorhus/ava), used for its terrifying speed. To run it:

	npm test

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