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

digital-tree

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

digital-tree

trie data structure

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

digital tree

Trie data structure implementation

Install

npm install --save digital-tree

API

    var Trie = require('digital-tree')

    var trie = new Trie()

put(key, value)

Put something in the tree

    trie.put(['a', 'path', 'to'], 'something')

remove(key)

Remove something from the tree

given:

{ "a": {
        "path": {
            "to": {
                "$": "value"
            }
        }
    }
}
    var subtree = trie.remove(['a', 'path'])

subtree will be:

{ "to": { "$": "value" } }

Trie underlying data will look like this after the removal:

{ "a": {}}

get(key)

Get something from the tree

    var value = trie.get(['a', 'path', 'to'])

value will be the string "something"

searchByPrefix(key, excludeEmptyKeys)

Search for all the entries under key

    var result = trie.searchByPrefix(['a', 'path'])

result will be:

[ [ [ "a", "path", "to" ], "something" ] ]

TODO

  • add benchmarks of other similar modules

Keywords

FAQs

Package last updated on 26 Nov 2015

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