mem-fs
Simple in-memory vinyl file store
Last updated 2 years ago by sboudrias .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install mem-fs 
SYNC missed versions from official npm registry.

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.

Pass stored files through a pipeline

store#pipeline() generates a new map with yielded files in transforms. If no transform is passed, files references are updated.

Current Tags

  • 4.1.0                                ...           latest (10 months ago)
  • 4.0.0-beta.1                                ...           next (a year ago)

16 Versions

  • 4.1.0                                ...           10 months ago
  • 4.0.0                                ...           a year ago
  • 4.0.0-beta.1                                ...           a year ago
  • 3.0.0                                ...           2 years ago
  • 2.3.0                                ...           2 years ago
  • 2.2.1                                ...           4 years ago
  • 2.2.0                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.3                                ...           9 years ago
  • 1.1.2                                ...           9 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (2)
Downloads
Total 2
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (9)

© 2010 - cnpmjs.org x YWFE | Home | YWFE