Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filesystem2use

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filesystem2use

A collection of helpers for the Filesystem Facility

  • 0.0.8
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

🚀 graph-fs

Allow to browse files like a graph where each file or directory is a node.

const {Node} = require("graph-fs");

Instantiate

const directory = new Node("/path/to/directory");

const file = directory.resolve('file.ext');
const sameFile = new Node("/path/to/directory/file.ext");

sameFile === file; // true (same instance)

Get infos

myFile.exists; // boolean

myFile.is.file; // true
myFile.is.directory; // false

myDirectory.is.directory; // true
myDirectory.is.file; // false

Path & name

myDirectory.toString(); // "/path/to/directory/"
myDirectory.absolute; // "/path/to/directory"
myDirectory.name; // "directory"

myFile.toString(); // "/path/to/file.ext"
myFile.absolute; //   "/path/to/file.ext"
myFile.name; // "file.ext"

Navigate

const parent = file.parent
const sameParent = file.resolve("..")
parent === sameParent // true

Read

directory.children; // Node[] of files and directories
file.getContent([options = "utf8"]); // string

Create


 // create a new directory
const newDirectory = directory.newDirectory("new-directory");

// create a directory recursively
const target = dir.resolve('this/path/does/not/exists');
target.exists; // false
target.asDirectoryRecursively();
target.exists; // true
target.is.directory; // true

Write

// create a new file
const newFile = directory.newFile("newFile.ext", [content]);

// force to write a file, even if it or its parents, still don't exist. It will create the full path to it.
file.overwrite(contentString);

Rename

const changedDir = directory.rename('changed'); // Node instance
directory.exists; // false
changedDir.exists; // true

Copy

const me2 = directory.copy('me2'); // Node instance
directory.exists; // true
me2.exists; // true

Move

const newLocation = directory.move('newLocation'); // Node instance
directory.exists; // false
newLocation.exists; // true

Clean

directory.clear() // delete all what's inside the directory
directory.delete() // delete the directory

Keywords

FAQs

Package last updated on 01 Dec 2022

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc