{"_id":"didyoumean","_rev":"382507","name":"didyoumean","description":"Match human-quality input to potential matches by edit distance.","dist-tags":{"latest":"1.2.2"},"maintainers":[{"name":"dcporter","email":"dcporter@gmail.com"}],"time":{"modified":"2021-08-04T02:27:25.000Z","created":"2013-01-19T21:53:33.778Z","1.2.2":"2021-06-24T14:00:09.748Z","1.2.1":"2014-09-14T22:33:36.668Z","1.2.0":"2014-03-16T02:12:02.695Z","1.1.0":"2013-01-19T21:53:33.778Z"},"users":{"techscientist":true,"rocket0191":true,"programmer5000":true},"author":{"name":"Dave Porter","email":"dcporter@gmail.com","url":"http://dcporter.net/"},"repository":{"type":"git","url":"git+https://github.com/dcporter/didyoumean.js.git"},"versions":{"1.2.2":{"name":"didyoumean","version":"1.2.2","description":"Match human-quality input to potential matches by edit distance.","homepage":"https://github.com/dcporter/didyoumean.js","author":{"name":"Dave Porter","email":"dcporter@gmail.com","url":"http://dcporter.net/"},"keywords":["didyoumean","mean","edit","distance","levenshtein"],"main":"./didYouMean-1.2.1.js","repository":{"type":"git","url":"git+https://github.com/dcporter/didyoumean.js.git"},"bugs":{"url":"https://github.com/dcporter/didyoumean.js/issues"},"license":"Apache-2.0","gitHead":"f58cc8d9d3d127f31aa88b9e23b6daf4ead34abb","_id":"didyoumean@1.2.2","_nodeVersion":"12.18.0","_npmVersion":"6.14.4","dist":{"shasum":"989346ffe9e839b4555ecf5666edea0d3e8ad037","size":4571,"noattachment":false,"key":"/didyoumean/-/didyoumean-1.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/didyoumean/download/didyoumean-1.2.2.tgz"},"_npmUser":{"name":"dcporter","email":"dcporter@gmail.com"},"directories":{},"maintainers":[{"name":"dcporter","email":"dcporter@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/didyoumean_1.2.2_1624543209601_0.5660588049172106"},"_hasShrinkwrap":false,"publish_time":1624543209748,"_cnpm_publish_time":1624543209748},"1.2.1":{"name":"didyoumean","version":"1.2.1","description":"Match human-quality input to potential matches by edit distance.","homepage":"https://github.com/dcporter/didyoumean.js","author":{"name":"Dave Porter","email":"dcporter@gmail.com","url":"http://dcporter.net/"},"keywords":["didyoumean","mean","edit","distance","levenshtein"],"main":"./didYouMean-1.2.1.js","repository":{"type":"git","url":"https://github.com/dcporter/didyoumean.js.git"},"bugs":{"url":"https://github.com/dcporter/didyoumean.js/issues"},"license":"Apache","_id":"didyoumean@1.2.1","dist":{"shasum":"e92edfdada6537d484d73c0172fd1eba0c4976ff","size":4565,"noattachment":false,"key":"/didyoumean/-/didyoumean-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/didyoumean/download/didyoumean-1.2.1.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"dcporter","email":"dcporter@gmail.com"},"maintainers":[{"name":"dcporter","email":"dcporter@gmail.com"}],"directories":{},"publish_time":1410734016668,"_cnpm_publish_time":1410734016668,"_hasShrinkwrap":false},"1.2.0":{"name":"didyoumean","version":"1.2.0","description":"Match human-quality input to potential matches by edit distance.","homepage":"https://github.com/dcporter/didyoumean.js","author":{"name":"Dave Porter","email":"dcporter@gmail.com","url":"http://dcporter.net/"},"keywords":["didyoumean","mean","edit","distance","levenshtein"],"main":"./didYouMean-1.2.0.js","repository":{"type":"git","url":"https://github.com/dcporter/didyoumean.js.git"},"bugs":{"url":"https://github.com/dcporter/didyoumean.js/issues"},"license":"Apache","_id":"didyoumean@1.2.0","dist":{"shasum":"71256ddd39ff77af2c9aa65598737b1e94ec3751","size":4550,"noattachment":false,"key":"/didyoumean/-/didyoumean-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/didyoumean/download/didyoumean-1.2.0.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"dcporter","email":"dcporter@gmail.com"},"maintainers":[{"name":"dcporter","email":"dcporter@gmail.com"}],"directories":{},"publish_time":1394935922695,"_cnpm_publish_time":1394935922695,"_hasShrinkwrap":false},"1.1.0":{"name":"didyoumean","version":"1.1.0","description":"Match human-quality input to potential matches by edit distance.","homepage":"https://github.com/dcporter/didyoumean.js","author":{"name":"Dave Porter","email":"dcporter@gmail.com","url":"http://dcporter.net/"},"keywords":["didyoumean","mean","edit","distance","levenshtein"],"main":"./didYouMean-1.1.0.js","repository":{"type":"git","url":"https://github.com/dcporter/didyoumean.js"},"bugs":{"url":"https://github.com/dcporter/didyoumean.js/issues"},"license":"Apache","_id":"didyoumean@1.1.0","dist":{"shasum":"45668d70f92624249451ee264c4072ec28a7e226","size":4525,"noattachment":false,"key":"/didyoumean/-/didyoumean-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/didyoumean/download/didyoumean-1.1.0.tgz"},"_npmVersion":"1.1.59","_npmUser":{"name":"dcporter","email":"dcporter@gmail.com"},"maintainers":[{"name":"dcporter","email":"dcporter@gmail.com"}],"directories":{},"publish_time":1358632413778,"_cnpm_publish_time":1358632413778,"_hasShrinkwrap":false}},"readme":"didYouMean.js - A simple JavaScript matching engine\n===================================================\n\n[Available on GitHub](https://github.com/dcporter/didyoumean.js).\n\nA super-simple, highly optimized JS library for matching human-quality input to a list of potential\nmatches. You can use it to suggest a misspelled command-line utility option to a user, or to offer\nlinks to nearby valid URLs on your 404 page. (The examples below are taken from a personal project,\nmy [HTML5 business card](http://dcporter.aws.af.cm/me), which uses didYouMean.js to suggest correct\nURLs from misspelled ones, such as [dcporter.aws.af.cm/me/instagarm](http://dcporter.aws.af.cm/me/instagarm).)\nUses the [Levenshtein distance algorithm](https://en.wikipedia.org/wiki/Levenshtein_distance).\n\ndidYouMean.js works in the browser as well as in node.js. To install it for use in node:\n\n```\nnpm install didyoumean\n```\n\n\nExamples\n--------\n\nMatching against a list of strings:\n```\nvar input = 'insargrm'\nvar list = ['facebook', 'twitter', 'instagram', 'linkedin'];\nconsole.log(didYouMean(input, list));\n> 'instagram'\n// The method matches 'insargrm' to 'instagram'.\n\ninput = 'google plus';\nconsole.log(didYouMean(input, list));\n> null\n// The method was unable to find 'google plus' in the list of options.\n```\n\nMatching against a list of objects:\n```\nvar input = 'insargrm';\nvar list = [ { id: 'facebook' }, { id: 'twitter' }, { id: 'instagram' }, { id: 'linkedin' } ];\nvar key = 'id';\nconsole.log(didYouMean(input, list, key));\n> 'instagram'\n// The method returns the matching value.\n\ndidYouMean.returnWinningObject = true;\nconsole.log(didYouMean(input, list, key));\n> { id: 'instagram' }\n// The method returns the matching object.\n```\n\n\ndidYouMean(str, list, [key])\n----------------------------\n\n- str: The string input to match.\n- list: An array of strings or objects to match against.\n- key (OPTIONAL): If your list array contains objects, you must specify the key which contains the string\n  to match against.\n\nReturns: the closest matching string, or null if no strings exceed the threshold.\n\n\nOptions\n-------\n\nOptions are set on the didYouMean function object. You may change them at any time.\n\n### threshold\n\n  By default, the method will only return strings whose edit distance is less than 40% (0.4x) of their length.\n  For example, if a ten-letter string is five edits away from its nearest match, the method will return null.\n\n  You can control this by setting the \"threshold\" value on the didYouMean function. For example, to set the\n  edit distance threshold to 50% of the input string's length:\n\n  ```\n  didYouMean.threshold = 0.5;\n  ```\n\n  To return the nearest match no matter the threshold, set this value to null.\n\n### thresholdAbsolute\n\n  This option behaves the same as threshold, but instead takes an integer number of edit steps. For example,\n  if thresholdAbsolute is set to 20 (the default), then the method will only return strings whose edit distance\n  is less than 20. Both options apply.\n\n### caseSensitive\n\n  By default, the method will perform case-insensitive comparisons. If you wish to force case sensitivity, set\n  the \"caseSensitive\" value to true:\n\n  ```\n  didYouMean.caseSensitive = true;\n  ```\n\n### nullResultValue\n\n  By default, the method will return null if there is no sufficiently close match. You can change this value here.\n\n### returnWinningObject\n\n  By default, the method will return the winning string value (if any). If your list contains objects rather\n  than strings, you may set returnWinningObject to true.\n  \n  ```\n  didYouMean.returnWinningObject = true;\n  ```\n  \n  This option has no effect on lists of strings.\n\n### returnFirstMatch\n  \n  By default, the method will search all values and return the closest match. If you're simply looking for a \"good-\n  enough\" match, you can set your thresholds appropriately and set returnFirstMatch to true to substantially speed\n  things up.\n\n\nLicense\n-------\n\ndidYouMean copyright (c) 2013-2014 Dave Porter.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License\n[here](http://www.apache.org/licenses/LICENSE-2.0).\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","_attachments":{},"homepage":"https://github.com/dcporter/didyoumean.js","bugs":{"url":"https://github.com/dcporter/didyoumean.js/issues"},"license":"Apache-2.0"}