gmnon.cn-疯狂蹂躏欧美一区二区精品,欧美精品久久久久a,高清在线视频日韩欧美,日韩免费av一区二区

站長資訊網
最全最豐富的資訊網站

Node.js 19正式發布,聊聊它的 6 大特性!

Node 19已正式發布,下面本篇文章就來帶大家詳解了解一下Node.js 19的 6 大特性,希望對大家有所幫助!

Node.js 19正式發布,聊聊它的 6 大特性!

node.js極速入門課程:進入學習

通譯自:6 Major Features of Node.js 19. Details of Node.js 19 new features… | by Jennifer Fu | Oct, 2022 | Better Programming


Node.js 14 將在 2023 年 4 月結束更新維護,Node.js 16 (LTS) 預計將在 2023 年 9 月結束更新維護。

而Node 19 在 2022-10-18 發布。【相關教程推薦:nodejs視頻教程】

我們知道 Node.js 版本分兩種:LTS 和 Current

Node.js 19正式發布,聊聊它的 6 大特性!

其中,Current 版本通常每 6 個月發布一次。

每年 4 月份發布新的偶數版本;

每年 10 月份發布新的奇數版本;

在剛過去的 10 月,發布的 V19.0.1 成為最新的 “Current” 嘗鮮版,它一共帶來 6 大特性。

1. HTTP(S)/1.1 KeepAlive 默認為 true

Node.js v19 設置 keepAlive 默認值為 true,這意味著所有出站的 HTTP(s) 連接都將使用 HTTP 1.1 keepAlive,默認時間為 5S;

代碼測試:

const http = require('node:http'); console.log(http.globalAgent); const https = require('node:https'); console.log(https.globalAgent);
登錄后復制

我們可以對比看看 v16 和 v19 的 node server Agent 配置差異:

  • V16

% nvm use 16 Now using node v16.0.0 (npm v7.10.0) % node server Agent {   _events: [Object: null prototype] {     free: [Function (anonymous)],     newListener: [Function: maybeEnableKeylog]   },   _eventsCount: 2,   _maxListeners: undefined,   defaultPort: 80,   protocol: 'http:',   options: [Object: null prototype] { path: null },   requests: [Object: null prototype] {},   sockets: [Object: null prototype] {},   freeSockets: [Object: null prototype] {},   keepAliveMsecs: 1000,   keepAlive : false,   maxSockets: Infinity,   maxFreeSockets: 256,   scheduling: 'lifo',   maxTotalSockets: Infinity,   totalSocketCount: 0,   [Symbol(kCapture)]: false } Agent {   _events: [Object: null prototype] {     free: [Function (anonymous)],     newListener: [Function: maybeEnableKeylog]   },   _eventsCount: 2,   _maxListeners: undefined,   defaultPort: 443,   protocol: 'https:',   options: [Object: null prototype] { path: null },   requests: [Object: null prototype] {},   sockets: [Object: null prototype] {},   freeSockets: [Object: null prototype] {},   keepAliveMsecs: 1000,   keepAlive: false,   maxSockets: Infinity,   maxFreeSockets: 256,   scheduling: 'lifo',   maxTotalSockets: Infinity,   totalSocketCount: 0,   maxCachedSessions: 100,   _sessionCache: { map: {}, list: [] },   [Symbol(kCapture)]: false }
登錄后復制

第 18、40 行,keepAlive 默認設置為 false;

  • V19

% nvm use 19 Now using node v19.0.0 (npm v8.19.2) % node server Agent {   _events: [Object: null prototype] {     free: [Function (anonymous)],     newListener: [Function: maybeEnableKeylog]   },   _eventsCount: 2,   _maxListeners: undefined,   defaultPort: 80,   protocol: 'http:',   options: [Object: null prototype] {     keepAlive: true,     scheduling: 'lifo',     timeout: 5000,     noDelay: true,     path: null   },   requests: [Object: null prototype] {},   sockets: [Object: null prototype] {},   freeSockets: [Object: null prototype] {},   keepAliveMsecs: 1000,   keepAlive: true,   maxSockets: Infinity,   maxFreeSockets: 256,   scheduling: 'lifo',   maxTotalSockets: Infinity,   totalSocketCount: 0,   [Symbol(kCapture)]: false } Agent {   _events: [Object: null prototype] {     free: [Function (anonymous)],     newListener: [Function: maybeEnableKeylog]   },   _eventsCount: 2,   _maxListeners: undefined,   defaultPort: 443,   protocol: 'https:',   options: [Object: null prototype] {     keepAlive: true,     scheduling: 'lifo',     timeout: 5000,     noDelay: true,     path: null   },   requests: [Object: null prototype] {},   sockets: [Object: null prototype] {},   freeSockets: [Object: null prototype] {},   keepAliveMsecs: 1000,   keepAlive: true,   maxSockets: Infinity,   maxFreeSockets: 256,   scheduling: 'lifo',   maxTotalSockets: Infinity,   totalSocketCount: 0,   maxCachedSessions: 100,   _sessionCache: { map: {}, list: [] },   [Symbol(kCapture)]: false }
登錄后復制

