Creating a Node.js Library that Supports Both Promises and Error-First Callbacks

suggest change

Introduction

Many people prefer promises or async/await, but a module can still support error-first callbacks. Rather than publishing two modules, or making every caller promisify the API, return a promise and also accept an optional node-style callback. Bluebird's asCallback() and Q's nodeify() both do that. Node.js callbacks are error-first: the first argument is an error or null.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents