All Projects → streamich → Memfs

streamich / Memfs

Licence: unlicense
In-memory filesystem with Node's API

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Memfs

SimpleOS
Operating System Coded in Assembly and C
Stars: ✭ 72 (-91.57%)
Mutual labels:  filesystem, fs
fs.c
File system API much like Node's fs module (synchronous)
Stars: ✭ 65 (-92.39%)
Mutual labels:  filesystem, fs
watcher
The file system watcher that strives for perfection, with no native dependencies and optional rename detection support.
Stars: ✭ 37 (-95.67%)
Mutual labels:  filesystem, fs
Node Ntfs
Windows NT File System (NTFS) file system driver
Stars: ✭ 18 (-97.89%)
Mutual labels:  fs, filesystem
Chonky
😸 A File Browser component for React.
Stars: ✭ 313 (-63.35%)
Mutual labels:  fs, filesystem
sandboxed-fs
Sandboxed Wrapper for Node.js File System API
Stars: ✭ 41 (-95.2%)
Mutual labels:  filesystem, fs
gof
Yet another simple Go filesystem wrapper
Stars: ✭ 13 (-98.48%)
Mutual labels:  filesystem, fs
tabfs-specs
Specifications for the tabfs filesystem (osdev) | Mirror of https://codeark.it/Chalk-OS/tabfs-specs
Stars: ✭ 15 (-98.24%)
Mutual labels:  filesystem, fs
Tfs
Mirror of https://gitlab.redox-os.org/redox-os/tfs
Stars: ✭ 2,890 (+238.41%)
Mutual labels:  fs, filesystem
mongoose-gridfs
mongoose gridfs on top of new gridfs api
Stars: ✭ 79 (-90.75%)
Mutual labels:  filesystem, fs
MeowDB.js
Database in JSON (Node.JS Library)
Stars: ✭ 12 (-98.59%)
Mutual labels:  filesystem, fs
Electron Filesystem
FileSystem for windows
Stars: ✭ 409 (-52.11%)
Mutual labels:  fs, filesystem
unionfs
Use multiple fs modules at once
Stars: ✭ 170 (-80.09%)
Mutual labels:  filesystem, fs
vue-fs
A Vue file management client, complete with a node/express/FS backend.
Stars: ✭ 40 (-95.32%)
Mutual labels:  filesystem, fs
fu
Unix's Find, Unleashed.
Stars: ✭ 32 (-96.25%)
Mutual labels:  filesystem, fs
korefile
File System API for Local/GitHub.
Stars: ✭ 29 (-96.6%)
Mutual labels:  filesystem, fs
fs-fuse
Export any Node.js `fs`-like object as a FUSE filesystem
Stars: ✭ 32 (-96.25%)
Mutual labels:  filesystem, fs
rxnode
Rxnode - a small and fast wrapper around the nodejs API using RxJS.
Stars: ✭ 24 (-97.19%)
Mutual labels:  filesystem, fs
webpack-plugin-ramdisk
🐏 A webpack plugin for blazing fast builds on a RAM disk / drive
Stars: ✭ 118 (-86.18%)
Mutual labels:  memory, in-memory
Filer
Node-like file system for browsers
Stars: ✭ 389 (-54.45%)
Mutual labels:  fs, filesystem

memfs

In-memory file-system with Node's fs API.

  • Node's fs API implemented, see API Status
  • Stores files in memory, in Buffers
  • Throws sameish* errors as Node.js
  • Has concept of i-nodes
  • Implements hard links
  • Implements soft links (aka symlinks, symbolic links)
  • Permissions may* be implemented in the future
  • Can be used in browser, see memfs-webpack

Install

npm install --save memfs

Usage

import { fs } from 'memfs';

fs.writeFileSync('/hello.txt', 'World!');
fs.readFileSync('/hello.txt', 'utf8'); // World!

Create a file system from a plain JSON:

import { fs, vol } from 'memfs';

const json = {
  './README.md': '1',
  './src/index.js': '2',
  './node_modules/debug/index.js': '3',
};
vol.fromJSON(json, '/app');

fs.readFileSync('/app/README.md', 'utf8'); // 1
vol.readFileSync('/app/src/index.js', 'utf8'); // 2

Export to JSON:

vol.writeFileSync('/script.sh', 'sudo rm -rf *');
vol.toJSON(); // {"/script.sh": "sudo rm -rf *"}

Use it for testing:

vol.writeFileSync('/foo', 'bar');
expect(vol.toJSON()).toEqual({ '/foo': 'bar' });

Create as many filesystem volumes as you need:

import { Volume } from 'memfs';

const vol = Volume.fromJSON({ '/foo': 'bar' });
vol.readFileSync('/foo'); // bar

const vol2 = Volume.fromJSON({ '/foo': 'bar 2' });
vol2.readFileSync('/foo'); // bar 2

Use memfs together with unionfs to create one filesystem from your in-memory volumes and the real disk filesystem:

import * as fs from 'fs';
import { ufs } from 'unionfs';

ufs.use(fs).use(vol);

ufs.readFileSync('/foo'); // bar

Use fs-monkey to monkey-patch Node's require function:

import { patchRequire } from 'fs-monkey';

vol.writeFileSync('/index.js', 'console.log("hi world")');
patchRequire(vol);
require('/index'); // hi world

Docs

See also

  • spyfs - spies on filesystem actions
  • unionfs - creates a union of multiple filesystem volumes
  • linkfs - redirects filesystem paths
  • fs-monkey - monkey-patches Node's fs module and require function
  • libfs - real filesystem (that executes UNIX system calls) implemented in JavaScript

License

Unlicense - public domain.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].