Socket
Socket
Sign inDemoInstall

raikiri

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raikiri - npm Package Compare versions

Comparing version 0.1.0-beta.2 to 0.1.1

2

dist/cjs/ei.js

@@ -1,1 +0,1 @@

let t=(t,e)=>{let r="";for(let l=0;l<t.length&&e[l]===t[l];l++)r+=e[l];return r},e=({children:t=null,part:e="",static:r=null}={})=>{let l=Object.create(null);if(e&&(l.part=e),l.children=new Map,t)for(let e of Object.keys(t))l.children.set(+e,t[+e]);return r&&(l.static=r),l},r=(t,e=null,r=null)=>{let l=Object.create(null);if(l.param=t,l.children=new Map,e)for(let t of Object.keys(e))l.children.set(+t,e[+t]);return r&&(l.static=r),l};export class Raikiri{root={};history=[];add(l,i,n){this.history.push([l,i,n]),l in this.root||(this.root[l]=e());let h=this.root[l],s=[""];if(i.split("/").forEach(t=>{if(t){if(t.startsWith(":")||t.startsWith("*")){s.push(t),s.push("/");return}s[s.length-1]+=`${t}/`}}),i.endsWith("/")||"/"===i||(s[s.length-1]=s[s.length-1].slice(0,s[s.length-1].length-1)),s.length>1&&""===s[s.length-1]&&s.pop(),1===s.length){let t="/"+s[0];h.static||(h.static={}),h.static[t]=n;return}if("*"===s[1]&&"/"===s[0]&&2===s.length){let t=e();t.store=n,this.root[l].children.set(42,t);return}t:for(let l=0;l<s.length;l++){let i=s[l],c=l===s.length-1;for(let r of h.children.keys()){let l=h.children.get(r);l.part;let n=t(h.part,i);if(n===i)continue t;if(n||58!==i.charCodeAt(0)&&42!==i.charCodeAt(0)){if(n){let l=i.charCodeAt(n.length),s=h.children.get(r),a=h.part.slice(n.length+1),o=h.part.charCodeAt(n.length),d=h.part!==n;if(d){let t=e({part:i.slice(n.length+1)});h.part=n,h.children.set(l,t),h.children.set(o,e({part:a,children:{[r]:s}})),h.children.delete(r),h=t}else{let s=h.children.get(l);if(s){let c=i.slice(n.length+1);if(c===s.part){h=s;continue t}if(!s.part){h=s.children.get(r);continue t}s.part.charCodeAt(0);let a=t(c,s.part);s.part=s.part.slice(a.length);let o=e({part:c.slice(a.length)});h.children.set(l,e({part:c.slice(-1),children:{[s.part.charCodeAt(a.length-1)]:s,[c.charCodeAt(a.length-1)]:o}})),h=o;continue t}if(c)break;let a=e({part:i.slice(n.length+1)});h.children.set(l,a),h=a}}else if(h.part){let t=e({part:i.slice(1)}),r={...h};r.part=r.part.slice(1);let l=e({children:{[h.part.charCodeAt(0)]:r,[i.charCodeAt(0)]:t}});h.part="",h.children=l.children,h=t}else{let t=e({part:i.slice(1)});h.children.set(i.charCodeAt(0),t),h=t}continue t}}if(i.includes(":")){if(h.children.has(58)){h=h.children.get(58);continue}h.children.set(58,r(i.slice(1))),h=h.children.get(58)}else if(i.includes("*")){h.children.set(42,e()),h=h.children.get(42);break t}else{if(c){h.static||(h.static={}),h.static[i]=n;return}h.part=i}}h.store=n}remove(t,e){let r=new Raikiri;for(let l=0;l<this.history.length;l++){let[i,n,h]=this.history[l];(i!==t||n!==e)&&r.add(i,n,h)}this.history=r.history,this.root=r.root}match(t,e){let r=this.root[t];if(!r)return;let i=r.static?.[e];return i?{store:i,params:{}}:l(e.slice(1),r,{})}}let l=(t,e,r)=>{let l=e.children.get(t.charCodeAt(e.part?.length));if(!l){let l=e.children.get(58);if(l){let n=t.indexOf("/",e.part.length);return -1===n?(r[l.param]=t.slice(e.part.length),l.store)?{store:l.store,params:r}:void 0:(r[l.param]=t.slice(e.part.length,n),i(t.slice(n),e.children.get(58),r))}if(e.children.has(42)){r["*"]=t.slice(e.part.length);let l=e.children.get(42).store;return l?{store:l,params:r}:void 0}return e.store?{store:e.store,params:r}:void 0}return i(t.slice(e.part.length+1),l,r)},i=(t,e,r)=>{let l=e.static?.[t];if(l)return{store:l,params:r};let n=e.children.get(t.charCodeAt(e.part?.length));if(!n){let l=e.children.get(58);if(l){let n=t.indexOf("/",e.part.length);return -1===n?(r[l.param]=t.slice(e.part.length),l.store)?{store:l.store,params:r}:void 0:(r[l.param]=t.slice(e.part.length,n),i(t.slice(n),e.children.get(58),r))}if(e.children.has(42)){e.part?r["*"]=t.slice(e.part.length):r["*"]=t;let l=e.children.get(42).store;return l?{store:l,params:r}:void 0}return e.store?{store:e.store,params:r}:void 0}return i(t.slice(e.part.length+1),n,r)};export default Raikiri;
let t=(t,e)=>{let r="";for(let l=0;l<t.length&&e[l]===t[l];l++)r+=e[l];return r},e=({children:t=null,part:e="",static:r=null}={})=>{let l=Object.create(null);if(e&&(l.part=e),l.children=new Map,t)for(let e of Object.keys(t))l.children.set(+e,t[+e]);return r&&(l.static=r),l},r=(t,e=null,r=null)=>{let l=Object.create(null);if(l.param=t,l.children=new Map,e)for(let t of Object.keys(e))l.children.set(+t,e[+t]);return r&&(l.static=r),l};export class Raikiri{root={};history=[];add(l,i,n){this.history.push([l,i,n]),l in this.root||(this.root[l]=e());let h=this.root[l],s=[""];if(i.split("/").forEach(t=>{if(t){if(t.startsWith(":")||t.startsWith("*")){s.push(t),s.push("/");return}s[s.length-1]+=`${t}/`}}),i.endsWith("/")||"/"===i||(s[s.length-1]=s[s.length-1].slice(0,s[s.length-1].length-1)),s.length>1&&""===s[s.length-1]&&s.pop(),1===s.length){let t="/"+s[0];h.static||(h.static={}),h.static[t]=n;return}if("*"===s[1]&&"/"===s[0]&&2===s.length){let t=e();t.store=n,this.root[l].children.set(42,t);return}t:for(let l=0;l<s.length;l++){let i=s[l],c=l===s.length-1;for(let r of h.children.keys()){let l=h.children.get(r);l.part;let n=t(h.part,i);if(n===i)continue t;if(n||58!==i.charCodeAt(0)&&42!==i.charCodeAt(0)){if(n){let l=i.charCodeAt(n.length),s=h.children.get(r),a=h.part.slice(n.length+1),o=h.part.charCodeAt(n.length),d=h.part!==n;if(d){let t=e({part:i.slice(n.length+1)});h.part=n,h.children.set(l,t),h.children.set(o,e({part:a,children:{[r]:s}})),h.children.delete(r),h=t}else{let s=h.children.get(l);if(s){let c=i.slice(n.length+1);if(c===s.part){h=s;continue t}if(!s.part){h=s.children.get(r);continue t}s.part.charCodeAt(0);let a=t(c,s.part);s.part=s.part.slice(a.length);let o=e({part:c.slice(a.length)});h.children.set(l,e({part:c.slice(-1),children:{[s.part.charCodeAt(a.length-1)]:s,[c.charCodeAt(a.length-1)]:o}})),h=o;continue t}if(c)break;let a=e({part:i.slice(n.length+1)});h.children.set(l,a),h=a}}else if(h.part){let t=e({part:i.slice(1)}),r={...h};r.part=r.part.slice(1);let l=e({children:{[h.part.charCodeAt(0)]:r,[i.charCodeAt(0)]:t}});h.part="",h.children=l.children,h=t}else{let t=e({part:i.slice(1)});h.children.set(i.charCodeAt(0),t),h=t}continue t}}if(i.includes(":")){if(h.children.has(58)){h=h.children.get(58);continue}h.children.set(58,r(i.slice(1))),h=h.children.get(58)}else if(i.includes("*")){h.children.set(42,e()),h=h.children.get(42);break t}else{if(c){h.static||(h.static={}),h.static[i]=n;return}h.part=i}}h.store=n}remove(t,e){let r=new Raikiri;for(let l=0;l<this.history.length;l++){let[i,n,h]=this.history[l];(i!==t||n!==e)&&r.add(i,n,h)}this.history=r.history,this.root=r.root}match(t,e){let r=this.root[t];if(!r)return;let i=r.static?.[e];return i?{store:i,params:{}}:l(e.slice(1),r,{})}_m(t,e){let r=this.root[t];if(r)return l(e.slice(1),r,{})}}let l=(t,e,r)=>{let l=e.children.get(t.charCodeAt(e.part?.length));if(!l){let l=e.children.get(58);if(l){let n=t.indexOf("/",e.part.length);return -1===n?(r[l.param]=t.slice(e.part.length),l.store)?{store:l.store,params:r}:void 0:(r[l.param]=t.slice(e.part.length,n),i(t.slice(n),e.children.get(58),r))}if(e.children.has(42)){r["*"]=t.slice(e.part.length);let l=e.children.get(42).store;return l?{store:l,params:r}:void 0}return e.store?{store:e.store,params:r}:void 0}return i(t.slice(e.part.length+1),l,r)},i=(t,e,r)=>{let l=e.static?.[t];if(l)return{store:l,params:r};let n=e.children.get(t.charCodeAt(e.part?.length));if(!n){let l=e.children.get(58);if(l){let n=t.indexOf("/",e.part.length);return -1===n?(r[l.param]=t.slice(e.part.length),l.store)?{store:l.store,params:r}:void 0:(r[l.param]=t.slice(e.part.length,n),i(t.slice(n),e.children.get(58),r))}if(e.children.has(42)){e.part?r["*"]=t.slice(e.part.length):r["*"]=t;let l=e.children.get(42).store;return l?{store:l,params:r}:void 0}return e.store?{store:e.store,params:r}:void 0}return i(t.slice(e.part.length+1),n,r)};export default Raikiri;

