Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/junosuarez/path-trie

data structure for path-addressable resources
https://github.com/junosuarez/path-trie

Last synced: 8 days ago
JSON representation

data structure for path-addressable resources

Awesome Lists containing this project

README

        

# path-trie
data structure for path-addressable resources

## usage

```javascript
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) => Trie`

### `pathTrie.flatten: (trie: Trie, from: Array = []) => Dictionary`

`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

- jden

## license
MIT. (c) 2013 jden . See LICENSE.md