In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "what are the new features of Node.js 8.5", friends who are interested may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the new features of Node.js 8.5"?
What's New in Node.js 8.5
Recently, Node.js released version 8.5, in which Node added three exciting new features.
Support for ES Module
During this iteration of the version, Node finally supported the ES module proposal of the developer's voice. This means that you can directly use the import keyword to introduce the required modules. Node 8.5 can run the following code:
`import fs from 'fs' `
Using the es module, you need to note that the extension of the incoming file should be mjs and use the-experimental-modules logo.
Restrictions on using the ES module in Node.js:
Import (), the V8 engine will be supported in the next release
Import.meta, V8 engine does not support it.
Require ('. / foo.mjs') is not supported
Performance monitoring
In Node.js version 8.5, performance is monitored by API.
In Node.js 8.5, you can call mark () and measure () API to monitor the execution time of Node.js events.
In Node.js 8.5, you can use:
Const {performance} = require ('perf_hooks') performance.mark (' A') setTimeout () = > {performance.mark ('B') performance.measure ('A to B', 'Aids,' B') const entry = performance.getEntriesByName ('A to B', 'measure') console.log (entry.duration)}, 10000)
Official document: https://nodejs.org/api/perf_hooks.html
Fs module adds file copy function
Node.js 8.5 introduces a more advanced file system, in which you can copy the code of a file directly through the fs module:
Const fs = require ('fs') fs.copyFile (' source.txt', 'destination.txt', (err) = > {if (err) {/ / handle error properly, not just console.log return console.error (err)} console.log (' source.txt was copied to destination.txt')}) so far, I believe you have a deeper understanding of "what are the new features of Node.js 8.5", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.