0.0.3 • Published 1 year ago

rrat v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

RRAT

Rrat is a simple radix tree data structure implementation specialized for routing. It is inspired by radix3.

Installation

pnpm i rrat

Usage

import { createRadixTree } from "rrat";

const tree = createRadixTree();
testTree.insert("", "root");
/*
  {
      name: "/",
      content: "root"
  }
*/
testTree.search("/");

testTree.insert("/foo", "foo");
/*
  {
      name: "/foo",
      content: "foo"
  }
*/
testTree.search("/foo");

testTree.insert("/test/:param/1", "testParam");
/*
  {
      name: "/test/random/1",
      content: "testParam",
      params: Map {
        "param" => "random"
      }
  }
*/
testTree.search("/test/random/1");

More examples can be found in the test directory.

Currently, all leading and trailing slashes are ignored. This may change in the future.

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago