Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
miss-plete-js
Advanced tools
This repository is forked from the original to quickly integrate with out styling.
This repository is forked from the original to quickly integrate with out styling.
MissPlete 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-js --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/
).
import MissPlete from './MissPlete.js';
import './miss-plete-example.css';
new MissPlete({
input: document.querySelector('input[name="city"]'),
// Each subarray contains an option and all its synonyms
options: [["Barcelona", "BCN"], ["San Francisco", "SF"]],
// The class name for the dropdown. Ex. 'miss-plete'
className: 'miss-plete',
// OPTIONAL
// It must return an object with at least the properties `score` and
// `displayValue`.
// Default is a Jaro–Winkler similarity function.
scoreFn: (inputValue, optionSynonyms) => {
// Crazy random example
const score = Math.random();
return { score: score, displayValue: `${optionSynonyms[0]} (${score})` };
},
// 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 <li> node
// to display, or null if nothing else has to be displayed.
// Default returns <li> nodes for the 8 best-scored options.
listItemFn: (scoredOption, itemIndex) => {
const li = scoredOption.score < 0.5 ? null : document.createElement("li");
li && li.appendChild(document.createTextNode(scoredOption.displayValue));
return li;
}
});
Copyright © 2015 Xavi Caballé
Licensed under the MIT License.
FAQs
This repository is forked from the original to quickly integrate with out styling.
We found that miss-plete-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.