# jaro-winkler

> A string similarity function using the Jaro-Winkler distance metric.

Latest version **0.2.8** (published 2016-10-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install jaro-winkler
pnpm add jaro-winkler
yarn add jaro-winkler
bun add jaro-winkler
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.8 |
| Published | 2016-10-04 |
| First published | 2015-02-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/jaro-winkler) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 85 |
| Author | Jordan Thomas |
| Maintainers | jordanthomas |
| Keywords | distance, metric, jaro, winkler, jaro-winkler, compare |

## Links

- npm: https://www.npmjs.com/package/jaro-winkler
- Repository: https://github.com/jordanthomas/jaro-winkler
- Issues: https://github.com/jordanthomas/jaro-winkler/issues
- npm.io page: https://npm.io/package/jaro-winkler

## Recent versions

- 0.2.8 (latest) — 2016-10-04
- 0.2.7 — 2016-07-25
- 0.2.6 — 2015-05-07
- 0.2.5 — 2015-05-07
- 0.2.4 — 2015-03-06
- 0.2.3 — 2015-02-28
- 0.2.2 — 2015-02-25
- 0.2.1 — 2015-02-16
- 0.2.0 — 2015-02-13
- 0.1.2 — 2015-02-11
- 0.1.1 — 2015-02-11
- 0.1.0 — 2015-02-11

## README

# Jaro-Winkler

A string similarity function using the Jaro-Winkler distance metric. Returns a
number between 0 and 1. A 0 being no similarity and a 1 being an exact match.

Read more about it [on Wikipedia](http://en.wikipedia.org/wiki/Jaro–Winkler_distance).

## Install

Install in your Node project using npm as usual; `npm install jaro-winkler`. It
also works in the browser, just include the source within `index.js` in your
project however you prefer. Note that the `distance` function will be added to
the global scope if it's not included with a tool like [Browserify](http://browserify.org).

## Example Usage

```
var distance = require('jaro-winkler');

distance('MARTHA', 'MARHTA');
// 0.961

distance('DWAYNE', 'DUANE');
// 0.84

distance('DIXON', 'DICKSONX');
// 0.814


// Case Insensitive

distance('MARTHA', 'MARTHA');
// 1

distance('mArThA', 'MaRtHa', { caseSensitive: false });
// 1
```

## Sample App

Here's contrived sample of how you might utilize a distance metric in your own
app. This shows how you might offer a helpful message when a user fat-fingers a
command.

```
#!/usr/bin/env node

'use strict';

var distance = require('jaro-winkler');
var commands = ['open', 'close', 'save', 'revert', 'select', 'copy', 'duplicate', 'add', 'subtract'];
var rated    = [];
var args     = process.argv.slice(2);

commands.forEach(function(command) {
  rated.push({
    command: command,
    distance: distance(args[0], command)
  });
});

rated.sort(function(a, b) {
  if (a.distance < b.distance) {
    return 1;
  } else if (a.distance > b.distance) {
      return -1;
  } else {
    return 0;
  }
});

if (rated[0].distance === 1) {
  console.log("Running " + rated[0].command + "!");
} else {
  console.log("Did you mean " + rated[0].command + "?");
}

process.exit(0);
```

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