🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
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
npm
Version published
Weekly downloads
4
-55.56%
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