All Projects → mafintosh → to-radix-tree

mafintosh / to-radix-tree

Licence: MIT license
Convert a series of strings into a radix tree

Programming Languages

javascript
184084 projects - #8 most used programming language

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].