/** * A broadcast path that provides safe prefix matching operations. * * This module provides path-aware operations that respect delimiter boundaries, * preventing issues like "foo" matching "foobar". * * Paths are automatically trimmed of leading and trailing slashes on creation, * making all slashes implicit at boundaries. * All paths are RELATIVE; you cannot join with a leading slash to make an absolute path. * * @example * ```typescript * // Creation automatically trims slashes * const path1 = Path.from("/foo/bar/"); * const path2 = Path.from("foo/bar"); * console.log(path1 === path2); // true * * // Multiple arguments are joined with "/" * const path3 = Path.from("api", "v1", "users"); * console.log(path3); // "api/v1/users" * * // Safe prefix matching * const base = Path.from("api/v1"); * console.log(Path.hasPrefix(Path.from("api"), base)); // true * console.log(Path.hasPrefix(Path.from("api/v1"), base)); // true * * const joined = Path.join(base, Path.from("users")); * console.log(joined); // "api/v1/users" * ``` */ export type Valid = string & { __brand: "Name"; }; /** Build a path from one or more components, joining with "/" and trimming redundant slashes. */ export declare function from(...paths: string[]): Valid; /** * Check if a path has the given prefix, respecting path boundaries. * * Unlike String.startsWith, this ensures that "foo" does not match "foobar". * The prefix must either: * - Be exactly equal to the path * - Be followed by a '/' delimiter in the original path * - Be empty (matches everything) * * @example * ```typescript * const path = Path.from("foo/bar"); * console.log(Path.hasPrefix(Path.from("foo"), path)); // true * console.log(Path.hasPrefix(Path.from("foo/"), path)); // true (trailing slash ignored) * console.log(Path.hasPrefix(Path.from("fo"), path)); // false * * const path2 = Path.from("foobar"); * console.log(Path.hasPrefix(Path.from("foo"), path2)); // false * ``` */ export declare function hasPrefix(prefix: Valid, path: Valid): boolean; /** * Strip the given prefix from a path, returning the suffix. * * Returns null if the prefix doesn't match according to hasPrefix rules. * * @example * ```typescript * const path = Path.from("foo/bar/baz"); * const suffix = Path.stripPrefix(Path.from("foo"), path); * console.log(suffix); // "bar/baz" * * const suffix2 = Path.stripPrefix(Path.from("foo/"), path); * console.log(suffix2); // "bar/baz" * * const noMatch = Path.stripPrefix(Path.from("notfound"), path); * console.log(noMatch); // null * ``` */ export declare function stripPrefix(prefix: Valid, path: Valid): Valid | null; /** * Join two path components together. * * @example * ```typescript * const base = Path.from("foo"); * const joined = Path.join(base, Path.from("bar")); * console.log(joined); // "foo/bar" * ``` */ export declare function join(path: Valid, other: Valid): Valid; /** The empty path, which is a prefix of every path. */ export declare function empty(): Valid; //# sourceMappingURL=path.d.ts.map