https://github.com/bramstein/datrie
A JavaScript Double Array Trie
https://github.com/bramstein/datrie
Last synced: about 1 year ago
JSON representation
A JavaScript Double Array Trie
- Host: GitHub
- URL: https://github.com/bramstein/datrie
- Owner: bramstein
- Created: 2013-05-17T09:57:30.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2014-11-10T15:08:08.000Z (over 11 years ago)
- Last Synced: 2025-03-12T21:46:29.747Z (over 1 year ago)
- Language: JavaScript
- Size: 153 KB
- Stars: 20
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Double Array Trie library
**Note: this is a work in progress**
This library implements a double array trie in JavaScript. Nested JavaScript object tries are easy to build but take up large amounts of memory and need to be serialized and deserialized when sending them over the wire. A double array trie consists of three fixed size arrays which can be efficiently stored and transmitted.
var Trie = require('datrie');
var trie = new Trie({
'#': 1,
'a': 2,
'b': 3,
'c': 4,
'd': 5,
'k': 6
});
trie.insert('bad#');
trie.insert('back#');
trie.contains('bad#); // true
trie.contains('back#'); // true
trie.contains('hello'); // false
trie.remove('back#');
trie.contains('back#'); // false
## Installation
$ npm install datrie
## License
This library is licensed under the three clause BSD license.