本文由净化在众成翻译平台上翻译。
此次版本迭代中,Node 终于支持了开发者呼声最高的 ES 模块提案。这意味着,你可以直接使用import关键字引入需要的模块。Node 8.5 可以运行如下代码:
import fs from 'fs'
使用es模块,你需要注意,引入文件的扩展名应为 mjs,同时使用 --experimental-modules标识。
在 Node.js 中使用 ES 模块的限制:
import(), V8引擎将在下一版本支持,
import.meta, V8引擎将在暂不支持,
不支持 require('./foo.mjs')
参考文章:https://github.com/nodejs/node/pull/14369/files
在 Node.js 8.5 版本中,性能监控API 。
在 Node.js 8.5 中,可以调用 mark() 和 measure() API,监控 Node.js 事件执行时间。
在 Node.js 8.5 中,你可以这样使用:
const { performance } = require('perf_hooks') performance.mark('A') setTimeout(() => {
performance.mark('B')
performance.measure('A to B', 'A', 'B')
const entry = performance.getEntriesByName('A to B', 'measure')
console.log(entry.duration)}, 10000)
官方文档:https://nodejs.org/api/perf_hooks.html
参考文章:https://github.com/nodejs/node/pull/14680/files
Node.js 8.5 推出了更高级的文件系统,在这个版本你可以直接通过 fs 模块复制某个文件的代码:
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')})
参考文章:https://github.com/nodejs/node/pull/15034/files
希望通过这些新特性,开发者能做出更令人惊喜的 Node.js 应用。
参考文章:https://nodejs.org/en/blog/release/v8.5.0/
原文来自:众成翻译
声明:所有来源为“聚合数据”的内容信息,未经本网许可,不得转载!如对内容有异议或投诉,请与我们联系。邮箱:marketing@think-land.com
通过出发地、目的地、出发日期等信息查询航班信息。
通过站到站查询火车班次时刻表等信息,同时已集成至聚合MCP Server。火车票订票MCP不仅能赋予你的Agent火车时刻查询,还能支持在线订票能力。
通过车辆vin码查询车辆的过户次数等相关信息
验证银行卡、身份证、姓名、手机号是否一致并返回账户类型
查询个人是否存在高风险行为