npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

to-radix-tree

1.0.0

@mafintosh

npmHomeRepoSnykSocket
Downloads:2
$ npm install to-radix-tree
DailyWeeklyMonthlyYearly

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