npm.io
0.1.0 • Published 6 years ago

mtrie

Licence
MIT
Version
0.1.0
Deps
1
Size
1.9 MB
Vulns
0
Weekly
0

trie

Use trie to implement 'search array by the specified prefixed-string'.

// Big array
const data = [
  'abc hello',
  'hello world',
  'Wow that'
  // ...
]

// The matching string
const str = 'ab'

// Buid trie tree
const tree = trie.generateTrie(data)

// The matched array
const r = trie.matchString(tree, str)