Skip to content

使用node v10+可以用原生的require('fs').promises中提供的API

Notifications You must be signed in to change notification settings

hbshun/fs-async-await

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fs-async-await

node >= 7.6.0

File System 中异步API 支持 async/await。

每个异步方法,加上后缀Async变成新的方法。

access -> accessAsync
...

使用:

const fs = require('./fs-async-await')

let readFile = async (filename) => {
  return await fs.readFileAsync(filename);
}
(async () => {
  let content = await readFile(__filename);
  console.log(content.toString());
})();

About

使用node v10+可以用原生的require('fs').promises中提供的API

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published