New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prefix-trie-ts

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prefix-trie-ts

Create and modify trie prefix structures, extract word lists including anagrams and sub-anagrams

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28
increased by12%
Maintainers
1
Weekly downloads
 
Created
Source

Prefix Trie TS

Smallest possible Trie implimintation written in Typescript.

Features

  • Prefix trie for autocomplete.
  • Less than 800 bytes gzipped.
  • Full typescript support.
  • Trie is not case sensitive.

Installation

npm i prefix-trie-ts

Browser

  • Include dist/prefixTrie.min.js on your page with a script tag.

NodeJS

const Trie = requie("prefix-trie-ts").Trie;

Typescript

import { Trie } from "prefix-trie-ts";

Usage

var trie = new Trie(["scott","jeb"]);
trie.addWord("john");
console.log(trie.getPrefix("j")) // <= ["john","jeb"]

Methods

Constructor

Optionally pass in the list of strings to search.

var trie = new Trie(["name1","name2"...])

Add Word

Add a word to the trie.

trie.addWord("name3");

Remove Word

Remove a word from the trie.

trie.removeWord("name3");

Get All Words

List all words in the word list.

trie.getWords()

Get Prefix

Search the trie for all words that begin with or match a given string. Returns an array of found strings.

trie.getPrefix("jo")

Export Trie Index

let exported = trie.getIndex();

Import Trie Index

trie.setIndex(indexJSON);

Keywords

FAQs

Package last updated on 30 Mar 2018

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