Skip to content

zacharyhamm/completer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A ternary search trie modified to support autocompletion suggestions.

It's kind of like a binary search tree with lexical ordering. Best case O(log n) lookups, and space requirements not significantly greater than the array of completions itself.

Construct with an array of strings:

const Completer = require('trie-completer');

let completer = new Completer([
    'a', 'aa', 'aaab', 'abc', 'def'
]);

Then you can get the completions for a prefix via completer.getCompletions(prefix) Completions will be sorted in ascending lexical order.

See Sedgewick & Wayne, Algorithms, 4th edition, Section 5.2

About

A trie-based javascript autocompleter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published