trek-router
A fast HTTP router, inspired by Echo's Router.
Benchmarks
See benchmarks, use GitHub API Routes.
VS
$ npm run benchmark
trek-router x 5,236 ops/sec ±0.37% (102 runs sampled)
memoryUsage: { rss: 39653376, heapTotal: 31446272, heapUsed: 12252760 }
path-to-regexp x 434 ops/sec ±3.19% (90 runs sampled)
memoryUsage: { rss: 59383808, heapTotal: 50021120, heapUsed: 19588840 }
route-recognizer x 336 ops/sec ±2.33% (92 runs sampled)
memoryUsage: { rss: 62365696, heapTotal: 53104896, heapUsed: 20683920 }
route-trie x 1,105 ops/sec ±4.55% (86 runs sampled)
memoryUsage: { rss: 64360448, heapTotal: 54136832, heapUsed: 28538568 }
routington x 1,237 ops/sec ±0.54% (100 runs sampled)
memoryUsage: { rss: 67698688, heapTotal: 58252544, heapUsed: 18660040 }
Fastest is trek-router
Usage
import Router from 'trek-router';
let r = new Router();
r.add('GET', '/folders/files/bolt.gif', () => {});
r.add('GET', '/users/:id', () => {});
r.add('GET', '/books/*', () => {});
let result = r.find('GET', '/users/233')
let result = r.find('GET', '/photos/233')
License
MIT