@@ -17,3 +17,4 @@ interface RadixNode<T> {

} | undefined;
private _m;
}
export default Raikiri;

@@ -1,1 +0,1 @@

let t=(t,e)=>{let r="";for(let l=0;l<t.length&&e[l]===t[l];l++)r+=e[l];return r},e=({children:t=null,part:e="",static:r=null}={})=>{let l=Object.create(null);if(e&&(l.part=e),l.children=new Map,t)for(let e of Object.keys(t))l.children.set(+e,t[+e]);return r&&(l.static=r),l},r=(t,e=null,r=null)=>{let l=Object.create(null);if(l.param=t,l.children=new Map,e)for(let t of Object.keys(e))l.children.set(+t,e[+t]);return r&&(l.static=r),l};export class Raikiri{root={};history=[];add(l,i,n){this.history.push([l,i,n]),l in this.root||(this.root[l]=e());let h=this.root[l],s=[""];if(i.split("/").forEach(t=>{if(t){if(t.startsWith(":")||t.startsWith("*")){s.push(t),s.push("/");return}s[s.length-1]+=`${t}/`}}),i.endsWith("/")||"/"===i||(s[s.length-1]=s[s.length-1].slice(0,s[s.length-1].length-1)),s.length>1&&""===s[s.length-1]&&s.pop(),1===s.length){let t="/"+s[0];h.static||(h.static={}),h.static[t]=n;return}if("*"===s[1]&&"/"===s[0]&&2===s.length){let t=e();t.store=n,this.root[l].children.set(42,t);return}t:for(let l=0;l<s.length;l++){let i=s[l],c=l===s.length-1;for(let r of h.children.keys()){let l=h.children.get(r);l.part;let n=t(h.part,i);if(n===i)continue t;if(n||58!==i.charCodeAt(0)&&42!==i.charCodeAt(0)){if(n){let l=i.charCodeAt(n.length),s=h.children.get(r),a=h.part.slice(n.length+1),o=h.part.charCodeAt(n.length),d=h.part!==n;if(d){let t=e({part:i.slice(n.length+1)});h.part=n,h.children.set(l,t),h.children.set(o,e({part:a,children:{[r]:s}})),h.children.delete(r),h=t}else{let s=h.children.get(l);if(s){let c=i.slice(n.length+1);if(c===s.part){h=s;continue t}if(!s.part){h=s.children.get(r);continue t}s.part.charCodeAt(0);let a=t(c,s.part);s.part=s.part.slice(a.length);let o=e({part:c.slice(a.length)});h.children.set(l,e({part:c.slice(-1),children:{[s.part.charCodeAt(a.length-1)]:s,[c.charCodeAt(a.length-1)]:o}})),h=o;continue t}if(c)break;let a=e({part:i.slice(n.length+1)});h.children.set(l,a),h=a}}else if(h.part){let t=e({part:i.slice(1)}),r={...h};r.part=r.part.slice(1);let l=e({children:{[h.part.charCodeAt(0)]:r,[i.charCodeAt(0)]:t}});h.part="",h.children=l.children,h=t}else{let t=e({part:i.slice(1)});h.children.set(i.charCodeAt(0),t),h=t}continue t}}if(i.includes(":")){if(h.children.has(58)){h=h.children.get(58);continue}h.children.set(58,r(i.slice(1))),h=h.children.get(58)}else if(i.includes("*")){h.children.set(42,e()),h=h.children.get(42);break t}else{if(c){h.static||(h.static={}),h.static[i]=n;return}h.part=i}}h.store=n}remove(t,e){let r=new Raikiri;for(let l=0;l<this.history.length;l++){let[i,n,h]=this.history[l];(i!==t||n!==e)&&r.add(i,n,h)}this.history=r.history,this.root=r.root}match(t,e){let r=this.root[t];if(!r)return;let i=r.static?.[e];return i?{store:i,params:{}}:l(e.slice(1),r,{})}}let l=(t,e,r)=>{let l=e.children.get(t.charCodeAt(e.part?.length));if(!l){let l=e.children.get(58);if(l){let n=t.indexOf("/",e.part.length);return -1===n?(r[l.param]=t.slice(e.part.length),l.store)?{store:l.store,params:r}:void 0:(r[l.param]=t.slice(e.part.length,n),i(t.slice(n),e.children.get(58),r))}if(e.children.has(42)){r["*"]=t.slice(e.part.length);let l=e.children.get(42).store;return l?{store:l,params:r}:void 0}return e.store?{store:e.store,params:r}:void 0}return i(t.slice(e.part.length+1),l,r)},i=(t,e,r)=>{let l=e.static?.[t];if(l)return{store:l,params:r};let n=e.children.get(t.charCodeAt(e.part?.length));if(!n){let l=e.children.get(58);if(l){let n=t.indexOf("/",e.part.length);return -1===n?(r[l.param]=t.slice(e.part.length),l.store)?{store:l.store,params:r}:void 0:(r[l.param]=t.slice(e.part.length,n),i(t.slice(n),e.children.get(58),r))}if(e.children.has(42)){e.part?r["*"]=t.slice(e.part.length):r["*"]=t;let l=e.children.get(42).store;return l?{store:l,params:r}:void 0}return e.store?{store:e.store,params:r}:void 0}return i(t.slice(e.part.length+1),n,r)};export default Raikiri;
let t=(t,e)=>{let r="";for(let l=0;l<t.length&&e[l]===t[l];l++)r+=e[l];return r},e=({children:t=null,part:e="",static:r=null}={})=>{let l=Object.create(null);if(e&&(l.part=e),l.children=new Map,t)for(let e of Object.keys(t))l.children.set(+e,t[+e]);return r&&(l.static=r),l},r=(t,e=null,r=null)=>{let l=Object.create(null);if(l.param=t,l.children=new Map,e)for(let t of Object.keys(e))l.children.set(+t,e[+t]);return r&&(l.static=r),l};export class Raikiri{root={};history=[];add(l,i,n){this.history.push([l,i,n]),l in this.root||(this.root[l]=e());let h=this.root[l],s=[""];if(i.split("/").forEach(t=>{if(t){if(t.startsWith(":")||t.startsWith("*")){s.push(t),s.push("/");return}s[s.length-1]+=`${t}/`}}),i.endsWith("/")||"/"===i||(s[s.length-1]=s[s.length-1].slice(0,s[s.length-1].length-1)),s.length>1&&""===s[s.length-1]&&s.pop(),1===s.length){let t="/"+s[0];h.static||(h.static={}),h.static[t]=n;return}if("*"===s[1]&&"/"===s[0]&&2===s.length){let t=e();t.store=n,this.root[l].children.set(42,t);return}t:for(let l=0;l<s.length;l++){let i=s[l],c=l===s.length-1;for(let r of h.children.keys()){let l=h.children.get(r);l.part;let n=t(h.part,i);if(n===i)continue t;if(n||58!==i.charCodeAt(0)&&42!==i.charCodeAt(0)){if(n){let l=i.charCodeAt(n.length),s=h.children.get(r),a=h.part.slice(n.length+1),o=h.part.charCodeAt(n.length),d=h.part!==n;if(d){let t=e({part:i.slice(n.length+1)});h.part=n,h.children.set(l,t),h.children.set(o,e({part:a,children:{[r]:s}})),h.children.delete(r),h=t}else{let s=h.children.get(l);if(s){let c=i.slice(n.length+1);if(c===s.part){h=s;continue t}if(!s.part){h=s.children.get(r);continue t}s.part.charCodeAt(0);let a=t(c,s.part);s.part=s.part.slice(a.length);let o=e({part:c.slice(a.length)});h.children.set(l,e({part:c.slice(-1),children:{[s.part.charCodeAt(a.length-1)]:s,[c.charCodeAt(a.length-1)]:o}})),h=o;continue t}if(c)break;let a=e({part:i.slice(n.length+1)});h.children.set(l,a),h=a}}else if(h.part){let t=e({part:i.slice(1)}),r={...h};r.part=r.part.slice(1);let l=e({children:{[h.part.charCodeAt(0)]:r,[i.charCodeAt(0)]:t}});h.part="",h.children=l.children,h=t}else{let t=e({part:i.slice(1)});h.children.set(i.charCodeAt(0),t),h=t}continue t}}if(i.includes(":")){if(h.children.has(58)){h=h.children.get(58);continue}h.children.set(58,r(i.slice(1))),h=h.children.get(58)}else if(i.includes("*")){h.children.set(42,e()),h=h.children.get(42);break t}else{if(c){h.static||(h.static={}),h.static[i]=n;return}h.part=i}}h.store=n}remove(t,e){let r=new Raikiri;for(let l=0;l<this.history.length;l++){let[i,n,h]=this.history[l];(i!==t||n!==e)&&r.add(i,n,h)}this.history=r.history,this.root=r.root}match(t,e){let r=this.root[t];if(!r)return;let i=r.static?.[e];return i?{store:i,params:{}}:l(e.slice(1),r,{})}_m(t,e){let r=this.root[t];if(r)return l(e.slice(1),r,{})}}let l=(t,e,r)=>{let l=e.children.get(t.charCodeAt(e.part?.length));if(!l){let l=e.children.get(58);if(l){let n=t.indexOf("/",e.part.length);return -1===n?(r[l.param]=t.slice(e.part.length),l.store)?{store:l.store,params:r}:void 0:(r[l.param]=t.slice(e.part.length,n),i(t.slice(n),e.children.get(58),r))}if(e.children.has(42)){r["*"]=t.slice(e.part.length);let l=e.children.get(42).store;return l?{store:l,params:r}:void 0}return e.store?{store:e.store,params:r}:void 0}return i(t.slice(e.part.length+1),l,r)},i=(t,e,r)=>{let l=e.static?.[t];if(l)return{store:l,params:r};let n=e.children.get(t.charCodeAt(e.part?.length));if(!n){let l=e.children.get(58);if(l){let n=t.indexOf("/",e.part.length);return -1===n?(r[l.param]=t.slice(e.part.length),l.store)?{store:l.store,params:r}:void 0:(r[l.param]=t.slice(e.part.length,n),i(t.slice(n),e.children.get(58),r))}if(e.children.has(42)){e.part?r["*"]=t.slice(e.part.length):r["*"]=t;let l=e.children.get(42).store;return l?{store:l,params:r}:void 0}return e.store?{store:e.store,params:r}:void 0}return i(t.slice(e.part.length+1),n,r)};export default Raikiri;
{
"name": "raikiri",
"version": "0.1.0-beta.2",
"version": "0.1.1",
"description": "Elysia's Radix tree router",

@@ -5,0 +5,0 @@ "author": {

@@ -318,2 +318,9 @@ const COLON = 58

}
private _m(method: string, path: string) {
const node = this.root[method]
if (!node) return
return iterateFirst(path.slice(1), node, {})
}
}

@@ -320,0 +327,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc