Socket
Socket
Sign inDemoInstall

@wry/trie

Package Overview
Dependencies
1
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wry/trie

https://en.wikipedia.org/wiki/Trie


Version published
Maintainers
1
Weekly downloads
4,153,509
decreased by-7%

Weekly downloads

Package description

What is @wry/trie?

The @wry/trie package is a library for creating and manipulating trie data structures in JavaScript. A trie, also known as a prefix tree, is a type of search tree that is used to store a dynamic set or associative array where the keys are usually strings. It is particularly useful for tasks like autocomplete, spell checking, and prefix matching.

What are @wry/trie's main functionalities?

Creating a Trie

This feature allows you to create a new Trie instance and insert strings into it. You can then find all strings that start with a given prefix.

{"import { Trie } from '@wry/trie';

const trie = new Trie();
trie.insert('hello');
trie.insert('world');
trie.insert('help');

console.log(trie.find('hel')); // ['hello', 'help']
console.log(trie.find('world')); // ['world']"}

Checking for Existence

This feature allows you to check if a particular string exists in the trie.

{"import { Trie } from '@wry/trie';

const trie = new Trie();
trie.insert('hello');
trie.insert('world');

console.log(trie.has('hello')); // true
console.log(trie.has('bye')); // false"}

Removing Entries

This feature allows you to remove entries from the trie.

{"import { Trie } from '@wry/trie';

const trie = new Trie();
trie.insert('hello');
trie.insert('world');
trie.remove('hello');

console.log(trie.has('hello')); // false
console.log(trie.has('world')); // true"}

Other packages similar to @wry/trie

Readme

Source

@wry/trie

A trie data structure that holds object keys weakly, yet can also hold non-object keys, unlike WeakMap.

Keywords

FAQs

Last updated on 15 May 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc