@mapl/router 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fast-compile.d.ts +1 -1
- package/fast-compile.js +1 -1
- package/package.json +1 -1
package/fast-compile.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export declare const injectMatcher: (deps: any[]) => number;
|
|
|
3
3
|
/**
|
|
4
4
|
* Compile the router but with no pattern matching code
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: (router: Router, decls: string[],
|
|
6
|
+
declare const _default: (router: Router, decls: string[], routerId: number, matcherId: number, captures: string) => string;
|
|
7
7
|
export default _default;
|
package/fast-compile.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default (router,decls,
|
|
1
|
+
export default (router,decls,routerId,matcherId,captures)=>{let builder=router[0].length===0?"":router[0].map((pair)=>`if(p==="${pair[0].slice(1).replace(/"/g,"\\\"")}"){${pair[1]}}`).join("");if(router[1]===null)return builder;let fns=[];f(router[1],fns);let args=`(t,q${captures})`;return`${builder}let q=[],t=f${matcherId}(f${routerId},p,q,-1,p.length);if(t!==null)return d${decls.push(`${args}=>{${fns.map((fn,i)=>`if(t===${i+1}){${fn}}`).join("")}}`)}${args};`};import matcher from"./tree/matcher.js";let f=(node,fns)=>{if(node[1]!==null)node[1]=fns.push(node[1]);if(node[2]!==null){let children=node[2];for(let key in children)f(children[key],fns)}if(node[3]!==null){let params=node[3];if(params[1]!==null)params[1]=fns.push(params[1]);if(params[0]!==null)f(params[0],fns)}if(node[4]!==null)node[4]=fns.push(node[4])};export var injectMatcher=(deps)=>deps.push(matcher);
|