# fuzzytrie

> Dynamic word set with accelerated exact and fuzzy search based on trie data structure.

Latest version **1.0.1** (published 2016-12-02) · WTFPL license · 0 weekly downloads

## Install

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

## 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 | 2016-12-02 |
| First published | 2016-12-01 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Sergey Fedotov |
| Maintainers | sergeyfromhell |
| Keywords | search, trie, words, set, fuzzy, unrestricted, damerau, levenshtein |

## Links

- npm: https://www.npmjs.com/package/fuzzytrie
- Repository: https://github.com/SergeyFromHell/fuzzytrie
- Homepage: https://github.com/SergeyFromHell/fuzzytrie#readme
- Issues: https://github.com/SergeyFromHell/fuzzytrie/issues
- npm.io page: https://npm.io/package/fuzzytrie

## 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

- 1.0.1 (latest) — 2016-12-02
- 1.0.0 — 2016-12-01

## README

## fuzzytrie

Dynamic word set with accelerated exact and fuzzy search based on trie data structure.

## Usage

### Create FuzzyTrie
FuzzyTrie constructor has no parameters:
```js
var FuzzyTrie = require('fuzzytrie');

var trie = new FuzzyTrie();
```

### Insert
To insert into the trie use "add" method with single argument:
```js
trie.add('hello');
```

### Remove
Use "delete" method to remove a word from the trie:
```js
trie.delete('hello');
```

### Check existence
Use "has" to detemine that trie contains a word:
```js
trie.add('word');
var b = trie.has('word'); // b == true
trie.delete('word');
b = trie.has('word'); // b == false
```

### Search
Although you can use "has" to do exact search, there is also a method called "find" that can be used to find all words in the trie that "approximately" equals to the given word.
In fact, "find" implements fuzzy search with [UNRESTRICTED Damerau-Levenshtein Distance](https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance) metric.
It's accelerated with underlying trie data structure so it's performance is sublinear (in terms of number of words inside the trie).
Maximal distance from given word is passed with second parameter of "find". It returns JavaScript Object with words within given maximal distance as keys and their distances as values.
If there are no words in the trie within given distance, it returns empty Object({}).
```js
var maxDistance = 2;
var result = trie.find('hello',maxDistance);
// result == { <word1>: <distance from 'hello' to word1>, <word2>: <distance from 'hello' to word2>,... };

```
You should remember that performance of the "find" method is critically depends on the maximal distance parameter.

### Clear
You can clear the trie with "clear" method:
```js
trie.clear();
```

### All
Array of all words contained in the trie can be acquired with "all".
```js
var a = trie.all();
// a = [...];
```

### Empty
You can check that trie does not contain any word with "empty" method:
```js
var b = trie.empty();
// b == true if trie is empty (has no words)
// else, b == false
```

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