You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

trie

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trie

A trie dictionary storage model

0.2.1
latest
Source
npmnpm
Version published
Weekly downloads
7
40%
Maintainers
0
Weekly downloads
 
Created
Source

h1. node-trie

Author: James Brumond Version: 0.2.1

Copyright 2011 James Brumond Dual licensed under MIT and GPL

h2. Install

npm install trie

h2. Samples

var trie = require('trie');

var myTrie = new trie.Trie();

// Adding words
myTrie.addWord('hello');
myTrie.addWord('world');

// Removing words
myTrie.removeWord('world');

// Checking for words
myTrie.lookup('hello'); // true
myTrie.lookup('world'); // false

// Testing prefixes
myTrie.isValidPrefix('h'); // true
myTrie.isValidPrefix('he'); // true
myTrie.isValidPrefix('ho'); // false

// Serializing
var jsonBlob = myTrie.dumpJson();

// Unserializing
var otherTrie = new Trie();
otherTrie.loadJson(jsonBlob);

// Shortcut functions
var trie3 = trie.createTrieFromArray([ 'word1', 'word2', 'word3' ])
var trie4 = trie.createTrieFromJson(jsonBlob);

FAQs

Package last updated on 27 Jun 2011

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.