Since Node v11.0.0 fs promises are available natively without promisify
:
const fs = require('fs').promises;
async function loadMonoCounter() {
const data = await fs.readFile("monolitic.txt", "binary");
return Buffer.from(data);
}
More Related Contents:
- Asynchronous nodejs module exports
- How does Asynchronous programming work in a single threaded programming model?
- Using Promises with fs.readFile in a loop
- fs.writeFile in a promise, asynchronous-synchronous stuff
- What is non-blocking or asynchronous I/O in Node.js?
- Why await is not working for node request module?
- How to wait for a stream to finish piping? (Nodejs)
- Node.js – Using the async lib – async.foreach with object
- Proper request with async/await in Node.JS
- Mongoose complex (async) virtuals
- How would I create a for-loop in Node.js
- What is the –save option for npm install?
- How to avoid long nesting of asynchronous functions in Node.js
- Cannot overwrite model once compiled Mongoose
- Understanding Asynchronous Code in Layman’s terms
- ECONNREFUSED for Postgres on nodeJS with dockers
- How do I shutdown a Node.js http(s) server immediately?
- Mongoose Schema hasn’t been registered for model
- How to fetch/scan all items from `AWS dynamodb` using node.js
- Cannot POST / error using express
- req.locals vs. res.locals vs. res.data vs. req.data vs. app.locals in Express middleware
- Node.js – Find home directory in platform agnostic way
- Restart node upon changing a file
- Deploy Nodejs on Heroku fails serving static files located in subfolders
- convert streamed buffers to utf8-string
- How can I save multiple documents concurrently in Mongoose/Node.js?
- Passing arguments to require (when loading module)
- Node.js – logging / Use morgan and winston
- npm ERR! git dep preparation failed when trying to install package.json
- Webpack how to build production code and how to use it