Socket
Socket
Sign inDemoInstall

resig-trie

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    resig-trie

John Resig's trie implementation, prettified and packaged for npm


Version published
Weekly downloads
143
decreased by-33.18%
Maintainers
1
Install size
14.8 kB
Created
Weekly downloads
 

Readme

Source

A Simple JavaScript Trie, by John Resig

Install

npm install --save resig-trie

Usage

var trie = require('trie');

trie.create(['a', 'an', 'banana', 'bananas', 'byte', 'boolean', 'chocolate', 'code', ...]);
//=> <trie object>

trie.serialize(<trie object>, true); // true to create valid JSON
//=> '<trie object as JSON>'

trie.serialize(<trie object>, false); // false to create valid JavaScript (not JSON) - more efficient, but must be `eval`'ed
//=> '<trie object as long string>'

// Warning: this uses eval(), so don't pass user input. When the trie is
// serialized as JSON, you can just JSON.parse() it.
trie.unserialize(<trie string>);
//=> <trie object>

trie.find(<trie object>, 'banana');
//=> true, because 'banana' is in the trie

trie.find(<trie object>, 'microsoft');
//=> false, because 'microsoft' is not in the trie

License

Copyright 2011 John Resig. Josh Oldenburg packaged this as a simple npm module in 2014.

Released under the MIT license.

Keywords

FAQs

Last updated on 16 Jun 2014

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