simple-virtual-fs
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

simple-virtual-fs

A file system type interface for dealing with nested values by path

npm i simple-virtual-fs

Example:

import { VirtualFs } from 'simple-virtual-fs';

const fs = new VirtualFs<number>()
  .add('/foo/first', 1)
  .add('/foo/second', 2)
  .add('/foo/third', 3)
  .add('/bar/fourth', 4)
  .map(item => item * 2 : 0);

const res = fs.getChildren('/foo'); // ['/foo/first', '/foo/second', '/foo/third']

res.forEach(path => {
  console.log(fs.read(path)) //  2 -> 4 -> 6
});

Observe Changes.

import { VirtualFs } from 'virtual-fs';

const fs = new VirtualFs<number>();

fs.observe.subscribe((fs: FakeFs<number>) => {
  // returns initial instance and then triggers when anything the instance updates
});

fs.add('/foo/first', 1)
  .add('/foo/second', 2)
  .add('/foo/third', 3)
  .add('/bar/fourth', 4);

Readme

Keywords

none

Package Sidebar

Install

npm i simple-virtual-fs

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

10.4 kB

Total Files

9

Last publish

Collaborators

  • deebloo