diff --git a/src/index.ts b/src/index.ts index 317d3e1..2d12d09 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import { flexi } from "./lib"; export { until } from "./lib/walker"; +export * from "./types"; export default flexi; diff --git a/src/lib/flexi.ts b/src/lib/flexi.ts index 9d65add..b6c4d32 100644 --- a/src/lib/flexi.ts +++ b/src/lib/flexi.ts @@ -12,10 +12,9 @@ const flexi: Flexi = { isEmpty, isRoot, path, + pathString, root, walk }; -export * from "../types"; - export default flexi; diff --git a/src/types/Flexi.ts b/src/types/Flexi.ts index b660950..84ed311 100644 --- a/src/types/Flexi.ts +++ b/src/types/Flexi.ts @@ -18,6 +18,11 @@ export interface Flexi { */ path: (path: Path) => FlexiPath; + /** + * Returns the string path of a `path` + */ + pathString: (path: Path) => string; + /** * Concatinates multiple `paths` into a new `path` */ diff --git a/test/path/parse/pathString.test.ts b/test/path/parse/pathString.test.ts index 93b56d7..f1e7720 100644 --- a/test/path/parse/pathString.test.ts +++ b/test/path/parse/pathString.test.ts @@ -1,5 +1,6 @@ import { normalize } from "path"; +import flexi from "../../../src/lib/flexi"; import { empty as emptyPath } from "../../../src/lib/path"; import { empty as emptyMeta } from "../../../src/lib/path/meta"; import pathString from "../../../src/lib/path/parse/pathString"; @@ -32,6 +33,18 @@ describe("path", () => { expect(pathString(path)).toBe("flexiPath"); }); + + it("can get pathString via flexi", () => { + const path = "path"; + + expect(flexi.pathString(flexi.path(path))).toBe(path); + expect(flexi.pathString({ ...emptyMeta(), ...{ path } })).toBe(path); + expect(flexi.pathString({ basePath: path, path })).toBe( + normalize("path/path") + ); + expect(flexi.pathString([path])).toBe(path); + expect(flexi.pathString(path)).toBe(path); + }); }); }); });