https://github.com/experience-monks/typing-ahead
A lightweight library to build data model for typeahead feature
https://github.com/experience-monks/typing-ahead
autocomplete lightweight logarithmic-complexity modular typeahead
Last synced: about 1 year ago
JSON representation
A lightweight library to build data model for typeahead feature
- Host: GitHub
- URL: https://github.com/experience-monks/typing-ahead
- Owner: Experience-Monks
- License: mit
- Created: 2020-08-27T14:32:43.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-22T16:37:00.000Z (about 4 years ago)
- Last Synced: 2025-05-09T19:21:42.195Z (about 1 year ago)
- Topics: autocomplete, lightweight, logarithmic-complexity, modular, typeahead
- Language: JavaScript
- Homepage:
- Size: 481 KB
- Stars: 6
- Watchers: 25
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README

> A lightweight library to build data model for typeahead feature
[](https://snyk.io/test/github/Jam3/typing-ahead?targetFile=package.json) [](https://github.com/Jam3/typing-ahead/blob/master/LICENSE)
[](https://nodei.co/npm/typing-ahead/)
# 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](https://github.com/Jam3/nyg-nextjs)

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