vifi

Virtual File System

Usage no npm install needed!

<script type="module">
  import vifi from 'https://cdn.skypack.dev/vifi';
</script>

README

Vifi - virtual file system library

examples:


// we're importing vifi libary
const vifi = require('vifi/2');

// we create virtual file system (and we inject fs module)
const vfs = vifi(require('fs'));

// then we open file:
const file = vfs.open('some-file.txt');

then if you want to use promises you write this way:

file.read().then(contents => {
    // notice - this is early version,
    // so now write only can replace content of file
    // appending is not implemented yet
    file.write(contents + '\n' + new Date)
});

or using async/await (Node 7+):

async function someFunction() {
    const contents = await file.read();
    file.write(contents + '\n' + new Date)
}

someFunction();