
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
prefix-tree
Advanced tools
Simple prefix-tree
Class to work with prefix tree. API is similiar to native Map.
npm install --save prefix-tree
var Tree = require('prefix-tree');
var tree = new Tree([['hi', 42,] ['hello', 'world'], ['xo', 'xo']]);
tree.get('h');
// → [ 42, 'world']
tree.set('xxx', { '42': 42 });
tree.get('x');
// → [ 'xo', { '42': 42 }]
| Parameter | Type | Description |
|---|---|---|
items | array | optional Array of key-value pairs |
Example:
var tree = new PrefixTree([ ['key', 'value'], ['key2', 'value2'] ]);
var tree2 = new PrefixTree();
| Parameter | Type | Description |
|---|---|---|
key | string | key to search prefix in |
value | any | Anything you want to store |
Add value to prefix tree.
Example:
var tree = new PrefixTree();
tree.set('hello', 'world');
| Parameter | Type | Description |
|---|---|---|
prefix | string | prefix to search values |
Get values for a prefix.
Example:
var tree = new PrefixTree();
tree
.set('hell', 666);
.set('hello', 'world');
tree.get('he');
// → [666, 'world']
For debug purpose you could use toString() method.
NB For perfomance module load inspection only with NODE_ENV === 'development'
NODE_ENV='development' node -e "console.log('' + new (require('prefix-tree'))([['hello', 'hello'], ['hi', 'hi'], ['hell', 'hell']]))"
[root]
└── h
├── e
│ └── l
│ └── l : hell
│ └── o : hello
└── i : hi
Code released under the MIT.
FAQs
Simle prefix tree aka trie
We found that prefix-tree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.