npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

miss-plete-js

v1.4.5

Published

This repository is forked from the original to quickly integrate with out styling.

Downloads

5

Readme

MissPlete

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.

Demo

http://xavi.github.io/miss-plete

Installation

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/).

Usage

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;
  }
});

License

Copyright © 2015 Xavi Caballé

Licensed under the MIT License.