Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

radix-router

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

radix-router - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

4

index.js

@@ -69,3 +69,2 @@ 'use strict';

console.log('string',str);
// largest prefix

@@ -132,3 +131,2 @@ return str.slice(0, index);

console.log('prefix', prefix);
// no matches, return null

@@ -217,3 +215,2 @@ if (prefix.length === 0) {

if (str.length === 0 || str === '/') {
console.log('!!!!!!!!!!!!!!!!!!!!!!string length is zero');
return new Node('/', data);

@@ -223,3 +220,2 @@ }

var sections = str.split('/');
console.log('sections', sections);
// first section is a special case, if it has real content, create a node

@@ -226,0 +222,0 @@ // otherwise, create an empty node

2

package.json

@@ -15,3 +15,3 @@ {

"name": "radix-router",
"version": "0.1.5",
"version": "0.1.6",
"description": "Radix tree based router",

@@ -18,0 +18,0 @@ "main": "index.js",

@@ -20,10 +20,16 @@ # Radix Router

`insert(path, data)` - adds the given path to the router and associates the given data with the path
`new RadixRouter(options)` - Creates a new instance of a router. The `options` object is optional.
`lookup(path)` - performs a lookup of the path. If there is a match, the data associated with the route is returned
Possible parameters for the `options` object:
`delete(path)` - deletes the path from the router
- `strict` - Setting this option to `true` will force lookups to match exact paths (trailing slashes will not be ignored). Defaults to `false`.
`startsWith(prefix)` - returns a map of all routes starting with the given prefix and the data associated with them
`insert(path, data)` - Adds the given path to the router and associates the given data with the path.
`lookup(path)` - Performs a lookup of the path. If there is a match, the data associated with the route is returned.
`delete(path)` - Deletes the path from the router.
`startsWith(prefix)` - Returns a map of all routes starting with the given prefix and the data associated with them.
### Example

@@ -34,3 +40,5 @@

let router = new RadixRouter();
let router = new RadixRouter({
strict: true
});

@@ -37,0 +45,0 @@ router.insert('/api/v1/route', {

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