Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc