...

/

Exercise: A Virtual Filesystem

Exercise: A Virtual Filesystem

Practice how to write the file data in memory.

Problem statement

Modify our LevelDB filesystem adapter example to write the file data in memory rather than in LevelDB. You can use an object or a Map instance to store the key-value pairs of filenames and the associated data.

Coding challenge

Write your solution code in the following code widget. We’ve already added the package.json file for your ease.

Press + to interact
index.js
package.json
fs-adapter.js
{
"name": "Chapter-08",
"version": "1.0.0",
"description": "This examples shows how to use the adapter pattern to build an FS-like interface that writes to level db instead",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"level": "^6.0.0"
},
"engines": {
"node": ">=14"
},
"engineStrict": true
}

Solution

...