@softwareventures/maintain-project
Version:
Automatically create and maintain TypeScript projects with standard settings for Software Ventures Limited
18 lines • 687 B
JavaScript
import { chain } from "@softwareventures/chain";
import { foldFn, initial, push } from "@softwareventures/array";
export function resolvePathSegments(path) {
return chain(path)
.map(path => path.replace(/^\/*/u, ""))
.map(path => path.replace(/\/*$/u, ""))
.map(path => path.split(/\/+/u))
.map(foldFn((resolved, segment) => resolved == null
? null
: segment === "."
? resolved
: segment === ".." && resolved.length > 0
? initial(resolved)
: segment === ".."
? null
: push(resolved, segment), [])).value;
}
//# sourceMappingURL=path.js.map