Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

trie-completer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trie-completer

A trie-based autocompleter

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

Keywords

FAQs

Package last updated on 02 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc