Friday, June 12, 2020

Amazing Features Of Node.js 14



In 2019, Node.js turned 10 years old and its downloads are continuously growing 40% year over year. Recently, Node.js joined the OpenJS Foundation which ensures to improve project health, sustainability, and also a collaboration with the JavaScript community to a great extent. Every year the Node.js community has gained momentum and this will surely continue in 2020 too. The new version Node.js 14 was launched on April 21, 2020. This new version comes with some features and improvements that encourage developers to incorporate the capacity of data storing through online request and in-built diagnostic reporting.  Let see some highlights of Node.js 14-

Node.js 14-

The 14.x release comes with experimental Async Local storage API  to efficiently manage context across Asynchronous Calls over multiple releases. It also includes a new compiler, platform minimums, and an experimental Web Assembly System Interface.

Features Of Node.js 14-

1. V8 upgraded to V8 8.1-

The new version of V8 JavaScript engine come with execution changes and improvements just as keeping Node.js up with the continuous improvements in the language and runtime. 

2. Streams-

This version includes many changes marked as SemVer major in the Node.js Streams implementation. These are the changes to improve consistency across the Streams APIs to remove ambiguity and streamline behaviors across the various parts of Node.js core. 

3. Node.js Can Import WebAssembly Modules-

With ES module support comes the ability to import WebAssembly modules. It is a portable compiled binary format that can be parsed faster than JavaScript and executed at native speed. WebAssembly modules can be created using a language like  C/C++, Go, C#, Java, Python, Elixir, Rust and so on.

To allow the module support, you should pass a command line flag when  executing a Node.js application. For eg., 

node --experimental-wasm-modules index.js

Consider, you have an image processing library implemented as a WebAssembly module.

The syntax for using this Wasm module is-

import * as imageUtils from "./imageUtils.wasm";
import * as fs from "fs";
( async () => {
   const image = await fs.promises.readFile( "./image.png" );
   const updatedImage = await imageUtils.rotate90degrees( image );
} )();

You can also import WebAssembly module using the new dynamic import() statement in Node.js.

"use strict";
const fs = require("fs");
( async () => {
   const imageUtils = await import( "./imageUtils.wasm" );
   const image = await fs.promises.readFile( "./image.png" );
   const updatedImage = await imageUtils.rotate90degrees( image );
} )();

4. WebAssembly System Interface (WASI)-

Just like JavaScript, WebAssembly is designed to prevent access to any underlying operating system, sometimes called “sandboxed”. 

However, there are times when a WebAssembly module in your control in Node.js may profit by having the option to make system-level calls. And here comes the new WebAssembly System Interface (WASI).  It is designed to be a standard interface for making calls to the system such as host applications, native operating systems, and so on. Initial WASI support was now committed to the Node.js project. WASI is an amazing feature that we can see in 2020.

5. Diagnostic Reports Launch In 2020-










No comments:

Post a Comment