@mapl/router 0.7.1 → 0.7.3
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/package.json +4 -4
- package/utils.d.ts +7 -0
- package/utils.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapl/router",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "The fastest possible JS router",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
|
-
"./constants": "./constants.js",
|
|
13
12
|
"./utils": "./utils.js",
|
|
14
|
-
"./method": "./method/index.js",
|
|
15
|
-
"./path": "./path/index.js",
|
|
16
13
|
"./method/compiler": "./method/compiler.js",
|
|
14
|
+
"./constants": "./constants.js",
|
|
15
|
+
"./method": "./method/index.js",
|
|
17
16
|
"./path/compiler": "./path/compiler.js",
|
|
17
|
+
"./path": "./path/index.js",
|
|
18
18
|
"./tree/compiler": "./tree/compiler.js",
|
|
19
19
|
"./tree/node": "./tree/node.js"
|
|
20
20
|
}
|
package/utils.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
1
|
export declare const countParams: (path: string) => number;
|
|
2
|
+
declare const _: unique symbol;
|
|
3
|
+
export type ArgsCache = string[] & {
|
|
4
|
+
[_]: ""
|
|
5
|
+
};
|
|
6
|
+
export declare const paramsCache: (paramCnt: number) => ArgsCache;
|
|
7
|
+
export declare const addArg: (name: string, cache: ArgsCache) => ArgsCache;
|
|
8
|
+
export {};
|
package/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export let countParams=path=>{let cnt=path.endsWith(`**`)?2:0;for(let i=path.length-cnt;(i=path.lastIndexOf(`*`,i-1))!==-1;cnt++);return cnt};
|
|
1
|
+
export let countParams=path=>{let cnt=path.endsWith(`**`)?2:0;for(let i=path.length-cnt;(i=path.lastIndexOf(`*`,i-1))!==-1;cnt++);return cnt};export let paramsCache=paramCnt=>{let arr=[``,`q1`];for(let i=2;i<=paramCnt;i++)arr.push(arr[i-1]+`,q`+i);return arr};export let addArg=(name,cache)=>{let arr=[cache[0]===``?name:cache[0]+`,`+name];for(let i=1;i<cache.length;i++)arr.push(cache[i]+`,`+name);return arr};
|