Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
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.
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'));
Similar to fs-monkey, memfs provides an in-memory file system that mimics the Node.js fs module. While fs-monkey offers utilities to patch or virtualize the fs module, memfs focuses more on creating an in-memory file system that can be used directly or with fs-monkey for patching the global fs.
Unionfs is another package that is closely related to fs-monkey, specifically to its union file system functionality. It allows you to transparently overlay multiple file systems into one cohesive file system. While fs-monkey provides this functionality through its ufs feature, unionfs is dedicated solely to creating and managing union file systems.
Monkey-patches for filesystem related things.
require
function to load Node's modules from memory.fs
filesystem module.npm install --save fs-monkey
An fs-like object is an object that implements methods of Node's
filesystem API.
It is denoted as vol
:
let vol = {
readFile: () => { /* ... */ },
readFileSync: () => { /* ... */ },
// etc...
}
patchFs
- rewrites Node's filesystem module fs
with fs-like object vol
patchRequire
- rewrites require
function, patches Node's module
module to use a given fs-like object for module loadingUnlicense - public domain.
FAQs
Monkey patches for file system related things.
We found that fs-monkey demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.