# leven-match

> Return all word matches between two arrays within given Levenshtein distance

Latest version **2.0.3** (published 2022-09-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install leven-match
pnpm add leven-match
yarn add leven-match
bun add leven-match
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2022-09-06 |
| First published | 2020-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 26.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Espen Klem |
| Maintainers | eklem |
| Keywords | search, fuzzy, match, levenshtein, distance |

## Links

- npm: https://www.npmjs.com/package/leven-match
- Repository: https://github.com/eklem/leven-match
- Homepage: https://github.com/eklem/leven-match#readme
- Issues: https://github.com/eklem/leven-match/issues
- npm.io page: https://npm.io/package/leven-match

## Dependencies (1)

- [leven](https://npm.io/package/leven.md) ^4.0.0

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 2.0.3 (latest) — 2022-09-06
- 2.0.2 — 2022-03-25
- 2.0.1 — 2021-11-24
- 1.0.5 — 2021-10-08
- 1.0.4 — 2021-10-05
- 1.0.3 — 2021-06-11
- 1.0.2 — 2020-12-18
- 1.0.0 — 2020-06-16

## README

# leven-match
Return all word matches between two arrays within given Levenshtein distance.

Intended use is to return all words in a query that has matches in an index within a given Levenshtein distance. Good for autocomplete type functionality, and in some cases also searching.

Part of [daq-proc](https://github.com/eklem/daq-proc) - Simple document and query processing for offline-first search.

[![NPM version][npm-version-image]][npm-url]
[![NPM downloads][npm-downloads-image]][npm-url]
[![](https://data.jsdelivr.com/v1/package/npm/leven-match/badge?style=rounded)](https://www.jsdelivr.com/package/npm/leven-match)
[![MIT License][license-image]][license-url]
[![Build Status][build-image]][build-url]
[![JavaScript Style Guide][standardjs-image]][standardjs-url]

## Breaking change

Importing/requiring script has changed slightly for CJS and ESM. UMD is as it was.

## Initiating

### UMD -  Universal module definition/browser
```javaScript
<script src="https://cdn.jsdelivr.net/npm/leven-match/dist/leven-match.umd.min.js"></script>
// lvm.levenMatch available
```

### CJS - CommonJS

```javaScript
const { levenMatch } = require('leven-match')
// levenMatch available
```

### ESM - Ecmascript module

```javaScript
import { levenMatch } from 'leven-match'
// levenMatch available
```


## Use

<script>
  const index = ['return', 'all', 'word', 'matches', 'between', 'two', 'arrays', 'within', 'given', 'levenshtein', 'distance', 'intended', 'use', 'is', 'to', 'words', 'in', 'a', 'query', 'that', 'has', 'an', 'index', 'good', 'for', 'autocomplete', 'type', 'functionality,', 'and', 'some', 'cases', 'also', 'searching']
  const query = ['qvery', 'words', 'levensthein']

  levenMatch(query, index, {distance: 2})
  // returns:
  //[ [ 'query' ], [ 'word', 'words' ], [ 'levenshtein' ] ]
</script>
```

Returns an array of arrays. One sub-array for each query word.


[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: LICENSE
[npm-url]: https://npmjs.org/package/leven-match
[npm-version-image]: https://img.shields.io/npm/v/leven-match.svg?style=flat
[npm-downloads-image]: https://img.shields.io/npm/dm/leven-match.svg?style=flat
[build-url]: https://github.com/eklem/leven-match/actions/workflows/tests.yml
[build-image]: https://github.com/eklem/leven-match/actions/workflows/tests.yml/badge.svg
[standardjs-url]: https://standardjs.com
[standardjs-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square

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