第 14、16、42、44 行設置 keepAlive 默認值及時間;

啟用 keepAlive 能使連接重用,提高網絡的吞吐量。

另外,服務器將在調用 close() 自動斷開空閑的客戶端,內部依靠 http(s).Server.close API 實現;

這些修改,進一步優化了體驗和性能。

2. 穩定的 WebCrypto API

WebCrypto API 是一個使用密碼學構建的系統接口,在 node.js v19 趨于穩定(除 Ed25519、Ed448、X25519、X448 外)。

我們可以通過調用 globalThis.cryptorequire('node:crypto').webcrypto 來訪問,下面以 subtle 加密函數為例;

const { subtle } = globalThis.crypto;  (async function() {    const key = await subtle.generateKey({     name: 'HMAC',     hash: 'SHA-256',     length: 256   }, true, ['sign', 'verify']);    console.log('key =', key);    const enc = new TextEncoder();   const message = enc.encode('I love cupcakes');    console.log('message =', message);    const digest = await subtle.sign({     name: 'HMAC'   }, key, message);    console.log('digest =', digest);  })();
登錄后復制

首先生成 HMAC 密鑰,生成的密鑰可同時用于驗證消息數據完整性和真實性;

然后,對字符串 I love cupcakes 加密;

最后創建 消息摘要,它是一種加密散列函數;

在控制臺顯示:key 、message 、digest 信息

% node server key = CryptoKey {   type: 'secret',   extractable: true,   algorithm: { name: 'HMAC', length: 256, hash: [Object] },   usages: [ 'sign', 'verify' ] } message = Uint8Array(15) [   73, 32, 108, 111, 118,  101, 32,  99, 117, 112,   99, 97, 107, 101, 115] digest = ArrayBuffer {   [Uint8Contents]: <30 01 7a 5c d9 e2 82 55 6b 55 90 4f 1d de 36 d7 89 dd fb fb 1a 9e a0 cc 5d d8 49 13 38 2f d1 bc>,   byteLength: 32 }
登錄后復制

3. 自定義 ESM resolution 調整

Node.js 已經刪除 --experimental-specifier-resolution ,其功能現在可以通過自定義加載器實現。

可以在這個庫中測試:nodejs/loaders-test: Examples demonstrating the Node.js ECMAScript Modules Loaders API

git clone https://github.com/nodejs/loaders-test.git  % cd loaders-test/commonjs-extension-resolution-loader  % yarn install
登錄后復制

比如 loaders-test/commonjs-extension-resolution-loader/test/basic-fixtures/index.js 文件:

import { version } from 'process';  import { valueInFile } from './file'; import { valueInFolderIndex } from './folder';  console.log(valueInFile); console.log(valueInFolderIndex);
登錄后復制

./file 如果沒有自定義加載器,不會去查找文件的擴展名,比如 ./file.js./file.mjs

設置自定義加載器后,則可解決上述問題:

