Answer the question
In order to leave comments, you need to log in
How to make your fs wrapper?
Hello.
I have a wrapper around some fs functions, but I need to make an exact copy for fs.readdir and fs.createWriteStream.
Current code:
const fs = require('fs');
exports.mkdir = async function(dirArr) {
for(dir of dirArr) await fs.mkdir(dir, (e) => {err(e)});
}
exports.unlink = async function(linkArr) {
for(link of linkArr) await fs.unlink(link, (e) => {err(e)});
}
exports.rmdir = async function(dirArr) {
for(dir of dirArr) await fs.rmdir(dir, (e) => {err(e)});
}
exports.readFile = function(file, encoding = 'utf8') {
try {
return fs.readFileSync(file, encoding);
} catch(e) {
err(e);
}
}
function err(e) {
if(e) echo(` [E] ${e}`);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question