1.1.2 • Published 4 years ago

quick-trie v1.1.2

Weekly downloads
2
License
AGPL-3.0-only
Repository
github
Last release
4 years ago

Quick Trie Build Status codecov Known Vulnerabilities semantic-release

Trie implementation for faster searches

Trie

A trie structure an efficient way to match strings. It's worst computational complexity is O(N) where N is the length of the key.

For this reason trie search is commonly used in routing algorithms on web servers.

Features

  • Pattern matching in linear time
  • Efficient String Searching
  • Static Typing

Get Started

Install

yarn add quick-trie

Simple Usage

By default, key matching are case insensitive.

const root = init<number>();
add(root, 'foo', 1);

console.log(get(root, 'foo')); // 1
console.log(get(root, 'FOO')); // 1

To disable ignore casing, simply pass config object to the init function

const root = init<number>({
  ignoreCasing: false,
});
add(root, 'foo', 1);

console.log(get(root, 'foo')); // 1
console.log(get(root, 'FOO')); // undefined

Search String

const root = init<number>();
add(root, 'hello world', 1);
add(root, 'world class', 2);

console.log(search(root, 'world'));
[1, 2];
console.log(search(root, 'hello'));
[1];
console.log(search(root, 'class'));
[2];
1.1.1

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago