UNPKG

hurt

Version:

HTTP and SPA routing using RFC 6570 URI templates

16 lines (14 loc) 343 B
export function mixin({ name = '' } = {}) { const routes = {}; return { name, route(...args) { const name = args.reduce((name, options) => (name || options.name), ''); const route = routes[ name ] || this.route(...args); if (route.name) { routes[ name ] = route; } return route; } }; }