@mapl/router 0.0.21 → 0.0.22

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tree/compiler.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapl/router",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "main": "./index.js",
5
5
  "devDependencies": {
6
6
  "@stylistic/eslint-plugin": "latest",
package/tree/compiler.js CHANGED
@@ -1 +1 @@
1
- export function compileNode(node,builder,hasParam,hasMultipleParams,startIndexValue,startIndexPrefix){let part=node[0];let partLen=part.length;startIndexValue++;if(partLen!==1){builder.push(`if(__req_pl>${startIndexPrefix}${startIndexValue+partLen-2})`);for(let i=1;i<partLen;i++,startIndexValue++)builder.push(`if(__req_p.charCodeAt(${startIndexPrefix}${startIndexValue})===${part.charCodeAt(i)})`);builder.push("{")}if(node[1]!==null)builder.push(`if(__req_pl===${startIndexPrefix}${startIndexValue}){${node[1]}}`);if(node[2]!==null){let children=node[2];let childrenKeys=Object.keys(children);if(childrenKeys.length===1){builder.push(`if(__req_p.charCodeAt(${startIndexPrefix}${startIndexValue})===${childrenKeys[0]}){`);compileNode(children[childrenKeys[0]],builder,hasParam,hasMultipleParams,startIndexValue,startIndexPrefix);builder.push("}")}else{builder.push(`switch(__req_p.charCodeAt(${startIndexPrefix}${startIndexValue})){`);for(let i=0,l=childrenKeys.length;i<l;i++){builder.push(`case ${childrenKeys[i]}:`);compileNode(children[childrenKeys[i]],builder,hasParam,hasMultipleParams,startIndexValue,startIndexPrefix);builder.push("break;")}builder.push("}")}}if(node[3]!==null){let params=node[3];let hasStore=params[1]!==null;let hasChild=params[0]!==null;let requireAllocation=hasParam?hasMultipleParams:hasChild||!hasStore;if(requireAllocation)builder.push("{");if(hasParam)builder.push(`${hasMultipleParams?"":"let "}__req_ppi=${startIndexPrefix}${startIndexValue};`);let currentIndex=hasParam?"__req_ppi":startIndexPrefix+startIndexValue;let slashIndex=`__req_p.indexOf('/',${currentIndex})`;if(hasChild||!hasStore)builder.push(`${hasParam?"":"let "}__req_cpi=${slashIndex};`);if(hasStore){let paramsVal=`__req_p.slice(${currentIndex})`;builder.push(`if(${hasChild?"__req_cpi":slashIndex}===-1){${hasParam?`__req_ps.push(${paramsVal})`:`let __req_ps=[${paramsVal}]`};${params[1]}}`)}if(hasChild){let paramsVal=`__req_p.substring(${currentIndex},__req_cpi)`;builder.push(`if(${hasStore?"":"__req_cpi!==-1&&"}__req_cpi!==${currentIndex}){${hasParam?`__req_ps.push(${paramsVal})`:`let __req_ps=[${paramsVal}]`};`);compileNode(params[0],builder,true,hasParam,0,"__req_cpi+");if(!requireAllocation)builder.push("__req_ps.pop();");builder.push("}")}if(requireAllocation)builder.push("}")}if(node[4]!==null){let noStore=node[1]===null;if(noStore)builder.push(`if(__req_pl!==${startIndexPrefix}${startIndexValue}){`);let paramsVal=`__req_p.slice(${startIndexPrefix}${startIndexValue})`;builder.push(`${hasParam?`__req_ps.push(${paramsVal})`:`let __req_ps=[${paramsVal}]`};${node[4]}`);if(noStore)builder.push("}")}if(partLen!==1)builder.push("}")}
1
+ export function compileNode(node,builder,hasParam,hasMultipleParams,startIndexValue,startIndexPrefix){let part=node[0];let partLen=part.length;startIndexValue++;if(partLen!==1){builder.push(`if(__req_pl>${startIndexPrefix}${startIndexValue+partLen-2})`);for(let i=1;i<partLen;i++,startIndexValue++)builder.push(`if(__req_p.charCodeAt(${startIndexPrefix}${startIndexValue})===${part.charCodeAt(i)})`);builder.push("{")}if(node[1]!==null)builder.push(`if(__req_pl===${startIndexPrefix}${startIndexValue}){${node[1]}}`);if(node[2]!==null){let children=node[2];let childrenKeys=Object.keys(children);if(childrenKeys.length===1){builder.push(`if(__req_p.charCodeAt(${startIndexPrefix}${startIndexValue})===${childrenKeys[0]}){`);compileNode(children[childrenKeys[0]],builder,hasParam,hasMultipleParams,startIndexValue,startIndexPrefix);builder.push("}")}else{builder.push(`switch(__req_p.charCodeAt(${startIndexPrefix}${startIndexValue})){`);for(let i=0,l=childrenKeys.length;i<l;i++){builder.push(`case ${childrenKeys[i]}:`);compileNode(children[childrenKeys[i]],builder,hasParam,hasMultipleParams,startIndexValue,startIndexPrefix);builder.push("break;")}builder.push("}")}}if(node[3]!==null){let params=node[3];let hasStore=params[1]!==null;let hasChild=params[0]!==null;let requireAllocation=hasParam?hasMultipleParams:hasChild||!hasStore;if(requireAllocation)builder.push("{");if(hasParam)builder.push(`${hasMultipleParams?"":"let "}__req_ppi=${startIndexPrefix}${startIndexValue};`);let currentIndex=hasParam?"__req_ppi":startIndexPrefix+startIndexValue;let slashIndex=`__req_p.indexOf('/'${currentIndex==="0"?"":","+currentIndex})`;if(hasChild||!hasStore)builder.push(`${hasParam?"":"let "}__req_cpi=${slashIndex};`);if(hasStore){let paramsVal=currentIndex==="0"?"__req_p":`__req_p.slice(${currentIndex})`;builder.push(`if(${hasChild?"__req_cpi":slashIndex}===-1){${hasParam?`__req_ps.push(${paramsVal})`:`let __req_ps=[${paramsVal}]`};${params[1]}}`)}if(hasChild){let paramsVal=`__req_p.substring(${currentIndex},__req_cpi)`;builder.push(`if(${hasStore?"":"__req_cpi!==-1&&"}__req_cpi!==${currentIndex}){${hasParam?`__req_ps.push(${paramsVal})`:`let __req_ps=[${paramsVal}]`};`);compileNode(params[0],builder,true,hasParam,0,"__req_cpi+");if(!requireAllocation)builder.push("__req_ps.pop();");builder.push("}")}if(requireAllocation)builder.push("}")}if(node[4]!==null){let noStore=node[1]===null;let currentIndex=startIndexPrefix+startIndexValue;if(noStore)builder.push(`if(__req_pl!==${currentIndex}){`);let paramsVal=currentIndex==="0"?"__req_p":`__req_p.slice(${currentIndex})`;builder.push(`${hasParam?`__req_ps.push(${paramsVal})`:`let __req_ps=[${paramsVal}]`};${node[4]}`);if(noStore)builder.push("}")}if(partLen!==1)builder.push("}")}