UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

25 lines (24 loc) 847 B
import { isPathActive, isPathProud, requirePath } from "../util/path.js"; import { Store } from "./Store.js"; /** Store an absolute path, e.g. `/a/b/c` */ export class PathStore extends Store { constructor(path = ".", time) { super(requirePath(path), time); } /** Based on the current store path, is a path active? */ isActive(path) { return isPathActive(this.value, path); } /** Based on the current store path, is a path proud (i.e. a child of the current store path)? */ isProud(path) { return isPathProud(this.value, path); } /** Get an absolute path from a path relative to the current store path. */ getPath(path) { return requirePath(path, this.value); } // Override to clean the path. set(path) { super.set(requirePath(path, this.value)); } }