path-tool

1.0.4 • Public • Published

path-tool

path tool

Install

npm install path-tool

Usage & Api

var path_tool = require("path-tool");

//.dirPart(path, removeTailSlash)		//like path.dirname() + "/"

(path_tool.dirPart("aaa/bbb") === "aaa/") &&
(path_tool.dirPart("aaa/bbb/") === "aaa/") &&
(path_tool.dirPart("aaa\\bbb") === "aaa\\") &&		//will not change original '/' or '\\'
(path_tool.dirPart("aaa\\bbb\\") === "aaa\\") &&

(path_tool.dirPart("aaa\\bbb\\", true) === "aaa") &&		//argument: removeTailSlash

(path_tool.dirPart("/") === "") &&
(path_tool.dirPart("\\") === "") &&

(path_tool.dirPart("/aa") === "/") &&
(path_tool.dirPart("\\aa") === "\\") &&
(path_tool.dirPart("aa/") === "") &&
(path_tool.dirPart("aa\\") === "");

//.normalize(path)		//like path.normalize()

(path_tool.normalize("aaa///\\//\\//bbb") === "aaa/bbb") &&		//shrink //
(path_tool.normalize("aaa\\///\\//\\//bbb") === "aaa\\bbb") &&

(path_tool.normalize("/./aaa") === "/aaa") &&		//shrink /./
(path_tool.normalize("./aaa") === "aaa") &&

(path_tool.normalize("aaa/./") === "aaa/") &&
(path_tool.normalize("aaa/.") === "aaa/") &&

(path_tool.normalize("aaa/./bbb") === "aaa/bbb") &&
(path_tool.normalize("aaa/././bbb") === "aaa/bbb") &&
(path_tool.normalize("aaa/./bbb/././ccc") === "aaa/bbb/ccc") &&

(path_tool.normalize("aaa/../bbb") === "bbb") &&		//shrink dir/../
(path_tool.normalize("/aaa/../bbb") === "/bbb") &&

(path_tool.normalize("/../bbb") === "/../bbb") &&
(path_tool.normalize("../bbb") === "../bbb") &&

(path_tool.normalize("bbb/../") === "") &&
(path_tool.normalize("bbb/..") === "") &&
(path_tool.normalize("/bbb/../") === "/") &&
(path_tool.normalize("/bbb/..") === "/") &&

(path_tool.normalize("aaa/bbb/ccc/../../ddd") === "aaa/ddd") &&
(path_tool.normalize("aaa/bbb/../ccc/../../ddd") === "ddd") &&

(path_tool.normalize("aaa/bbb/../ccc/../../../ddd") === "../ddd") &&
(path_tool.normalize("/aaa/bbb/../ccc/../../../ddd") === "/../ddd") &&
(path_tool.normalize("../aaa/bbb/../ccc/../../../ddd") === "../../ddd");

Readme

Keywords

Package Sidebar

Install

npm i path-tool

Weekly Downloads

1

Version

1.0.4

License

ISC

Unpacked Size

8.04 kB

Total Files

4

Last publish

Collaborators

  • adf0001