Gathering detailed insights and metrics for @cowasm/memfs
Gathering detailed insights and metrics for @cowasm/memfs
Gathering detailed insights and metrics for @cowasm/memfs
Gathering detailed insights and metrics for @cowasm/memfs
In-memory filesystem with Node's API (forked from upstream memfs since there are longstanding bugs)
npm install @cowasm/memfs
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (99.9%)
JavaScript (0.1%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Unlicense License
2 Stars
1,044 Commits
3 Watchers
1 Branches
Updated on Feb 17, 2024
Latest Version
3.5.1
Package Id
@cowasm/memfs@3.5.1
Unpacked Size
154.46 kB
Size
35.09 kB
File Count
32
NPM Version
8.19.2
Node Version
19.0.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This is a fork of https://www.npmjs.com/package/memfs, since there's a bunch of critical bugs and missing maintenance there, which might not be a priority for that project, but are definitely a priority for me (though I'm sending PR's). Upstream memfs has nearly 12 million downloads a week, so I can see why doing these changes would be really scary there!
Things I've done here include:
See https://github.com/sagemathinc/memfs-js
In-memory file-system with Node's fs
API.
fs
API implemented, see old API Status, missing list, missing opendir
Buffer
smemfs-webpack
1npm install --save memfs
1import { fs } from "memfs"; 2 3fs.writeFileSync("/hello.txt", "World!"); 4fs.readFileSync("/hello.txt", "utf8"); // World!
Create a file system from a plain JSON:
1import { fs, vol } from "memfs"; 2 3const json = { 4 "./README.md": "1", 5 "./src/index.js": "2", 6 "./node_modules/debug/index.js": "3", 7}; 8vol.fromJSON(json, "/app"); 9 10fs.readFileSync("/app/README.md", "utf8"); // 1 11vol.readFileSync("/app/src/index.js", "utf8"); // 2
Export to JSON:
1vol.writeFileSync("/script.sh", "sudo rm -rf *"); 2vol.toJSON(); // {"/script.sh": "sudo rm -rf *"}
Use it for testing:
1vol.writeFileSync("/foo", "bar"); 2expect(vol.toJSON()).toEqual({ "/foo": "bar" });
Create as many filesystem volumes as you need:
1import { Volume } from "memfs";
2
3const vol = Volume.fromJSON({ "/foo": "bar" });
4vol.readFileSync("/foo"); // bar
5
6const vol2 = Volume.fromJSON({ "/foo": "bar 2" });
7vol2.readFileSync("/foo"); // bar 2
Use memfs
together with unionfs
to create one filesystem
from your in-memory volumes and the real disk filesystem:
1import * as fs from "fs"; 2import { ufs } from "unionfs"; 3 4ufs.use(fs).use(vol); 5 6ufs.readFileSync("/foo"); // bar
Use fs-monkey
to monkey-patch Node's require
function:
1import { patchRequire } from "fs-monkey"; 2 3vol.writeFileSync("/index.js", 'console.log("hi world")'); 4patchRequire(vol); 5require("/index"); // hi world
spyfs
- spies on filesystem actionsunionfs
- creates a union of multiple filesystem volumeslinkfs
- redirects filesystem pathsfs-monkey
- monkey-patches Node's fs
module and require
functionlibfs
- real filesystem (that executes UNIX system calls) implemented in JavaScriptUnlicense - public domain.
No vulnerabilities found.
No security vulnerabilities found.