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

cspell-trie-lib

Package Overview
Dependencies
Maintainers
1
Versions
296
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cspell-trie-lib

Trie Data Structure to support cspell.

  • 5.21.2
  • cspell5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
691K
decreased by-6.59%
Maintainers
1
Weekly downloads
 
Created

What is cspell-trie-lib?

The cspell-trie-lib package provides utilities for working with Trie data structures, which are particularly useful for spell checking, auto-completion, and other text processing tasks. It allows for efficient storage and retrieval of words and prefixes.

What are cspell-trie-lib's main functionalities?

Creating a Trie

This feature allows you to create a Trie and insert words into it. The `has` method checks if a word exists in the Trie.

const { Trie } = require('cspell-trie-lib');
const trie = new Trie();
trie.insert('hello');
trie.insert('world');
console.log(trie.has('hello')); // true
console.log(trie.has('world')); // true
console.log(trie.has('hell')); // false

Finding Words with a Given Prefix

This feature allows you to find all words in the Trie that start with a given prefix. The `findWithPrefix` method returns an array of words that match the prefix.

const { Trie } = require('cspell-trie-lib');
const trie = new Trie();
trie.insert('hello');
trie.insert('hell');
trie.insert('heaven');
trie.insert('heavy');
const wordsWithHe = trie.findWithPrefix('he');
console.log(wordsWithHe); // ['hello', 'hell', 'heaven', 'heavy']

Removing a Word from the Trie

This feature allows you to remove a word from the Trie. The `remove` method deletes the specified word, and the `has` method can be used to verify its removal.

const { Trie } = require('cspell-trie-lib');
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 cspell-trie-lib

Keywords

FAQs

Package last updated on 21 May 2022

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