Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

resig-trie

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resig-trie

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

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
235
increased by7.8%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 16 Jun 2014

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