import { isBuiltin } from 'node:module'; import { dirname } from 'node:path'; import { cwd } from 'node:process'; import { fileURLToPath, pathToFileURL } from 'node:url'; import { promisify } from 'node:util';  import resolveCallback from 'resolve/async.js';  const resolveAsync = promisify(resolveCallback);  const baseURL = pathToFileURL(cwd() + '/').href;   export async function resolve(specifier, context, next) {   const { parentURL = baseURL } = context;    if (isBuiltin(specifier)) {     return next(specifier, context);   }    // `resolveAsync` works with paths, not URLs   if (specifier.startsWith('file://')) {     specifier = fileURLToPath(specifier);   }   const parentPath = fileURLToPath(parentURL);    let url;   try {     const resolution = await resolveAsync(specifier, {       basedir: dirname(parentPath),       // For whatever reason, --experimental-specifier-resolution=node doesn't search for .mjs extensions       // but it does search for index.mjs files within directories       extensions: ['.js', '.json', '.node', '.mjs'],     });     url = pathToFileURL(resolution).href;   } catch (error) {     if (error.code === 'MODULE_NOT_FOUND') {       // Match Node's error code       error.code = 'ERR_MODULE_NOT_FOUND';     }     throw error;   }    return next(url, context); }
登錄后復制

測試命令:

% node --loader=./loader.js test/basic-fixtures/index   (node:56149) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time (Use `node --trace-warnings ...` to show where the warning was created) hello from file.js
登錄后復制

將不會再報錯,正常運行。

4. 移除對 DTrace/SystemTap/ETW 支持

在 Node.js v19中,移除了對 DTrace/SystemTap/ETW 的支持,主要是因為資源的優先級問題。

數據表明很少人用到 DTrace、SystemTap 或 ETW,維護它們沒有多大的意義。

如果你想恢復使用,可提 issues => github.com/nodejs/node…

5. 升級 V8 引擎至 10.7

Node.js v19 將 V8 JavaScript 引擎更新至 V8 10.7,其中包含一個新函數 Intl.NumberFormat,用于格式化敏感數字。

Intl.NumberFormat(locales, options)
登錄后復制

對于不同的語言,傳入不同的 locales:

const number = 123456.789;  console.log(new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(number)); console.log(new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'JPY' }).format(number)); console.log(new Intl.NumberFormat('ar-SA', { style: 'currency', currency: 'EGP' }).format(number)); console.log(new Intl.NumberFormat('zh-CN', { style: 'currency', currency: 'CNY' }).format(number));
登錄后復制

6. 試驗 Node watch 模式

運行時增加了 node –watch 選項。

在 "watch" 模式下運行,當導入的文件被改變時,會重新啟動進程。

比如:

const express = require("express"); const path = require("path"); const app = express(); app.use(express.static(path.join(__dirname, "../build")));  app.listen(8080, () =>   console.log("Express server is running on localhost:8080") );
登錄后復制

% node --watch server (node:67643) ExperimentalWarning: Watch mode is an experimental feature. This feature could change at any time (Use `node --trace-warnings ...` to show where the warning was created) Express server is running on localhost:8080
登錄后復制


Node.js 14 將在 2023 年 4 月結束更新維護,Node.js 16 (LTS) 預計將在 2023 年 9 月結束更新維護。

建議大家開始計劃將版本按需升級到 Node.js 16(LTS)或 Node.js 18(LTS)。

