path-trie

0.1.1 • Public • Published

path-trie

data structure for path-addressable resources

usage

  var pathTrie = require('path-trie')

  var dictionary = {
    'a/b/c': 123
  }
  var trie = pathTrie(dictionary)
  // => {
  //      a: {
  //        b: {
  //          c: {
  //            '@': 123
  //          }
  //        }
  //      }
  //    }

  dictionary = pathTrie.flatten(trie)
  // => {
  //      'a/b/c': 123
  //    }

api

pathTrie: (dictionary: Dictionary<String, Value>) => Trie

pathTrie.flatten: (trie: Trie, from: Array<String> = []) => Dictionary<String, Value>

from is an optional path to flatten just a particular subtrie.

pathTrie.put: (this: Trie, path: Path, val: Value) => Trie

pathTrie.get: (this: Trie, path: Path) => Value?

pathTrie.del: (this: Trie, path: Path) => void

installation

$ npm install path-trie

running the tests

from project root:

$ npm install
$ npm test

contributors

license

MIT. (c) 2013 jden jason@denizac.org. See LICENSE.md

Readme

Keywords

none

Package Sidebar

Install

npm i path-trie

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators