{"name":"didyoumean2","version":"7.0.0","keywords":["closest","compare","comparison","didyoumean","diff","difference","distance","edit","find","fuzzy","leven","levenshtein","match","matching","similar","similarity","string","suggest","suggestion","text","typescript","word"],"author":{"name":"foray1010"},"license":"MIT","_id":"didyoumean2@7.0.0","maintainers":[{"name":"foray1010","email":"carmine-0-bulrush@icloud.com"}],"homepage":"https://github.com/foray1010/didyoumean2","bugs":{"url":"https://github.com/foray1010/didyoumean2/issues"},"dist":{"shasum":"31c31321163018712cf933fcedc1ff5127cc50af","tarball":"http://registry-npm.ywwl.com/didyoumean2/download/didyoumean2-7.0.0.tgz","fileCount":10,"integrity":"sha512-X6xeJwuw3StMFSnoY4Ya1ppwtvV17ZcUGllElMINIf/M6xI61jQKHGM4fStTS8AtLUIBU3/9xbS7xV8p/T5O8g==","signatures":[{"sig":"MEUCIQCMlnyLuNt2CYys3wjqIOqqJBu/gsDZl9SdlsoLgh+byAIgTP9tZkSJ0K/eEhZMwdsmgHU1RbzD6Zqm6soOIhExzoE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":55375,"size":12579,"noattachment":false,"key":"/didyoumean2/-/didyoumean2-7.0.0.tgz"},"type":"module","$schema":"https://json.schemastore.org/package","engines":{"node":"^18.12.0 || >=20.9.0"},"exports":{"types":{"import":"./dist/index.d.mts","require":"./dist/index.d.ts"},"import":"./dist/index.mjs","require":"./dist/index.cjs"},"gitHead":"8f23d6c27ca454f03d63d8cf4845f9dbe1babc0f","scripts":{"ci":"yarn build && npm-run-all -p 'lint:*' 'type:*' && yarn test && size-limit","lint":"npm-run-all -p 'lint:*'","test":"jest","build":"yarn clean:build && tsc --project tsconfig.build.json && rollup --configPlugin \"babel={ babelHelpers: 'runtime', extensions: ['.js', '.ts'] }\" -c","remark":"remark --frail --ignore-path=node_modules/@foray1010/remark-preset/remarkignore --ignore-path-resolve-from=cwd --silently-ignore","lint:js":"eslint .","lint:md":"yarn remark .","prettier":"prettier --ignore-path=node_modules/@foray1010/prettier-config/prettierignore","type:check":"tsc","clean:build":"shx rm -rf dist/ build/dts/","type:coverage":"type-coverage --strict --at-least 99 --detail --ignore-catch"},"_npmUser":{"name":"foray1010","email":"carmine-0-bulrush@icloud.com"},"repository":{"url":"git+https://github.com/foray1010/didyoumean2.git","type":"git"},"_npmVersion":"10.8.2","description":"a library for matching human-quality input to a list of potential matches using the Levenshtein distance algorithm","directories":{},"sideEffects":false,"_nodeVersion":"18.20.4","dependencies":{"lodash.deburr":"^4.1.0","@babel/runtime":"^7.24.8","fastest-levenshtein":"^1.0.16"},"_hasShrinkwrap":false,"packageManager":"yarn@4.3.1","devDependencies":{"shx":"0.3.4","jest":"29.7.0","eslint":"8.57.0","rollup":"4.19.0","prettier":"3.3.3","remark-cli":"12.0.1","size-limit":"11.1.4","typescript":"5.5.3","@babel/core":"7.24.9","@types/jest":"29.5.12","ignore-sync":"7.0.1","lint-staged":"15.2.7","npm-run-all2":"6.2.2","node-notifier":"10.0.1","type-coverage":"2.29.1","@commitlint/cli":"19.3.0","rollup-plugin-dts":"6.1.1","@foray1010/tsconfig":"12.1.0","@rollup/plugin-babel":"6.0.4","@types/lodash.deburr":"4.1.9","@rollup/plugin-terser":"0.4.4","@foray1010/jest-preset":"5.1.0","@foray1010/babel-preset":"10.0.0","@rollup/plugin-commonjs":"26.0.1","@foray1010/eslint-config":"12.3.0","@foray1010/remark-preset":"10.0.1","@foray1010/prettier-config":"11.0.1","@rollup/plugin-node-resolve":"15.2.3","@size-limit/preset-small-lib":"11.1.4","@commitlint/config-conventional":"19.2.2"},"_npmOperationalInternal":{"tmp":"tmp/didyoumean2_7.0.0_1721571876244_0.7041650328068321","host":"s3://npm-registry-packages"},"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","publish_time":1721571876433,"_cnpm_publish_time":1721571876433,"dist-tags":{"latest":"7.0.4","prerelease":"2.0.0-1"}}