贊(0)
分享到: 更多 (0)
?
網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號
gmnon.cn-疯狂蹂躏欧美一区二区精品,欧美精品久久久久a,高清在线视频日韩欧美,日韩免费av一区二区
亚洲精品在线网址| 人人干人人视频| 天天综合中文字幕| www激情五月| 亚洲在线观看网站| 97在线免费视频观看| 18视频在线观看娇喘| 青青青免费在线| 日韩久久一级片| 欧美中文字幕在线观看视频| 伊人再见免费在线观看高清版| 国产成人三级视频| 色噜噜狠狠一区二区| 欧美日韩午夜爽爽| 国产女同无遮挡互慰高潮91| 欧美日韩黄色一级片| 国产原创popny丨九色| 亚洲第一色av| 校园春色 亚洲色图| av无码久久久久久不卡网站| 无码少妇一区二区三区芒果| 国产91porn| 成 人 黄 色 小说网站 s色| 日日摸天天爽天天爽视频| 欧美视频免费播放| 日韩中文在线字幕| 黄色a级三级三级三级| jizz大全欧美jizzcom| 欧美黄色免费影院| 东京热加勒比无码少妇| 成人在线免费观看av| 中文字幕无码精品亚洲资源网久久| 天天干天天操天天玩| 日本韩国欧美在线观看| 欧美精品99久久| 女人被男人躁得好爽免费视频| 欧美 日韩 国产 在线观看| 国内自拍中文字幕| 日韩精品视频久久| 国产精品中文久久久久久| 男人靠女人免费视频网站| 激情文学亚洲色图| 成年人小视频网站| 久久久999视频| 99国产精品久久久久久| 欧美a v在线播放| 99精品一区二区三区的区别| 可以在线看的黄色网址| 国产一区二区三区小说| 成年人免费观看的视频| 中文av字幕在线观看| 国产精品沙发午睡系列| www.日本少妇| 男人添女荫道口图片| 超碰97免费观看| 国内av一区二区| 国产香蕉一区二区三区| 日本男女交配视频| 超级碰在线观看| av女优在线播放| 日韩精品视频一区二区在线观看| www污在线观看| 欧美牲交a欧美牲交aⅴ免费真 | 大陆极品少妇内射aaaaa| 日本一本中文字幕| 欧美丰满熟妇bbbbbb百度| 丰满少妇大力进入| 午夜免费福利在线| 色哺乳xxxxhd奶水米仓惠香| 97中文字幕在线| 在线免费观看视频黄| 亚洲高潮无码久久| 超碰在线97免费| 人体内射精一区二区三区| 久草福利视频在线| www.xxx麻豆| 波多野结衣网页| 午夜在线观看av| 精品少妇无遮挡毛片| 999一区二区三区| 日本特级黄色大片| 成熟老妇女视频| 免费午夜视频在线观看| 日本手机在线视频| 91精品国产毛片武则天| japanese在线视频| 亚洲综合伊人久久| 亚洲高清av一区二区三区| 日本一二区免费| 永久免费黄色片| 日韩成人手机在线| 国产a级片网站| 国产a视频免费观看| 91n.com在线观看| 亚洲一级片免费观看| 午夜影院免费观看视频| 蜜臀av.com| 日韩激情免费视频| av在线无限看| 国产日产欧美一区二区| 国产真人做爰毛片视频直播| 国产精品久久久久9999爆乳| 国产高清精品在线观看| 黄色一级大片在线观看| 色网站在线视频| 国产精品免费成人| 91嫩草国产丨精品入口麻豆| 精品99在线视频| 欧美成人手机在线视频| 欧美日韩精品在线一区二区| www.超碰97.com| 一区二区xxx| 国产91xxx| 亚洲不卡中文字幕无码| 91香蕉国产线在线观看| 一起操在线视频| 草草草在线视频| 欧美久久久久久久久久久久久| 在线观看中文av| www.色就是色.com| 色婷婷.com| 久久黄色片网站| 日韩av.com| 色婷婷一区二区三区在线观看| 亚洲精品中文字幕乱码无线| 在线免费黄色网| www.九色.com| www.com毛片| 日本免费色视频| 日韩中文字幕亚洲精品欧美| 久久综合九色综合88i| 日韩精品 欧美| 捷克做爰xxxⅹ性视频| 国产高清视频网站| 欧美少妇一级片| 久久人人爽人人爽人人av| 久久精品.com| 五月激情五月婷婷| 真实国产乱子伦对白视频| 日本a在线免费观看| 国产精彩免费视频| 91社在线播放| 女人扒开屁股爽桶30分钟| 久久午夜夜伦鲁鲁一区二区| 国产永久免费网站| 18禁免费观看网站| 熟女视频一区二区三区| 熟妇人妻va精品中文字幕| 日韩精品一区二区在线视频| 欧美性受xxxxxx黑人xyx性爽| 亚洲熟妇无码另类久久久| 三级在线免费观看| www.午夜av| 亚洲激情在线观看视频| wwwxxx黄色片| 久久精品免费网站| 婷婷六月天在线| 波多野结衣网页| 一级片免费在线观看视频| 日本激情视频在线播放| 久久久久国产一区| 91福利国产成人精品播放| 日韩av资源在线| 日韩欧美国产片| 超碰超碰超碰超碰超碰| wwwwww欧美| 国产成人手机视频| 色网站在线视频| 国产97在线 | 亚洲| 国产精品视频分类| 欧美日韩不卡在线视频| 国产精品视频一区二区三区四区五区 | 香蕉视频在线网址| 无码日本精品xxxxxxxxx| 能在线观看的av| 艳母动漫在线观看| 欧美大片在线播放| 99久久久无码国产精品性色戒| 男人的天堂狠狠干| a级片一区二区| 日本黄xxxxxxxxx100| 亚洲精品怡红院| 欧美激情 国产精品| 日本a级片在线观看| 国产一级片自拍| 国产又粗又长又爽又黄的视频| www黄色av| 农村妇女精品一二区| 日韩毛片在线免费看| 国内自拍在线观看| 日批视频在线免费看| 超碰网在线观看| av在线网址导航| 久久精品xxx| 国产精品亚洲a| 成年网站免费在线观看| 亚洲图片 自拍偷拍| 中文精品无码中文字幕无码专区| 久久福利一区二区| 男女午夜激情视频|