Last active
August 2, 2019 08:04
-
-
Save popovkos/399a47b137ee0b99808ad4cc35a47da7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs=require('fs'); | |
const ab=['access','rename','ftruncate','chown','lchown','cmod','fchmod','stat','lstat','fstat','link','symlink', | |
'readlink','realpath','unlink','rmdir','readdir','close','open','utimes', | |
'futimes','fsync','write','read','readFile','writeFile','appendFile','mkdir','mkdtemp'] | |
// fchown fdatasync mkdtemp rename truncate | |
ab.forEach(name=>{ | |
if(!fs[name])return; | |
exports[name]=(...n)=>{ | |
return new Promise((res,rej)=>{ | |
fs[name](...n,(er,d)=>{ | |
if(er)rej(er) | |
if(d)res(d) | |
}) | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment