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 3.0.0 to 3.0.1

12

package.json
{
"name": "radix-router",
"version": "3.0.0",
"version": "3.0.1",
"description": "Radix tree based router",

@@ -13,6 +13,5 @@ "main": "index.js",

"scripts": {
"pretest": "eslint .",
"test": "mocha test",
"test-coverage": "istanbul cover _mocha --include-all-sources -- --ui bdd --reporter spec ./tests",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"pretest": "npm run lint",
"test": "nyc mocha test",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"lint": "eslint ."

@@ -34,4 +33,5 @@ },

"jshint": "^2.9.4",
"mocha": "^3.1.2"
"mocha": "^3.1.2",
"nyc": "^11.2.1"
}
}

@@ -18,2 +18,20 @@ # Radix Router

A minimal example:
```js
const RadixRouter = require('radix-router')
const router = new Router()
router.insert({
path: '/api/people/:id',
data: { some: 'data' }
})
const { data, params } = router.lookup('/api/people/123456')
const { id } = params
console.log(id) // prints: '123456'
console.log(data) // prints: { some: 'data' }
```
#### Creating a new Router

@@ -152,8 +170,5 @@

content fills the position of the placeholder will be added to the lookup result
under the `params` attribute. The results within `params` is sorted by its occurrence
in the route.
under the `params` attribute. The name given for the placeholder in the path is the key to
retrieve the parameter from.
Note: Route placeholder params are placed into an array as an optimization. Your route handlers
should be aware of the order placeholders are defined in the routes.
Example:

@@ -163,9 +178,7 @@

router.insert(
path: '/api/v2/:myPlaceholder/route',
very: 'placeholder'
path: '/api/v2/:myPlaceholder/route'
})
router.insert(
path: '/api/v3/:organizations/directory/:groupId',
very: 'placeholder'
path: '/api/v3/:organizations/directory/:groupId'
})

@@ -178,3 +191,2 @@ ```

path: '/api/v2/:myPlaceholder/route',
very: 'placeholder',
params: {

@@ -190,3 +202,2 @@ myPlaceholder: 'application'

path: '/api/v3/:organizations/directory/:groupId',
very: 'placeholder',
params: {

@@ -193,0 +204,0 @@ organizations: 'test-org',

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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