A simple path template engine.
$ npm install bath
import assert from 'assert';
import bath from 'bath';
const { path, params } = bath('/users/:id');
assert.deepEqual(path({ id: '123' }) === '/users/123');
assert.deepEqual(params('/users/123'), { id: '123' });
import assert from 'assert';
import { path, params } from 'bath';
assert.deepEqual(path('/users/:id')({ id: '123' }) === '/users/123');
assert.deepEqual(params('/users/:id')('/users/123'), { id: '123' });
type Path = string;
type Params = { [key: string]: string; };
type Template = string;
type bath = (tempate: Template) => {
params: (path: Path) => Params | undefined;
path: (params?: Params) => Path;
};
https://gist.github.com/bouzuya/20dffb93201e00507dcdd0fde6de3a0f