🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

trie-array

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trie-array

Keeps your data sorted in trie

latest
Source
npmnpm
Version
1.1.3
Version published
Maintainers
1
Created
Source

trie-array

Simple and fast implementation of a trie, https://en.wikipedia.org/wiki/Trie. Using it you keep your collection sorted by key and indexed as in array.

To install:

npm install trie-array

To use in coffee script:

trieFactory = require "./index.coffee"
trie = trieFactory (obj) ->
  key = obj.word.toUpperCase()

for word, index in ['A','character','is','that','of','a','typical','hero']
  trie.add {word,index}

trie.add elem = { word: "IS", status: "transient" }

trie.findByKey 'IS'
## finds all objects with key 'IS'
## -> {"pos":4,"res":[{"word":"is","index":2},{"word":"IS","status":"transient"}]}

trie.del elem

trie.getNth 3
## gets the 3rd element in 'key' order
## -> {"word":"hero","index":7}

trie.getAt 4, 2
## gets 2 elements starting at position 4
## -> [{"word":"is","index":2},{"word":"of","index":4}]

Keywords

trie

FAQs

Package last updated on 22 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts