PathStore.isActive()method
Based on the current store path, is a path active (i.e. equal to the current path)?
isActive(path: AbsolutePath): boolean
new PathStore(path: AbsolutePath | RelativePath = ".", base: AbsolutePath = "/")
| Param | Type | |
|---|---|---|
path | AbsolutePathRelativePath | The initial value for the store (defaults to ., resolved against base). Defaults to "." |
base | AbsolutePath | The base path to resolve relative paths against (defaults to /). Defaults to "/" |
| Return | |
|---|---|
PathStore | Store an absolute path, e.g. /a/b/c |
| Property | Type | |
|---|---|---|
.base | AbsolutePath | Base path that relative inputs are resolved against. required readonly |
Store an absolute path, e.g. /a/b/c
this.base.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.
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 pathThe constructor takes an optional second base argument (default /) used to resolve relative paths assigned to the store.
const store = new PathStore("/a/b");
store.isActive("/a/b"); // true
store.getPath("c"); // "/a/b/c"Based on the current store path, is a path active (i.e. equal to the current path)?
isActive(path: AbsolutePath): boolean
Based on the current store path, is a path proud (i.e. an ancestor of the current store path)?
isProud(path: AbsolutePath): boolean
Get an absolute path from a path relative to the current store path.
getPath(path: AbsolutePath | RelativePath): AbsolutePath