# suggestSimilar

**Kind:** Function

**Source:** [`lib/suggestSimilar.js`](https://github.com/tj/commander.js/blob/main/lib/suggestSimilar.js#L56)

Find close matches, restricted to same number of edits.

`suggestSimilar` finds candidate values that closely match a given input while limiting results to candidates with the same edit distance. It supports suggestion flows where nearby alternatives should be returned without mixing candidates from different edit-distance groups.

## Signature

```ts
function suggestSimilar(word, candidates)
```

## Parameters

| Name | Type |
|---|---|
| `word` | `any` |
| `candidates` | `any` |

## Diagram

```mermaid
graph LR
  Input[Input value] --> Suggest[suggestSimilar]
  Candidates[Candidate values] --> Suggest
  Suggest --> Filter[Filter by matching edit distance]
  Filter --> Matches[Similar matches]
```

## Usage

```js
const suggestSimilar = require('./lib/suggestSimilar');

const input = 'colour';
const candidates = ['color', 'collar', 'column'];

const matches = suggestSimilar(input, candidates);

console.log(matches);
```

## AI Coding Instructions

- Keep candidate values in the format expected by existing callers before passing them to `suggestSimilar`.
- Preserve the edit-distance restriction when changing matching behavior; do not combine results from different distance groups.
- Check existing tests and call sites before changing the function’s return shape or ordering.
- Use `suggestSimilar` for suggestion output rather than duplicating edit-distance filtering in callers.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (1)

- `Command` — `lib/command.js`:14
