1.0.0 • Published 6 years ago
to-radix-tree v1.0.0
to-radix-tree
Convert a series of strings into a radix tree
npm install to-radix-tree
Usage
const toRadixTree = require('to-radix-tree')
const tree = toRadixTree([
'hello world',
'hello verden'
])
console.log(tree)
Running the above will print something like
{
prefix: 'hello ',
children: [{
prefix: 'world',
value: 'hello world'
}, {
prefix: 'verden',
value: 'hello verden'
}]
}
API
tree = toRadixTree(array)
Turns an array of strings into a radix tree. The tree looks like this
{
prefix: 'all-children-start-with-this',
children: [tree..],
value: anArrayItemThatMatchAllParentPrefixes
}
License
MIT
1.0.0
6 years ago