
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
Simple in-memory vinyl file store.
You access a file using store#get() method. If the file is in memory, it will be used. Otherwise, we'll load the file from the file-system.
import { create } from 'mem-fs';
const store = create();
store.get('/test/file.txt');
When trying to load a file we cannot read from disk, an empty Vinyl file will be returned. The contents of this file will be set to null.
Trying to get a directory or any invalid files will also return an empty Vinyl file pointer.
You update file references by using store#add() method. This method take a vinyl file object as parameter.
import File from 'vinyl';
import { create } from 'mem-fs';
const coffeeFile = new File({
cwd: '/',
base: '/test/',
path: '/test/file.coffee',
contents: new Buffer('test = 123'),
});
const store = create();
store.add(coffeeFile);
Using store#each(cb(file, index)), you can iterate over every file stored in the file system.
Using store#all(), you can get every file stored in the file system.
Using store#existsInMemory(), you can check if the file already exists in the file system without loading it from disk.
Using store#stream(), you can create a stream with every file stored in the file system.
store#pipeline() generates a new map with yielded files in transforms.
If no transform is passed, files references are updated.
The mock-fs package provides a way to mock the file system in Node.js. It allows you to create a virtual file system for testing purposes. Unlike mem-fs, which focuses on in-memory file operations, mock-fs is designed to mock the entire file system, making it suitable for more comprehensive testing scenarios.
The fs-extra package extends the native Node.js file system module with additional methods and features. While it does not provide an in-memory file system, it offers a wide range of file manipulation utilities that can be useful for various file operations. It is more focused on enhancing the existing file system capabilities rather than providing an in-memory solution.
The vinyl-fs package is a file system adapter for the Vinyl virtual file format, commonly used in the Gulp build system. It allows you to work with files in a stream-based manner. While it does not provide an in-memory file system, it offers a flexible way to handle file operations in build processes.
FAQs
Simple in-memory vinyl file store
The npm package mem-fs receives a total of 787,137 weekly downloads. As such, mem-fs popularity was classified as popular.
We found that mem-fs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.