MissPlete is a misspelling-tolerant autocomplete written in ECMAScript 2015, aka ECMAScript 6 (ES6).
npm install miss-pleteMissPlete is a misspelling-tolerant autocomplete written in ECMAScript 2015, aka
ECMAScript 6 (ES6).
It supports synonyms and it can be customized with any algorithm to select and
sort the completions. By default it uses a
Jaro–Winkler distance
algorithm, which allows for
better sloppy interaction
than the usual completion based on exact substring matches.
Less than 220 lines of code. No dependencies.
http://xavi.github.io/miss-plete
npm install miss-plete --save
The library is published to the npm registry transpiled to ES5 and UMD, so it can be used in ES5 (examples/es5/) and ES6 (examples/es6/).
``javascript
import MissPlete from './MissPlete.js';
new MissPlete({
input: document.querySelector('input[name="city"]'),
// Each subarray contains an option and all its synonyms
options: [["Barcelona", "BCN"], ["San Francisco", "SF"]],
// OPTIONAL
// It must return an object with at least the properties score and displayValue
// .${optionSynonyms[0]} (${score})
// Default is a Jaro–Winkler similarity function.
scoreFn: (inputValue, optionSynonyms) => {
// Crazy random example
const score = Math.random();
return { score: score, displayValue: };
},
// OPTIONAL
// Called for each scored option, in order, starting with the one with the
// greatest score. It's passed the scored option (as returned by scoreFn)
// and its index in the score-sorted list. It must return the
Copyright © 2015 Xavi Caballé
Licensed under the MIT License.