Socket
Book a DemoInstallSign in
Socket

flexi-path

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flexi-path

Flexible path builder and walker

1.5.3
latest
Source
npmnpm
Version published
Weekly downloads
34
Maintainers
1
Weekly downloads
 
Created
Source

flexi-path

Flexible path builder and walker

Build Status Codacy Badge GitHub top language code style: prettier Coverage Status David GitHub Pages GitHub npm

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
]

Keywords

builder

FAQs

Package last updated on 19 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.