{"id":13393527,"url":"https://github.com/foray1010/didyoumean2","last_synced_at":"2025-04-08T12:08:00.770Z","repository":{"id":37623081,"uuid":"48904055","full_name":"foray1010/didyoumean2","owner":"foray1010","description":"a library for matching human-quality input to a list of potential matches using the Levenshtein distance algorithm","archived":false,"fork":false,"pushed_at":"2025-04-01T05:26:20.000Z","size":8982,"stargazers_count":102,"open_issues_count":4,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-01T06:27:08.350Z","etag":null,"topics":["edit-distance","fuzzy-search","levenshtein-distance","spelling-correction","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foray1010.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-02T08:45:12.000Z","updated_at":"2025-04-01T05:25:52.000Z","dependencies_parsed_at":"2023-10-16T16:46:09.782Z","dependency_job_id":"107a50b7-02a9-44de-8952-b3df5538b218","html_url":"https://github.com/foray1010/didyoumean2","commit_stats":{"total_commits":1724,"total_committers":9,"mean_commits":"191.55555555555554","dds":0.4153132250580046,"last_synced_commit":"0b66d0c1cda1837f3f5b1a67f272138c0093b515"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foray1010%2Fdidyoumean2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foray1010%2Fdidyoumean2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foray1010%2Fdidyoumean2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foray1010%2Fdidyoumean2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foray1010","download_url":"https://codeload.github.com/foray1010/didyoumean2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247838444,"owners_count":21004580,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["edit-distance","fuzzy-search","levenshtein-distance","spelling-correction","typescript"],"created_at":"2024-07-30T17:00:55.244Z","updated_at":"2025-04-08T12:08:00.740Z","avatar_url":"https://github.com/foray1010.png","language":"TypeScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# didyoumean2\n\n[![Build Status](https://img.shields.io/circleci/project/foray1010/didyoumean2/master.svg)](https://circleci.com/gh/foray1010/didyoumean2/tree/master)\n[![codecov.io](https://img.shields.io/codecov/c/github/foray1010/didyoumean2.svg)](https://codecov.io/gh/foray1010/didyoumean2)\n\n[![node](https://img.shields.io/node/v/didyoumean2.svg)](https://www.npmjs.com/package/didyoumean2)\n[![npm](https://img.shields.io/npm/dm/didyoumean2.svg)](https://www.npmjs.com/package/didyoumean2)\n[![npm](https://img.shields.io/npm/l/didyoumean2.svg)](https://www.npmjs.com/package/didyoumean2)\n\n`didyoumean2` is a library for matching human-quality input to a list of potential matches using the [Levenshtein distance algorithm](https://en.wikipedia.org/wiki/Levenshtein_distance).\nIt is inspired by [didyoumean.js](https://github.com/dcporter/didyoumean.js).\n\n## Why reinventing the wheel\n\n1. Based on [fastest-levenshtein](https://github.com/ka-weihe/fastest-levenshtein), the fastest JS implementation of the [Levenshtein distance algorithm](https://en.wikipedia.org/wiki/Levenshtein_distance)\n\n1. ~100% faster than [didyoumean.js](https://github.com/dcporter/didyoumean.js)\n\n1. Well tested with 100% coverage\n\n1. Static type checking with [TypeScript](https://github.com/Microsoft/TypeScript)\n\n1. More control on what kind of matches you want to return\n\n1. Support matching object's `path` instead of just `key`\n\n## Installation\n\n```sh\nnpm install didyoumean2\n```\n\n```js\nconst didYouMean = require('didyoumean2').default\n// or if you are using TypeScript or ES module\nimport didYouMean from 'didyoumean2'\n\n// you can also access to Enums via:\nconst {\n  default: didYouMean,\n  ReturnTypeEnums,\n  ThresholdTypeEnums,\n} = require('didyoumean2')\n// or\nimport didYouMean, { ReturnTypeEnums, ThresholdTypeEnums } from 'didyoumean2'\n```\n\n## Development Setup\n\nWe are using [corepack](https://nodejs.org/api/corepack.html) to manage the `yarn` version\n\n```bash\ncorepack enable\n```\n\n## Usage\n\n```js\ndidYouMean(input, matchList[, options])\n```\n\n- `input {string}`: A string that you are not sure and want to match with `matchList`\n\n- `matchList {Object[]|string[]}`: A List for matching with `input`\n\n- `options {Object}`(optional): An options that allows you to modify the behavior\n\n- `@return {Array|null|Object|string}`: A list of or single matched result(s), return object if `match` is `{Object[]}`\n\n### Options\n\n#### `caseSensitive {boolean}`\n\n- default: `false`\n\n- Perform case-sensitive matching\n\n#### `deburr {boolean}`\n\n- default: `true`\n\n- Perform [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) insensitive matching\n\n- Refer to [lodash \\_.deburr](https://lodash.com/docs#deburr) for how it works\n\n#### `matchPath {Array}`\n\n- default: `[]`\n\n- If your `matchList` is an array of object, you must use `matchPath` to point to the string that you want to match\n\n- Refer to [ramda R.path](https://ramdajs.com/docs/#path) for how to define the path, e.g. `['obj', 'array', 0, 'key']`\n\n#### `returnType {string}`\n\n- default: `ReturnTypeEnums.FIRST_CLOSEST_MATCH`\n\n| returnType                            | Description                                                       |\n| ------------------------------------- | ----------------------------------------------------------------- |\n| `ReturnTypeEnums.ALL_CLOSEST_MATCHES` | Return all matches with the closest value to the `input` in array |\n| `ReturnTypeEnums.ALL_MATCHES`         | Return all matches in array                                       |\n| `ReturnTypeEnums.ALL_SORTED_MATCHES`  | Return all matches in array, sorted from closest to furthest      |\n| `ReturnTypeEnums.FIRST_CLOSEST_MATCH` | Return first match from `ReturnTypeEnums.ALL_CLOSEST_MATCHES`     |\n| `ReturnTypeEnums.FIRST_MATCH`         | Return first match (**FASTEST**)                                  |\n\n#### `threshold {integer|number}`\n\n- depends on `thresholdType`\n\n- type: `{number}` (`similarity`) or `{integer}` (`edit-distance`)\n\n- default: `0.4` (`similarity`) or `20` (`edit-distance`)\n\n- If the result is larger (`similarity`) or smaller (`edit-distance`) than or equal to the `threshold`, that result is matched\n\n#### `thresholdType {string}`\n\n- default: `ThresholdTypeEnums.SIMILARITY`\n\n| thresholdType                      | Description                                                                                                                                      |\n| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `ThresholdTypeEnums.EDIT_DISTANCE` | Refer to [Levenshtein distance algorithm](https://en.wikipedia.org/wiki/Levenshtein_distance), must be `integer`, lower value means more similar |\n| `ThresholdTypeEnums.SIMILARITY`    | `l = max(input.length, matchItem.length), similarity = (l - editDistance) / l`, `number` from `0` to `1`, higher value means more similar        |\n\n#### `trimSpaces {boolean}`\n\n- default: `true`\n\n- Remove noises when matching\n\n- Trim all starting and ending spaces, and concatenate all continuous spaces to one space\n\n## Test\n\n**_Before all:_**\n\n```sh\nnpm install -g yarn\nyarn install\n```\n\nUnit test and coverage:\n\n```sh\nyarn test\n```\n\nLinter:\n\n```sh\nyarn lint\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforay1010%2Fdidyoumean2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforay1010%2Fdidyoumean2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforay1010%2Fdidyoumean2/lists"}