• Stars
    star
    1,621
  • Rank 27,770 (Top 0.6 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated 10 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript file system utilities

memfs

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

  • Node's fs API implemented, see old API Status, missing list, missing opendir
  • 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.

More Repositories

1

react-use

React Hooks — 👍
TypeScript
37,122
star
2

libreact

Collection of useful React components
TypeScript
2,615
star
3

git-cz

Semantic Git commits
JavaScript
1,375
star
4

awesome-styleguides

A curated list of UI styleguides — 😎💄
1,193
star
5

use-media

useMedia React hook to track CSS media query state
TypeScript
515
star
6

json-joy

json-joy — JSON CRDT, JSON CRDT Patch, JSON Patch, JSON Predicate, JSON Patch Extended, JSON Patch+ OT, MessagePack codec, JSON-Rx, JSON-RPC 2.0, JSON Pointer, Reactive-RPC, random JSON generator, JSON Brand, JSON Expression, JSON Size, JSON Type, JSON Schema, JSON deep equality, JSON Binary, JSON clone / msgpack.org[JavaScript/TypeScript/NodeJS]
TypeScript
469
star
7

nano-css

Distilled CSS-in-JS for gourmet developers
JavaScript
412
star
8

freestyler

5th generation CSS-in-JS library
TypeScript
269
star
9

react-embed

Embed 3rd party widgets
TypeScript
234
star
10

unionfs

Use multiple fs modules at once
TypeScript
200
star
11

ass-js

Assembler.js — X86_64 and Ethereum
TypeScript
129
star
12

fs-monkey

Monkey-patches for file system related things
JavaScript
108
star
13

ts-easing

Easing functions in TypeScript
TypeScript
69
star
14

linkfs

Rewrite file system `fs` paths
TypeScript
52
star
15

awesome-css-animations

A curated list of CSS animation resources
48
star
16

jsx-plus-plus

Better JSX for busy developers
JavaScript
48
star
17

jskernel

Node.js exo-kernel dream - proposal
C
46
star
18

use-t

🗺 Translations with React hooks
TypeScript
42
star
19

libsys

POSIX/Linux/Mac system calls and low level operations for Node.js
C++
40
star
20

spyfs

Node filesystem spies and mocks
JavaScript
38
star
21

bamboo

Bamboo - Node.js clone in pure JavaScript
C
38
star
22

react-universal-interface

Universal Component Interface - FaCC, render prop, component prop, prop injection, HOC, decorator
TypeScript
38
star
23

thingies

Kitchen sink of helpful utilities.
TypeScript
37
star
24

memfs-webpack

Example of how to use memfs with webpack
JavaScript
37
star
25

libjs

libc implemented in JavaScript
TypeScript
35
star
26

react-use-media

react-media hook
TypeScript
27
star
27

md-mdast

Fast tiny Markdown to MDAST parser
TypeScript
21
star
28

react-micro-lifecycles

Life-cycles for React DOM elements
JavaScript
18
star
29

awesome-ci-recipes

Useful scripts and tricks for continuous integration
17
star
30

flexible-input

Autosizing <input> and <textarea> elements, which expand and shrink to fit contents
TypeScript
16
star
31

rx-use

RxJS DOM sensors
TypeScript
16
star
32

three-ducks

Distilled Redux for gourmet developers
JavaScript
15
star
33

fastest-json-copy

Fastest JSON deep clone implementation
JavaScript
14
star
34

react-simple-player

Lightweight React audio player component
TypeScript
14
star
35

pure-arr

Immutable pure Array.prototype functions
TypeScript
13
star
36

cross-ci

Travis, CircleCI, et. al. env vars normalized
JavaScript
13
star
37

jssh

JavaScript Shell
JavaScript
12
star
38

iconista

One NPM install, one React component — 💯+ icons
TypeScript
11
star
39

virtual-css

💄 Virtual CSS for virtual DOM libraries
TypeScript
11
star
40

set-harmonic-interval

one timer for all setInterval() with identical ms delay
TypeScript
11
star
41

hyperdyperid

Very fast base-36 ID generator and random integer generator for Node.js
JavaScript
11
star
42

content-ranking

Formulas for content ranking
TypeScript
11
star
43

entask

Micro- and Macro-tasks for Node and browsers
JavaScript
10
star
44

json-schema-serializer

Fast JSON.stringify with schema
TypeScript
10
star
45

modern-pick

Template string accessors to the selector rescue
TypeScript
10
star
46

stripe-web

Typesafe Stripe for browser
TypeScript
10
star
47

fast-shallow-equal

Very fast object shallow equal comparator
JavaScript
9
star
48

structured-interviews

Templates for structured interviews
JavaScript
9
star
49

ts-brand-json

TypeScript type for JSON-in-a-string
JavaScript
9
star
50

clickable-json

Interactive JSON and JSON CRDT editing and viewing React components
TypeScript
8
star
51

react-passport

React context for client-passport
TypeScript
8
star
52

state-containers

Simple state containers for your services and React apps
TypeScript
8
star
53

igit

Interactive CLI for semantic Git commit messages.
Go
8
star
54

sonic-forest

High performance tree and sorted map implementations for JavaScript in TypeScript
TypeScript
8
star
55

use-unmount

React hook which returns unmount observable
JavaScript
6
star
56

tree-dump

Simple console tree printing helpers
TypeScript
6
star
57

proofread

Proofread your Redux sagas.
JavaScript
6
star
58

crunchme

Pack your .js in a self-extracting compressed file
JavaScript
6
star
59

nodefs

THIS IS OLD, USE streamich/memfs INSTEAD
JavaScript
6
star
60

client-passport

Authentication for single-page apps
TypeScript
5
star
61

fasttrack

TypeScript boilerplate with commands
Shell
5
star
62

emoji-json-list

List of emojis, their aliases and unicode values
JavaScript
5
star
63

css-light

Light-weight module to write CSS in JavaScript
JavaScript
5
star
64

puppet-master

Executes Node.js function in a Chrome browser and returns result
JavaScript
5
star
65

code-colors-react

Code syntax highlighting React component
TypeScript
4
star
66

current-tick

Enqueue function to execute later within current event loop cycle
TypeScript
4
star
67

json-crdt-traces

JSON CRDT document sample change traces in JSON CRDT Patch format, for testing and benchmarking
TypeScript
4
star
68

mdast-flat

Flat version of MDAST format
TypeScript
4
star
69

elf

ELF structs
TypeScript
4
star
70

nmsg-rpc

RPC event based router for JavaScript bi-directional messaging
JavaScript
4
star
71

nano-css-extract-demo

Demo of nano-css extract addon - extracts CSS into an external style sheet
JavaScript
3
star
72

enwire

🐙 Rewire env vars
JavaScript
3
star
73

fslib

fs.js in pure JavaScript
TypeScript
3
star
74

libaio

asynchronous system call wrapper
JavaScript
3
star
75

typebase

C/C++ structs in Node.js
TypeScript
3
star
76

jml-h

JsonML + Virtual Hypertext generator (h)
JavaScript
3
star
77

code-colors

Code syntax highlighting for the web
TypeScript
3
star
78

collaborative-input

Collaboration-enabled HTML text editing elements: <input>, <textarea>, and [contenteditable]
TypeScript
3
star
79

v4-uuid

Simple UUID for browser without crypto dependency
TypeScript
2
star
80

socket.io-reqres

Request/response for socket.io
JavaScript
2
star
81

portable-example

portable.js web app tutorial
JavaScript
2
star
82

cpuid

cpuid x86 in JavaScript
JavaScript
2
star
83

node-multicore

Delightful multicore programming in Node.js
TypeScript
2
star
84

redux-oop

TypeScript
2
star
85

json-joy-php

JSON Pointer, JSON Patch and JSON Patch OT for PHP
PHP
2
star
86

xml-light

Simple XML/HTML in JavaScript
JavaScript
2
star
87

redis-joy

Fast and mean Redis 7+ cluster client written in TypeScript which supports RESP3 protocol
TypeScript
2
star
88

uint8-to-b64

Isomorphic Uint8Array conversion to Base64 string and back for browser and Node.js
JavaScript
1
star
89

md-jml

Markdown to JsonML parser in JavaScript
TypeScript
1
star
90

fs-zoo

File system abstractions and implementations
TypeScript
1
star
91

ci-scripts

Travis and CircleCI scripts
JavaScript
1
star
92

dom-copy

Copy to Clipboard
HTML
1
star
93

static-buffer

Execute machine code in your Buffer
JavaScript
1
star
94

utf8-bar

UTF8 % bar for terminal
JavaScript
1
star
95

p4-css

CSS for P4
TypeScript
1
star
96

logich

A light-weight extensible logging system written in Node.js way.
JavaScript
1
star
97

desigual

Syntax highlighter that outputs JsonML
JavaScript
1
star
98

json-joy-go

JSON Pointer (RFC 6901), JSON Patch (RFC 6902), JSON Predicate (IETF draft-snell-json-test-01) for GO
Go
1
star
99

tpl-ts-lib

Template for a TypeScript library.
JavaScript
1
star
100

json-joy-ruby

json-joy port to Ruby
Ruby
1
star