JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16
  • Score
    100M100P100Q53416F
  • License MIT

trie data structure

Package Exports

  • digital-tree

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (digital-tree) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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