Skip to content

Tests new features added since es6 up to es10 using node >= v12 such as async import, private class properties, new operators, async generators, for-wait-of loop......

Notifications You must be signed in to change notification settings

AndrewJHart/es10-features-in-node-13

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Playing with ES9+ features in node v13.5.0

Before explaining what features we are attempting to experiment with, there are a few notable modifications to the node application that are required to run it.

This is a simple plain node application with two subtle but notable additions.

  1. I am using the --experimental-modules flag when running the project so i can use standard export and export default for exporting from a module. Allows us to use import <file> from "<path>" syntax with js modules.
  2. I've modified package.json to include the line "type": "module"

These modifications allow us to use the newer import/export syntax. Also be aware that using import for local modules in this context requires the file extension like so:

// notice the .js at the end of the import statement of this local
// module. Dependencies installed via npm do not require the .js
import CoffeeMachine from "./utils/private-class-members.js";

What new features are attempting to use?

  • Asynchronously import another module that returns a promise
  • Using # for private props within classes
  • Uses Promise.allSettled([...promises]) instead of all()
  • Uses Promise.any([...promises]) instead of race()
  • Use nullish coalescence operator
  • Use the Elvis operator

Setting up the project

Clone the project & then cd into the directory

$ git clone [email protected]:AndrewJHart/es10-features-in-node-13.git
$ cd es10-features-in-node-13

This project only has one dependency, node-fetch so install it

npm install

note: make sure you are using at least node version 12.13.0.

running the project

To run the project is simple. To obviate having to run the script with the --experimental-modules flag every time, i've added a script in package.json that uses the experimental flags.

just execute this in the project directory:

$ npm run start

That's all folks. I'll be adding new things later when i have time just to test them.

Andrew Hart

About

Tests new features added since es6 up to es10 using node >= v12 such as async import, private class properties, new operators, async generators, for-wait-of loop......

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published