🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

memory-fs

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memory-fs

A simple in-memory filesystem. Holds data in a javascript object.

0.5.0
latest
Version published
Weekly downloads
12M
9.65%
Maintainers
1
Weekly downloads
 
Created

What is memory-fs?

The memory-fs npm package is an in-memory filesystem that mimics the Node.js fs module. It allows you to create, read, write, and delete files and directories in memory, which can be useful for testing or when you need a temporary filesystem that does not interact with the actual disk.

What are memory-fs's main functionalities?

Creating and writing files

This feature allows you to create new files and write content to them, similar to fs.writeFileSync in Node.js.

{"const MemoryFS = require('memory-fs');\nconst fs = new MemoryFS();\nfs.writeFileSync('/my-file.txt', 'Hello World');"}

Reading files

This feature allows you to read the contents of files that exist in the in-memory filesystem.

{"const MemoryFS = require('memory-fs');\nconst fs = new MemoryFS();\nfs.writeFileSync('/my-file.txt', 'Hello World');\nconst content = fs.readFileSync('/my-file.txt', 'utf-8');"}

Creating directories

This feature allows you to create directories within the in-memory filesystem.

{"const MemoryFS = require('memory-fs');\nconst fs = new MemoryFS();\nfs.mkdirSync('/my-directory');"}

Deleting files and directories

This feature allows you to delete files and directories from the in-memory filesystem.

{"const MemoryFS = require('memory-fs');\nconst fs = new MemoryFS();\nfs.writeFileSync('/my-file.txt', 'Hello World');\nfs.unlinkSync('/my-file.txt');\nfs.mkdirSync('/my-directory');\nfs.rmdirSync('/my-directory');"}

Other packages similar to memory-fs

Keywords

FAQs

Package last updated on 08 Oct 2019

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