@coverbase/radix
Advanced tools
| export type Match<T> = { | ||
| value: T; | ||
| parameters: Record<string, string>; | ||
| }; | ||
| export declare class Radix<T> { | ||
| value?: T; | ||
| parameter?: string; | ||
| children: Record<string, Radix<T>>; | ||
| constructor(parameter?: string); | ||
| insert: (key: string, value: T) => void; | ||
| match: (key: string) => Match<T> | undefined; | ||
| } | ||
| export declare const combineRadix: <T>(firstNode: Radix<T>, secondNode: Radix<T>) => Radix<T>; |
| export {}; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| class G{rootNode;constructor(){this.rootNode=E()}insert=(q,A)=>{let j=this.rootNode;for(let w of q.split("/")){const z=w.startsWith(":"),B=z?":":w;let D=j.children[B];if(D===void 0)D=z?E(w.substring(1)):E(),j.children[B]=D;j=D}j.value=A};match=(q,A)=>{let j=this.rootNode;for(let w of q.split("/")){const z=j.children[w]??j.children[":"];if(z){if(j=z,j.parameter)A[j.parameter]=w}}return j.value};merge=(q)=>{this.rootNode=F(this.rootNode,q.rootNode)}}var E=(q)=>{return{parameter:q,children:{}}},F=(q,A)=>{const j=E();j.value=q.value!==void 0?q.value:A.value,j.parameter=q.parameter!==void 0?q.parameter:A.parameter;for(let w of new Set([...Object.keys(q.children),...Object.keys(A.children)])){const z=q.children[w],B=A.children[w];if(z&&B)j.children[w]=F(z,B);else if(z)j.children[w]=z;else if(B)j.children[w]=B}return j};export{E as createNode,F as combineNodes,G as Radix}; | ||
| class D{value;parameter;children;constructor(q){this.parameter=q,this.children={}}insert=(q,T)=>{let j=this;for(let w of q.split("/")){const z=w.startsWith(":"),A=z?":":w;let B=j.children[A];if(B===void 0)B=z?new D(w.substring(1)):new D,j.children[A]=B;j=B}j.value=T};match=(q)=>{let T=this;const j={};for(let w of q.split("/"))if(T=T.children[w]??T.children[":"],T?.parameter)j[T.parameter]=w;if(T?.value)return{value:T.value,parameters:j}}}var E=(q,T)=>{const j=new D;j.value=q.value!==void 0?q.value:T.value,j.parameter=q.parameter!==void 0?q.parameter:T.parameter;for(let w of new Set([...Object.keys(q.children),...Object.keys(T.children)])){const z=q.children[w],A=T.children[w];if(z&&A)j.children[w]=E(z,A);else if(z)j.children[w]=z;else if(A)j.children[w]=A}return j};export{E as combineRadix,D as Radix}; |
+1
-1
| { | ||
| "name": "@coverbase/radix", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "type": "module", | ||
@@ -5,0 +5,0 @@ "exports": { |
| export type Node<T> = { | ||
| value?: T; | ||
| parameter?: string; | ||
| children: Record<string, Node<T>>; | ||
| }; | ||
| export declare class Radix<T> { | ||
| rootNode: Node<T>; | ||
| constructor(); | ||
| insert: (key: string, value: T) => void; | ||
| match: (key: string, parameters: Record<string, string>) => T | undefined; | ||
| merge: (radix: Radix<T>) => void; | ||
| } | ||
| export declare const createNode: <T>(parameter?: string) => Node<T>; | ||
| export declare const combineNodes: <T>(firstNode: Node<T>, secondNode: Node<T>) => Node<T>; |
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
4
33.33%1738
-7.26%