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

find-my-way

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-my-way - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

test/pretty-print.test.js

4

index.js

@@ -238,2 +238,6 @@ 'use strict'

Router.prototype.prettyPrint = function () {
return this.tree.prettyPrint('', true)
}
module.exports = Router

@@ -240,0 +244,0 @@

@@ -67,2 +67,38 @@ 'use strict'

Node.prototype.prettyPrint = function (prefix, tail) {
var paramName = ''
var map = this.map || {}
var methods = Object.keys(map).filter(method => map[method].handler)
if (this.prefix === ':') {
methods.forEach((method, index) => {
var params = this.map[method].params
var param = params[params.length - 1]
if (methods.length > 1) {
if (index === 0) {
paramName += param + ` (${method})\n`
return
}
paramName += ' ' + prefix + ':' + param + ` (${method})`
paramName += (index === methods.length - 1 ? '' : '\n')
} else {
paramName = params[params.length - 1] + ` (${method})`
}
})
} else if (methods.length) {
paramName = ` (${methods.join('|')})`
}
var tree = `${prefix}${tail ? '└── ' : '├── '}${this.prefix}${paramName}\n`
prefix = `${prefix}${tail ? ' ' : '│ '}`
for (var i = 0; i < this.numberOfChildren - 1; i++) {
tree += this.children[i].prettyPrint(prefix, false)
}
if (this.numberOfChildren > 0) {
tree += this.children[this.numberOfChildren - 1].prettyPrint(prefix, true)
}
return tree
}
module.exports = Node

2

package.json
{
"name": "find-my-way",
"version": "1.0.1",
"version": "1.1.0",
"description": "Crazy fast http radix based router",

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

@@ -89,2 +89,17 @@ # find-my-way

<a name="pretty-print"></a>
#### prettyPrint()
Prints the representation of the internal radix tree, useful for debugging.
```js
findMyWay.on('GET', '/test', () => {})
findMyWay.on('GET', '/test/hello', () => {})
findMyWay.on('GET', '/hello/world', () => {})
console.log(findMyWay.prettyPrint())
// └── /
// ├── test (GET)
// │ └── /hello (GET)
// └── hello/world (GET)
```
<a name="acknowledgements"></a>

@@ -91,0 +106,0 @@ ## Acknowledgements

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