current position:Home>Quick report ~ node JS 18 coming! Let's see what's new

Quick report ~ node JS 18 coming! Let's see what's new

2022-04-29 20:27:31Time time

Preface

Once a year again Node.js It's time for the community to release a new version ,Node.js v18 stay 4 month 19 No. was quietly released !Node.js v18 Will be in 2020 year 10 Month be LTS edition ( Leave to v16 There's not much time , cry /(ㄒoㄒ)/~~, Now it's still 14 Version of youmuyou ····), Yes v18 LTS Your support will continue until 2025 year 4 month . But in the official release LTS Before the release , There are still some ecological environments that are not covered by , Officials will continue to test and feedback , Therefore, at this stage, it is still necessary to eat carefully , Let's see what new tricks this new version brings ! image.pngNode.js.jpg

Node.js18 New characteristics

experimental Fetch

The good news ! The good news !!Node.js At last fetch Request function !

Fetch API Provides a simple 、 reasonable JavaScript Handle HTTP How to request , It has already become Web Standards for API. But for a long time ,Node I won't support it fetch request . If we want to send HTTP request , You have to use third-party plug-ins ( Such as node-fetch) Write or request from scratch . But now it's affected by undici Inspired by the (node-fetch Plugins are also based on undici-fetch),Node Also achieved as close as possible Web The standard Fetch standard , However, some features that need to be supported by the browser environment are ignored .

however Node Medium Fetch API It is also experimental , Further tests are needed to follow up .

image.png

Undici library

It's mentioned above that Node Fetch The implementation is based on undici, therefore Node Add a undici Is the library all right ??(doge) image.png So what exactly is this library ? In fact, that is Node.js Provided by the team , One use Nodejs Compiling 、 complete 、 ripe HTTP1.1 client .

Experimental test modular

node:test Modules can be created JavaScript test , Provides a quick 、 direct , There is no need to install other dependencies (Jset or Mocha) Can meet our simple testing needs , It uses TAP  Output the test results according to the specifications , This is also widely used by many testing tools , Easier to understand and accept . But it is still in the development stage , It can't completely replace mature Jset or Mocha.

import test from 'node:test'; //  Must be node: As a prefix , Indicates that... Is loaded node  Core module , Otherwise, the third-party module may be loaded 
 Copy code 

image.png

Platform support

  • Linux: As long as it's based on glibc 2.28 Or a higher version , Such as Debian 10、 RHEL 8 and Ubuntu 20.04
  • MacOS need 10.15 Or higher
  • Because in Node.js Created in v8 There are problems with dependencies ,win 32 The system will not be able to get updates at the first time Node.js v18 edition

For more support details, please stamp here

V8 The new version

Node Introduced V8 The engine has been updated to 10.1 Version of the , Improved and added some new features :

  • stay Node.js v17.9.0 It already has , for example findLast()findLastIndex(), This is in Web The end is still in the proposal stage , At present, we still need to pass lodash Use it

findlast.jpg

  • Improves the performance of classes and private methods on classes ( Their initialization speed is now as fast as normal attribute storage ).
  • Added Intl.supportedValuesOf(param) Method , The supported parameters are calendarcollationcurrency,numberingSystemtimeZone, and unit.
Intl.supportedValuesOf('calendar')
// ['buddhist', 'chinese', 'coptic', 'dangi', ...]

Intl.supportedValuesOf('collation')
// ['big5han', 'compat', 'dict', 'emoji', ...]

Intl.supportedValuesOf('currency')
// ['ADP', 'AED', 'AFA', 'AFN', 'ALK', 'ALL', 'AMD', ...]

Intl.supportedValuesOf('numberingSystem')
// ['adlm', 'ahom', 'arab', 'arabext', 'bali', ...]

Intl.supportedValuesOf('timeZone')
// ['Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_Ababa', 'Africa/Algiers', ...]

Intl.supportedValuesOf('unit')
// ['acre', 'bit', 'byte', 'celsius', 'centimeter', ...]
 Copy code 
  • More about V8 Engine V9.9 For version details, please refer to here

Abandoned or removed API

fs : runtime deprecate string coercion in fs.write, fs.writeFileSync (Livia Medeiros) #42607  
dns : remove dns.lookup and dnsPromises.lookup options type coercion (Antoine du Hamel) #41431  
process : runtime deprecate multipleResolves (Benjamin Gruenbaum) #41896
stream : remove thenable support (Robert Nagy) #40773  
tls : move tls.parseCertString to end-of-life (Tobias Nießen) #41479
 Copy code 

Thank you for reading ~ That's about Node.js v18 The whole content of , If you have any ideas, come and discuss them together

Reference resources :

Node.js 18 is now available! | Node.js (nodejs.org)

Node.JS 18 Released. All you need to know about Nodejs 18 | by Muhammad Arshad | BITLogix | Apr, 2022 | Medium

copyright notice
author[Time time],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/04/202204292027263816.html

Random recommended