typing-ahead
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Logo

A lightweight library to build data model for typeahead feature

Known Vulnerabilities GitHub license

NPM

typing-ahead

This is a lightweight module for generating a data model to perform typeahead or autocomplete task in logarithmic time.

It has two public methods:

  • generate: Lets you generate a data model consists of words
  • find: Finds the closest match of the input word within the provided model

Get Started

  1. Import the module onto your project and build the data model by passing an array of words

  2. Pass the model and some characters to the find function to get results

Example

const typingAhead = require('typing-ahead');

const myModel = typingAhead.generate(['typingahead', 'autocomplete']);
const results = typingAhead.find('typing', myModel); // result ['typingahead']

This example is made with Jam3 NextJS Generator Example

Unit Test

There are some test cases provided in ./__test__/index.test.js to ensure that the data model is built correctly.

npm test

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i typing-ahead

    Weekly Downloads

    2

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    113 kB

    Total Files

    23

    Last publish

    Collaborators

    • hperigo
    • gabroell
    • josdelgaur
    • jam3dev
    • njam3
    • iranreyes
    • namniak
    • donghyukjang
    • alemesa
    • neoli
    • colin-j3
    • jmckinnell
    • n0wak
    • amelierosser
    • artemleznikov
    • jeffong