Book Image

Mastering JavaScript Promises

Book Image

Mastering JavaScript Promises

Overview of this book

Table of Contents (16 chapters)
Mastering JavaScript Promises
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Q utilities for Node.js


In this chapter, we came to know that promises are getting more easy to use within Node.js. The following is the set of all major utilities offered by Q for using Node.js:

  • Q.nfapply(fs.readFile, [filename, encoding]).then(console.log);

  • Q.nfcall(fs.readFile, filename, encoding).then(console.log);

  • Q.nfbind(fs.readFile)(filename, encoding).then(console.log);

  • Q.npost(fs, "readFile", [filename, encoding]).then(console.log);

  • Q.nsend(fs, "readFile", filename, encoding).then(console.log);

Q has more to offer, but the preceding ones are the best and most used and sensible use of these can help us write a more manageable, cleaner, and dynamically controlled mechanism.