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

ion-ezautocomplete

v1.0.5

Published

This is a standard JavaScript (as well as Node requiriable) class that adds super easy auto completion to your input elements.

Downloads

2

Readme

AutoComplete

This is a standard JavaScript (as well as Node requiriable) class that adds super easy auto completion to your input elements.

npm
Github

Implementation

Standard Webpage JavaScript

If you are using this for a website and standard JavaScript in general, just add it to your header tag as any other script:

<header>
  <script src="ion-ezautocomplete.js"></script>
</header>

Node.js module

If you are using Node.js with Electron or something else that supports using a browser with Node.js, you can also add it as a module instead. First install it with npm i ion-ezautocomplete and then require it in your javascript file.

// Using {} when requiring only exports the AutoComplete class, which is the only thing you'll need as of right now.
const {AutoComplete} = require("ion-ezautocomplete");

If you prefer calling the class something shorter or just something else entirely, you can do that in the require statement.
Example: I would write this if I want to call it AC instead.

const {AutoComplete: AC} = require("ion-ezautocomplete");

Getting started

Adding autocompletion is as easy as 1 line of code to get started.

const instance = new AutoComplete(document.querySelector("YourInput"), ["Autocompletes"]);
// Or it can also be done using the static AutoComplete.add() function
const instance = AutoComplete.add(document.querySelector("YourInput"), ["Autocompletes"]);

AutoComplete's constructor takes 2 arguments: inputElement and completions.
Using AutoComplete.add() is completely identical to using new Autocomplete().

/**
  * Initialize an object and activate autocomplete.
  * @param {HTMLInputElement} inputElement Element to watch and autocomplete.
  * @param {string[]} completions Completions that this input box can autocomplete to. You can always add or remove by just modifying the ``completions`` variable of an instance.
  */
new AutoComplete(inputElement, completions = []);

You can easily add more dynamically by using the array push(string) function.

const ac = new AutoComplete(inputElement, completions = []);
ac.completions.push("Any new completion");

Array of completions

AutoComplete instances has an array variable called completions. You can add and remove autocompletion strings dynamically by editing this.
Default: []

/**
  * List of words and sentences available for autocompletions.
  * This list is automatically sorted by shortest to longest string when executed.
  * @type {string[]}
  */
completions = [];

Enabled/Disabled

You can disabled autocompletion temporarily until re-enabled by modifying the enabled variable.
Default: true

/**
  * The current state of activation. If ``true``, autocompletion will happen
  */
enabled = true;

Case Sensitivity

You can toggle case sensitivity by modifying the caseSensitive variable.
Default: false

/**
  * If the autocompletion should be case sensitive.
  */
caseSensitive = false;

Tab Fill

You can toggle between if the Tab button fills the autocompletion or not by editing the tabFill variable.
Default: true

/**
  * When ``Tab`` is press and an autocompletion is present, should it fill instead of tab stopping?
  */
tabFill = true;

Minimum Characters

You can limit that the autocompletions should only be suggested if the input is more than a specified count of characters. You can set the instance variable minChars to the number of characters you minimum want the user to write before it starts suggesting.
Default: 1

/**
  * The minimum about of characters in a string or word to begin suggesting autocompletions.
  */
minChars = 1;

Word Separator

AutoComplete instances also carry a separateBy variable.
By default this is space but can be set to any string. Space is the most logical thing to separate words by and therefore recommend to keep default.

Default: " "

/**
  * The character to separate words by.
  */
separateBy = " ";

Known supported element types

<input>
<textarea></textarea> <!-- Multiline supported! -->

Go ahead and try it in action, it's super simple.