Socket
Socket
Sign inDemoInstall

trie

Package Overview
Dependencies
0
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    trie

A trie dictionary storage model


Version published
Weekly downloads
12
increased by33.33%
Maintainers
0
Install size
41.6 kB
Created
Weekly downloads
 

Readme

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

Last updated on 27 Jun 2011

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