1.5.3 • Published 2 years ago
flexi-path v1.5.3
flexi-path
Flexible path builder and walker
Installation
npm install flexi-path
Test
npm test
Example
Build paths
import flexi from "flexi-path";
const path = flexi.path("path").append("other");
const prependedPath = path.prepend("prepended");
const finalPath = prependedPath.prepend(__dirName).append("someFile.js");
finalPath.write();
//==> {cur dir}/prepended/path/other/someFile.js
Walk paths
import flexi from "flexi-path";
const path = flexi.path("path/to/existing/file.js");
flexi.walk.forward(path);
//==> ["path", "to", "existing", "file.js"]
const existingPath = flexi.path("existing/path");
const completePath = existingPath.append("some/non/existing/parts");
const result = flexi.walk.back(restOfPath, { until: until.exists() });
//==> existing/path
Compare paths
import flexi from "flexi-path";
const common = flexi.path("/common/root");
const first = flexi.path("first/path");
const second = flexi.path("second/path");
const diff = common.append(first).diff(common.append(second));
//==> [
first
second
]
const intersect = first.intersect(second);
//==> path
const except = first.except(second);
//==> first/second
const equals = flexi.path("path").equals("path");
//==> true
flexi.path("").isEmpty()
//==> true
Manipulate paths
const path = flexi.path("one/two/three/four/five/six");
const reversed = path.reverse();
//==> six/five/four/three/two/one
const cut = reversed.cut(4);
//==> six/five
const flat = cut.flatten();
//==> [
six
five
]
1.5.3
2 years ago
1.5.2
3 years ago
1.5.0
3 years ago
1.4.1
3 years ago
1.4.0
4 years ago
1.3.0
4 years ago
1.2.1
5 years ago
1.2.0
5 years ago
1.0.0
5 years ago
0.2.0
6 years ago
0.1.2-beta.16
6 years ago
0.1.2-beta.15
6 years ago
0.1.2-beta.12
6 years ago
0.1.2-beta.11
6 years ago
0.1.2-beta.10
6 years ago
0.1.2-beta.9
6 years ago
0.1.2-beta.8
6 years ago
0.1.2-beta.7
6 years ago
0.1.2-beta.5
6 years ago
0.1.2-beta.3
6 years ago
0.1.2-beta.2
6 years ago
0.1.2-beta.1
6 years ago
0.1.2
6 years ago
0.1.1
6 years ago
0.1.0
6 years ago