PathStoreclass

new PathStore(path: AbsolutePath | RelativePath = ".", base: AbsolutePath = "/")
ParamType
pathAbsolutePath
RelativePath
The initial value for the store (defaults to ., resolved against base). Defaults to "."
baseAbsolutePath
The base path to resolve relative paths against (defaults to /). Defaults to "/"
Return
PathStore
Store an absolute path, e.g. /a/b/c
PropertyType
.baseAbsolutePath
Base path that relative inputs are resolved against. required readonly

Store an absolute path, e.g. /a/b/c

  • Accepts absolute or relative paths as input and normalises them to an absolute path against this.base.
  • Provides helpers to test whether other paths are active or proud relative to the current path.

A Store for an absolute path such as /a/b/c. PathStore resolves any relative path assigned to it against a fixed base, and adds route-matching helpers useful for navigation state.

Usage

ts
import { PathStore } from "shelving/store";

const route = new PathStore("/products/42");

route.value = "../43";              // resolved against the current path → "/products/43"

route.isActive("/products/43");     // true — exact match of the current path
route.isProud("/products");         // true — current path is at or below "/products"
route.getPath("./reviews");         // "/products/43/reviews" — resolve a relative path

The constructor takes an optional second base argument (default /) used to resolve relative paths assigned to the store.

Examples

const store = new PathStore("/a/b");
store.isActive("/a/b"); // true
store.getPath("c"); // "/a/b/c"

Methods

Go

PathStore.isActive()method

Based on the current store path, is a path active (i.e. equal to the current path)?

isActive(path: AbsolutePath): boolean
Go

PathStore.isProud()method

Based on the current store path, is a path proud (i.e. an ancestor of the current store path)?

isProud(path: AbsolutePath): boolean
Go

PathStore.getPath()method

Get an absolute path from a path relative to the current store path.

getPath(path: AbsolutePath | RelativePath): AbsolutePath