---
title: "What's New in Node v10?"
description: "Key features in Node.js v10 including fs/promises, console.table, top-level await, and more. Practical notes and code in JS."
url: "https://h3manth.com/scribe/whats-new-in-node-v10/"
canonical_url: "https://h3manth.com/scribe/whats-new-in-node-v10/"
markdown_url: "https://h3manth.com/scribe/blog/whats-new-in-node-v10.md"
publishDate: "2018-04-25T00:00:00.000Z"
author: "Hemanth HM"
category: "node"
tags: ["node","javascript"]
word_count: 212
reading_time_minutes: 2
x_markdown_tokens: 504
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# What's New in Node v10?

> Key features in Node.js v10 including fs/promises, console.table, top-level await, and more. Practical notes and code in JS.

Node v10 has a good set of new [features](https://nodejs.org/en/blog/release/v10.0.0/), here are few that I liked.

## FS Promisified

`fs/promises` API is an experimental promisified version of the fs functions.

```javascript
const fsp = require('fs/promises');

const stat = async (dir) => fsp.stat(dir);

stat(".")
  .then(console.log, console.error)
  .catch(console.error);

## console.table
javascript
console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);
// ┌─────────┬─────┬─────┐
// │ (index) │  a  │  b  │
// ├─────────┼─────┼─────┤
// │    0    │  1  │ 'Y' │
// │    1    │ 'Z' │  2  │
// └─────────┴─────┴─────┘
```

## Top Level Await in REPL

Starting the REPL with `--experimental-repl-await` flag enables top level await:

```bash
$ node --experimental-repl-await
> const fsp = require('fs/promises');
> await fsp.stat(".");

## Pipeline for Streams
javascript
const fs = require('fs');
const zlib = require('zlib');
const pipeline = util.promisify(stream.pipeline);

async function run() {
  await pipeline(
    fs.createReadStream('archive.tar'),
    zlib.createGzip(),
    fs.createWriteStream('archive.tar.gz')
  );
  console.log('Pipeline succeeded');
}

run().catch(console.error);

## for-await-of Loops
javascript
async function foo() {
  const Iters = [
    Promise.resolve('foo'),
    Promise.resolve('bar'),
  ];
  
  for await (const it of Iters) {
    console.log(it);
  }
}

foo();

## Optional Catch Binding
javascript
function meow() {
  try {
    throw new Error();
  } catch { // no binding needed!
    return true;
  }
  return false;
}

## RegExp Unicode Property Escapes
javascript
(/\p{Script=Greek}/u).test('π'); // true
```
