refactor: new direction

This commit is contained in:
rkiel
2019-07-20 09:21:10 -04:00
parent 438416bd41
commit 5b9d2b0711
3 changed files with 105 additions and 12 deletions

17
js/file.js Normal file
View File

@@ -0,0 +1,17 @@
const fs = require("fs");
const util = require("util");
let lib;
function exists(path) {
const stat = util.promisify(fs.stat);
return stat(path);
}
function read(path) {
const readFile = util.promisify(fs.readFile);
return readFile(path).then(buffer => buffer.toString("utf-8"));
}
lib = { exists, read };
module.exports = lib;