Skip to content

Instantly share code, notes, and snippets.

@azole
Created December 29, 2021 08:58
Show Gist options
  • Save azole/e3b7ab75e64a952ae01cb300db32e06a to your computer and use it in GitHub Desktop.
Save azole/e3b7ab75e64a952ae01cb300db32e06a to your computer and use it in GitHub Desktop.
const fs = require('fs');
const writeFile = async (data, fileName) => {
// 你要寫的部分
return new Promise((resolve, reject) => {
fs.writeFile(fileName, data, (err) => {
if (err) {
reject(err);
}
resolve();
});
});
};
(async () => {
await writeFile('ABC', 'test.txt');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment