Skip to content

Commit

Permalink
feat: pathString
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan committed Sep 16, 2019
1 parent 5085fee commit def79ed
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/index.ts
@@ -1,5 +1,6 @@
import { flexi } from "./lib";

export { until } from "./lib/walker";
export * from "./types";

export default flexi;
3 changes: 1 addition & 2 deletions src/lib/flexi.ts
Expand Up @@ -12,10 +12,9 @@ const flexi: Flexi = {
isEmpty,
isRoot,
path,
pathString,
root,
walk
};

export * from "../types";

export default flexi;
5 changes: 5 additions & 0 deletions src/types/Flexi.ts
Expand Up @@ -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`
*/
Expand Down
13 changes: 13 additions & 0 deletions 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";
Expand Down Expand Up @@ -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);
});
});
});
});

0 comments on commit def79ed

Please sign in to comment.