creates an object / string representation of a file system
npm install serialfscreates an object / string representation of files and folders
``javascript
const serialfs = require('serialfs');
// callback style
serialfs.obj('subfolder', (err, res) => {
console.log(res);}); // {"file1": "contents", "file2": "contents"}
serialfs.obj('subfolder', {should_read_file_contents: false}, (err, res) => {
console.log(res);}); // {"file1": "", "file2":""}
serialfs.yaml('subfolder', (err, res) => {
console.log(res);}); // "file1: '' \nfile2: ''"
// promise style
serialfs.obj('subfolder').then((res) => {
console.log(res);}).catch((err) => true);
`
the second parameter is the options object. specify behvior with the following:
if this is true, will recurse into all subfolders\
if this is false, will not recurse into any subfolders\
if this is an object, will look for the current folder's name
- if found, will recurse into the folder in the object and the file system and repeat
- if not found, will recurse into the folder
if this is true, will read the contents of the files\
if this is false, will not read the contents of the files\
if this is an object, will look for the current folder's name
- if found, will recurse into the folder in the object and the file system and repeat
- if not found, will recurse into the folder
javascript
{a: {b: 'text1', c: 'text2'}, d: {e: 'text3:, f: 'text4'}}
`the recurse object is:
`javascript
{a: {b: true}}
`and the read file object is:
`javascript
{a: {d: false}}
`the result would be:
`javascript
{a: {b: 'text1', c: ''}, d: null}
`$3
will send extra information to standard out, to help understand what's happening
installation
`shell
npm install --save serialfs
``