• Stars
    star
    123
  • Rank 290,145 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 10 years ago
  • Updated 10 months ago

Reviews

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

Repository Details

Simple in-memory vinyl file store.

mem-fs

Simple in-memory vinyl file store.

Usage

Loading a file

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.

Adding/updating a file

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);

Iterating over the file system

Using store#each(cb(file, index)), you can iterate over every file stored in the file system.

Get all files

Using store#all(), you can get every file stored in the file system.

Check existence in the file system

Using store#existsInMemory(), you can check if the file already exists in the file system without loading it from disk.

Stream every file stored in the file system

Using store#stream(), you can create a stream with every file stored in the file system.

More Repositories

1

Inquirer.js

A collection of common interactive command line user interfaces.
TypeScript
19,956
star
2

mem-fs-editor

File edition helpers working on top of mem-fs (https://github.com/SBoudrias/mem-fs)
TypeScript
415
star
3

AST-query

Tentative to a simple JavaScript AST modification library
JavaScript
242
star
4

gulp-istanbul

Istanbul unit test coverage plugin for gulp.
JavaScript
185
star
5

class-extend

Backbone like `Class.extend` for Node.js
JavaScript
88
star
6

grouped-queue

In memory queue system prioritizing tasks
JavaScript
86
star
7

gruntfile-editor

An API to modify a Gruntfile.js content
JavaScript
40
star
8

readline2

Node.js Readline faรงade fixing bugs and issues in v0.8 and v0.10
JavaScript
27
star
9

gulp-exclude-gitignore

Gulp plugin to exclude file contained in .gitignore from the stream
JavaScript
27
star
10

run-async

Utility method to run function either synchronously or asynchronously using the common `this.async()` style.
JavaScript
23
star
11

require.replace

Require.js plugin to load conditionnal modules (i18n and such)
JavaScript
21
star
12

generator-jest

Add jest support to any projects
JavaScript
19
star
13

file-utils

Grunt.file utility fork to add some goodness
JavaScript
16
star
14

inquirer-npm-name

Helper function using inquirer to validate a value provided in a prompt does not exist as an npm package.
JavaScript
13
star
15

detect-conflict

Small utility library that check if a new file content can be merged safely in the on-disk existing file.
JavaScript
11
star
16

gulp-validate-jsdoc

Ensure your JsDoc covers every functions parameters.
JavaScript
7
star
17

dotfiles

My OS X dotfiles (based on necolas/dotfiles)
Shell
7
star
18

instagram-feed-slideshow

Fetch an instagram hash tag feed and displays it in a slideshow
JavaScript
4
star
19

frontend-windows-installer

Installer for most common Frontend/JavaScript work/build tools
3
star
20

Detect-Mobile-Device

PHP based mobile redirection code
2
star
21

flight-filedrop

File dropzone component (FileReader API)
JavaScript
2
star
22

bug-next-head

Demo project of a next.js bug with the Head component
JavaScript
1
star
23

generator-py-microlib

Generate python micro library boilerplate
JavaScript
1
star
24

jquery.3dish-slider

3D "ish" slider plugin for jQuery - Work in progress
JavaScript
1
star