New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

rad-tree

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

rad-tree

Small radix tree library

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

rad-tree

Small library implementing a radix (or prefix) tree.

Install

npm i --save rad-tree

Usage

Create a tree

'use strict'

const Tree = require('rad-tree')

const tree = new Tree()

Set key/value pairs

...

tree.set('icecream', 'cone')
tree.set('foo', 'bar')
tree.set('iced', 'coffee')
tree.set('foobar', 'baz')
tree.set('ice') // value defaults to `ice`
tree.set('fo', 'mo')

Get values

...

tree.get('foobar')
// 'baz'

tree.get('icedcoffee')
// undefined

Delete key/value pairs

...

tree.delete('foobar')
// true

tree.delete('icedcoffee')
// false

Generate object representation of tree

...

tree.toObject()

// {
//   edges: [
//     {
//       key: 'fo',
//       node: {
//         value: 'mo',
//         edges: [
//           {
//             key: 'o',
//             node: {
//               value: 'bar',
//               edges: [
//                 {
//                   key: 'bar',
//                   node: { value: 'baz' }
//                 }
//               ]
//             }
//           }
//         ]
//       }
//     },
//     {
//       key: 'ice',
//       node: {
//         edges: [
//           {
//             key: 'cream',
//             node: { value: 'cone' }
//           },
//           {
//             key: 'd',
//             node: { value: 'coffee' }
//           }
//         ],
//         value: 'ice'
//       }
//     }
//   ]
// }

Generate string representation of tree

...

tree.toString()

// `fo: mo
//   o: bar
//     bar: baz
// ice: ice
//   cream: cone
//   d: coffee`

Test

npm test

Lint

npm run lint

Documentation

npm run doc

Contributing

Please do!

If you find a bug, want a feature added, or just have a question, feel free to open an issue. In addition, you're welcome to create a pull request addressing an issue. You should push your changes to a feature branch and request merge to develop.

Make sure linting and tests pass and coverage is 💯 before creating a pull request!

FAQs

Package last updated on 18 Sep 2020

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