You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

fs-monkey

Package Overview
Maintainers
1
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Source code not available
We could not scan this package. Some page functionalities have been disabled

fs-monkey

Monkey patches for file system related things.

1.1.0
latest
Source
npmnpm
Version published
Weekly downloads
16M
0.55%
Maintainers
1
Weekly downloads
 
Created

What is fs-monkey?

The fs-monkey package is a utility library for Node.js that allows you to patch or virtualize the Node.js file system (fs) module. This can be particularly useful for testing purposes, where you might want to avoid performing I/O operations on the actual file system. It provides functionalities to patch the global fs module, or to create a virtual file system that can be used independently.

What are fs-monkey's main functionalities?

Patching the global fs module

This feature allows you to patch the global fs module with a virtual file system. In the code sample, a virtual file system is created with a single file '/foo.txt' containing the text 'bar'. The global fs module is then patched, so any subsequent fs operations in the process will interact with this virtual file system instead of the real one.

const {patchFs} = require('fs-monkey');
const {Volume} = require('memfs');
const vol = Volume.fromJSON({'/foo.txt': 'bar'});
patchFs(vol);

Creating a union file system

This feature allows you to create a union file system, which combines multiple file systems into a single coherent file system interface. In the code sample, a virtual file system is created and then combined with the real fs module using the union file system. This allows for fallback to the real file system for files not found in the virtual file system.

const {ufs} = require('fs-monkey');
const {Volume} = require('memfs');
const vol = Volume.fromJSON({'/foo.txt': 'bar'});
ufs.use(vol);
ufs.use(require('fs'));

Other packages similar to fs-monkey

Keywords

fs

FAQs

Package last updated on 18 Jul 2025

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