This series of blog posts was inspired by a thread which I posted on Twitter.
🔤 Generate v4 UUIDs without needing the uuid library
If you want to generate v4 UUIDs in Node.js e.g.
d2c14405-a3dd-4fcc-b13b-bc649fe1a0bf, you no longer need to add the
uuid library as a dependency. You can use
🛑 Cancel async operations with AbortController
If you want to cancel an async operation in Node.js, such as an HTTP request, you can now use the built in
AbortSignal classes. They were originally introduced in the Web Platform APIs, which are implemented by web browsers.
📦 Make your imports clearer with the node: protocol
You can use the
node: protocol to make it clear in your code when you’re importing built in Node.js modules. It makes it much easier to tell which modules are third-party dependencies.
🌟 Take advantage of promise-based APIs in Node.js
You can use
util.promisify() to wrap callback-based APIs in Node.js core. But did you know that Node.js provides several promise-based APIs too? You can use them with
await, no wrapping needed! There are two new promise-based APIs in Node.js core: