find-my-way
Advanced tools
Comparing version 1.3.2 to 1.4.0
@@ -22,2 +22,11 @@ 'use strict' | ||
Node.prototype.add = function (node) { | ||
if (node.kind === 0) { | ||
for (var i = 0; i < this.numberOfChildren; i++) { | ||
if (this.children[i].kind > 0) { | ||
this.children.splice(i, 0, node) | ||
this.numberOfChildren++ | ||
return | ||
} | ||
} | ||
} | ||
this.children.push(node) | ||
@@ -24,0 +33,0 @@ this.numberOfChildren++ |
{ | ||
"name": "find-my-way", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "Crazy fast http radix based router", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# find-my-way | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://travis-ci.org/delvedor/find-my-way.svg?branch=master)](https://travis-ci.org/delvedor/find-my-way) [![Coverage Status](https://coveralls.io/repos/github/delvedor/find-my-way/badge.svg?branch=master)](https://coveralls.io/github/delvedor/find-my-way?branch=master) | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://travis-ci.org/delvedor/find-my-way.svg?branch=master)](https://travis-ci.org/delvedor/find-my-way) [![Coverage Status](https://coveralls.io/repos/github/delvedor/find-my-way/badge.svg?branch=master)](https://coveralls.io/github/delvedor/find-my-way?branch=master) [![NPM downloads](https://img.shields.io/npm/dm/find-my-way.svg?style=flat)](https://www.npmjs.com/package/find-my-way) | ||
A crazy fast HTTP router, internally uses an highly performant [Radix Tree](https://en.wikipedia.org/wiki/Radix_tree) (aka compact [Prefix Tree](https://en.wikipedia.org/wiki/Trie)), supports route params, wildcards, and it's framework independent. | ||
It is inspired by the [echo](https://github.com/labstack/echo) router, some parts have been extracted from [trekjs](https://github.com/trekjs) router. | ||
A crazy fast HTTP router, internally uses an highly performant [Radix Tree](https://en.wikipedia.org/wiki/Radix_tree) (aka compact [Prefix Tree](https://en.wikipedia.org/wiki/Trie)), supports route params, wildcards, and it's framework independent. | ||
If you want to see a benchmark comparison with the most commonly used routers, see [here](https://github.com/delvedor/router-benchmark). | ||
Do you need a real-world example that uses this router? Check out [Fastify](https://github.com/fastify/fastify). | ||
<a name="install"></a> | ||
@@ -63,3 +65,4 @@ ## Install | ||
``` | ||
If you want to register a **parametric** path, just use the *colon* before the parameter name, if you need a **wildcard** use the *star*. | ||
If you want to register a **parametric** path, just use the *colon* before the parameter name, if you need a **wildcard** use the *star*. | ||
*Remember that static routes are always inserted before parametric and wildcard.* | ||
```js | ||
@@ -130,3 +133,4 @@ // parametric | ||
This project is kindly sponsored by [LetzDoIt](http://www.letzdoitapp.com/). | ||
This project is kindly sponsored by [LetzDoIt](http://www.letzdoitapp.com/). | ||
It is inspired by the [echo](https://github.com/labstack/echo) router, some parts have been extracted from [trekjs](https://github.com/trekjs) router. | ||
@@ -138,4 +142,2 @@ <a name="license"></a> | ||
*The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non infringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.* | ||
Copyright © 2017 Tomas Della Vedova |
@@ -329,1 +329,79 @@ 'use strict' | ||
}) | ||
test('static routes should be inserted before parametric / 1', t => { | ||
t.plan(1) | ||
const findMyWay = FindMyWay() | ||
findMyWay.on('GET', '/test/hello', () => { | ||
t.pass('inside correct handler') | ||
}) | ||
findMyWay.on('GET', '/test/:id', () => { | ||
t.fail('wrong handler') | ||
}) | ||
findMyWay.lookup({ method: 'GET', url: '/test/hello' }, null) | ||
}) | ||
test('static routes should be inserted before parametric / 2', t => { | ||
t.plan(1) | ||
const findMyWay = FindMyWay() | ||
findMyWay.on('GET', '/test/:id', () => { | ||
t.fail('wrong handler') | ||
}) | ||
findMyWay.on('GET', '/test/hello', () => { | ||
t.pass('inside correct handler') | ||
}) | ||
findMyWay.lookup({ method: 'GET', url: '/test/hello' }, null) | ||
}) | ||
test('static routes should be inserted before parametric / 3', t => { | ||
t.plan(2) | ||
const findMyWay = FindMyWay() | ||
findMyWay.on('GET', '/:id', () => { | ||
t.fail('wrong handler') | ||
}) | ||
findMyWay.on('GET', '/test', () => { | ||
t.ok('inside correct handler') | ||
}) | ||
findMyWay.on('GET', '/test/:id', () => { | ||
t.fail('wrong handler') | ||
}) | ||
findMyWay.on('GET', '/test/hello', () => { | ||
t.ok('inside correct handler') | ||
}) | ||
findMyWay.lookup({ method: 'GET', url: '/test' }, null) | ||
findMyWay.lookup({ method: 'GET', url: '/test/hello' }, null) | ||
}) | ||
test('static routes should be inserted before parametric / 4', t => { | ||
t.plan(2) | ||
const findMyWay = FindMyWay() | ||
findMyWay.on('GET', '/:id', () => { | ||
t.ok('inside correct handler') | ||
}) | ||
findMyWay.on('GET', '/test', () => { | ||
t.fail('wrong handler') | ||
}) | ||
findMyWay.on('GET', '/test/:id', () => { | ||
t.ok('inside correct handler') | ||
}) | ||
findMyWay.on('GET', '/test/hello', () => { | ||
t.fail('wrong handler') | ||
}) | ||
findMyWay.lookup({ method: 'GET', url: '/test/id' }, null) | ||
findMyWay.lookup({ method: 'GET', url: '/id' }, null) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
43054
1213
141
2