@jsonjoy.com/fs-node
In-memory filesystem with Node.js fs-compatible API
Last updated 21 days ago by GitHub Actions .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @jsonjoy.com/fs-node 
SYNC missed versions from official npm registry.

@jsonjoy.com/fs-node

In-memory filesystem with Node.js fs-compatible API.

Installation

npm install @jsonjoy.com/fs-node

Usage

import { Volume } from '@jsonjoy.com/fs-node';

const vol = new Volume();
vol.writeFileSync('/hello.txt', 'Hello, World!');
console.log(vol.readFileSync('/hello.txt', 'utf8')); // Hello, World!

Create filesystem from JSON

import { Volume } from '@jsonjoy.com/fs-node';

const vol = Volume.fromJSON({
  '/app/index.js': 'console.log("Hello");',
  '/app/package.json': '{"name": "app"}',
});

console.log(vol.readdirSync('/app')); // ['index.js', 'package.json']

API

The Volume class implements Node.js fs module's synchronous and callback APIs:

  • readFile, readFileSync
  • writeFile, writeFileSync
  • mkdir, mkdirSync
  • readdir, readdirSync
  • stat, statSync
  • unlink, unlinkSync
  • ... and many more

It also exposes a promises property for the Promise-based API:

const data = await vol.promises.readFile('/hello.txt', 'utf8');

License

Apache-2.0

Current Tags

  • 4.57.1                                ...           latest (20 days ago)

11 Versions

  • 4.57.1                                ...           20 days ago
  • 4.57.0                                ...           21 days ago
  • 4.56.11                                ...           a month ago
  • 4.56.10                                ...           3 months ago
  • 4.56.9                                ...           3 months ago
  • 4.56.8                                ...           3 months ago
  • 4.56.7                                ...           3 months ago
  • 4.56.4                                ...           3 months ago
  • 4.56.2                                ...           3 months ago
  • 4.56.1                                ...           3 months ago
  • 4.56.0                                ...           3 months ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (7)
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |