@e22m4u/js-path-trie
ES-module of the path trie routing.
Installation
npm install @e22m4u/js-path-trie
Example
add(pathTemplate: string, value: unknown)
- adds a value by the path templatematch(path: string)
- value lookup by the given path
const trie = new PathTrie();
trie.add('/foo/bar', yourValue1);
trie.add('/foo/:p1/bar/:p2', yourValue2);
trie.match('/foo/bar');
trie.match('/foo/10/bar/20');
trie.match('/foo/bar/baz');
Debug
Set environment variable DEBUG=jsPathTrie*
before start.
DEBUG=jsPathTrie* npm run test
Tests
npm run test
License
MIT