New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

flowfs

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flowfs

A filesystem abstraction doesn't interrupt your flow

latest
npmnpm
Version
5.2.1
Version published
Weekly downloads
3
Maintainers
0
Weekly downloads
 
Created
Source

flowfs

I wrote flowfs because I could never remember the names and signatures of the fs and related APIs, and because manipulating paths as strings is awkward and error-prone. Dealing with files was always a point where I would be knocked out of the zone by having to refer to docs, and run throwaway tests to make sure I was doing it right.

flowfs attempts to solve these issues by exposing an intuitive API that represents files as objects. Navigation between nodes is via properties; for example, if you're implementing an "include" directive for a template language and need to calculate a relative path -- instead of this:

// old, bad, awkward, error-prone, annoying, hard-to-remember way:

const fs = require("fs");
const path = require("path");

function include (templatePath, includePath) {
	let parent = fs.dirname(templatePath);
	
	return path.resolve(parent, includePath); // or something
}

... you would do this:

// flowfs way:

const fs = require("flowfs");

function include (templatePath, includePath) {
	return fs(templatePath).parent.child(includePath).path;
}

Instantiating and navigating between nodes doesn't do any IO, it just does string manipulation internally -- fs("/path/to/non-existent/file") is perfectly valid, and is the recommended way to create new files with flowfs, for example:

await fs("/new/file").write("some data");

FAQs

Package last updated on 25 Aug 2024

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