- assert 断言
- async_hooks 异步钩子
- async_hooks/context 异步上下文
- buffer 缓冲区
- C++插件
- C/C++插件(使用 Node-API)
- C++嵌入器
- child_process 子进程
- cluster 集群
- CLI 命令行
- console 控制台
- crypto 加密
- crypto/webcrypto 网络加密
- debugger 调试器
- deprecation 弃用
- dgram 数据报
- diagnostics_channel 诊断通道
- dns 域名服务器
- domain 域
- env 环境变量
- Error 错误
- events 事件触发器
- fs 文件系统
- global 全局变量
- http 超文本传输协议
- http2 超文本传输协议 2.0
- https 安全超文本传输协议
- inspector 检查器
- Intl 国际化
- module 模块
- module/cjs CommonJS 模块
- module/esm ECMAScript 模块
- module/package 包模块
- module/typescript TS 模块
- net 网络
- os 操作系统
- path 路径
- perf_hooks 性能钩子
- permission 权限
- process 进程
- punycode 域名代码
- querystring 查询字符串
- readline 逐行读取
- repl 交互式解释器
- report 诊断报告
- sea 单个可执行应用程序
- sqlite 轻型数据库
- stream 流
- stream/web 网络流
- string_decoder 字符串解码器
- test 测试
- timers 定时器
- tls 安全传输层
- trace_events 跟踪事件
- tty 终端
- url 网址
- util 实用工具
- v8 引擎
- vm 虚拟机
- wasi 网络汇编系统接口
- worker_threads 工作线程
- zlib 压缩
Node.js v25.3.0 文档
- Node.js v25.3.0
-
目录
- 全局对象
- 类:
AbortController - 类:
Blob - 类:
Buffer - 类:
ByteLengthQueuingStrategy __dirname__filenameatob(data)- 类:
BroadcastChannel btoa(data)clearImmediate(immediateObject)clearInterval(intervalObject)clearTimeout(timeoutObject)- 类:
CloseEvent - 类:
CompressionStream console- 类:
CountQueuingStrategy - 类:
Crypto crypto- 类:
CryptoKey - 类:
CustomEvent - 类:
DecompressionStream ErrorEvent- 类:
Event - 类:
EventSource - 类:
EventTarget exportsfetch- 类:
File - 类:
FormData global- 类:
Headers localStorage- 类:
MessageChannel - 类:
MessageEvent - 类:
MessagePort module- 类:
Navigator navigator- 类:
PerformanceEntry - 类:
PerformanceMark - 类:
PerformanceMeasure - 类:
PerformanceObserver - 类:
PerformanceObserverEntryList - 类:
PerformanceResourceTiming performanceprocessqueueMicrotask(callback)- 类:
ReadableByteStreamController - 类:
ReadableStream - 类:
ReadableStreamBYOBReader - 类:
ReadableStreamBYOBRequest - 类:
ReadableStreamDefaultController - 类:
ReadableStreamDefaultReader require()- 类:
Response - 类:
Request sessionStoragesetImmediate(callback[, ...args])setInterval(callback, delay[, ...args])setTimeout(callback, delay[, ...args])- 类:
Storage structuredClone(value[, options])- 类:
SubtleCrypto - 类:
DOMException - 类:
TextDecoder - 类:
TextDecoderStream - 类:
TextEncoder - 类:
TextEncoderStream - 类:
TransformStream - 类:
TransformStreamDefaultController - 类:
URL - 类:
URLPattern - 类:
URLSearchParams - 类:
WebAssembly - 类:
WebSocket - 类:
WritableStream - 类:
WritableStreamDefaultController - 类:
WritableStreamDefaultWriter
- 类:
- 全局对象
-
导航
- assert 断言
- async_hooks 异步钩子
- async_hooks/context 异步上下文
- buffer 缓冲区
- C++插件
- C/C++插件(使用 Node-API)
- C++嵌入器
- child_process 子进程
- cluster 集群
- CLI 命令行
- console 控制台
- crypto 加密
- crypto/webcrypto 网络加密
- debugger 调试器
- deprecation 弃用
- dgram 数据报
- diagnostics_channel 诊断通道
- dns 域名服务器
- domain 域
- env 环境变量
- Error 错误
- events 事件触发器
- fs 文件系统
- global 全局变量
- http 超文本传输协议
- http2 超文本传输协议 2.0
- https 安全超文本传输协议
- inspector 检查器
- Intl 国际化
- module 模块
- module/cjs CommonJS 模块
- module/esm ECMAScript 模块
- module/package 包模块
- module/typescript TS 模块
- net 网络
- os 操作系统
- path 路径
- perf_hooks 性能钩子
- permission 权限
- process 进程
- punycode 域名代码
- querystring 查询字符串
- readline 逐行读取
- repl 交互式解释器
- report 诊断报告
- sea 单个可执行应用程序
- sqlite 轻型数据库
- stream 流
- stream/web 网络流
- string_decoder 字符串解码器
- test 测试
- timers 定时器
- tls 安全传输层
- trace_events 跟踪事件
- tty 终端
- url 网址
- util 实用工具
- v8 引擎
- vm 虚拟机
- wasi 网络汇编系统接口
- worker_threads 工作线程
- zlib 压缩
- 其他版本
全局对象#>
【Global objects】
这些对象在所有模块中都可用。
【These objects are available in all modules.】
以下变量看起来可能是全局的,但实际上不是。它们仅存在于 CommonJS 模块 的作用域中:
【The following variables may appear to be global but are not. They exist only in the scope of CommonJS modules:】
此处列出的对象是 Node.js 特有的。还有一些是 JavaScript 语言本身的一部分,它们也是全局可访问的。
【The objects listed here are specific to Node.js. There are built-in objects that are part of the JavaScript language itself, which are also globally accessible.】
类:AbortController#>
【Class: AbortController】
一个实用类,用于在选定的基于 Promise 的 API 中发出取消信号。该 API 基于 Web API <AbortController>。
【A utility class used to signal cancelation in selected Promise-based APIs.
The API is based on the Web API <AbortController>.】
const ac = new AbortController();
ac.signal.addEventListener('abort', () => console.log('Aborted!'),
{ once: true });
ac.abort();
console.log(ac.signal.aborted); // Prints true
abortController.abort([reason])#>
reason<any> 一个可选的原因,可以通过AbortSignal的reason属性获取。
触发中止信号,使 abortController.signal 发出 'abort' 事件。
【Triggers the abort signal, causing the abortController.signal to emit
the 'abort' event.】
abortController.signal#>
类:AbortSignal#>
【Class: AbortSignal】
AbortSignal 用于在调用 abortController.abort() 方法时通知观察者。
【The AbortSignal is used to notify observers when the
abortController.abort() method is called.】
静态方法:AbortSignal.abort([reason])#>
【Static method: AbortSignal.abort([reason])】
reason<any>- 返回:<AbortSignal>
返回一个已经被中止的新的 AbortSignal。
【Returns a new already aborted AbortSignal.】
静态方法:AbortSignal.timeout(delay)#>
【Static method: AbortSignal.timeout(delay)】
delay<number> 在触发 AbortSignal 之前等待的毫秒数。
返回一个新的 AbortSignal,它将在 delay 毫秒后被中止。
【Returns a new AbortSignal which will be aborted in delay milliseconds.】
静态方法:AbortSignal.any(signals)#>
【Static method: AbortSignal.any(signals)】
signals<AbortSignal[]> 用于组合成新的AbortSignal的AbortSignal列表。
返回一个新的 AbortSignal,如果提供的任意信号被中止,该信号也会被中止。它的 abortSignal.reason 将被设置为导致它被中止的 signals 中的任意一个。
【Returns a new AbortSignal which will be aborted if any of the provided
signals are aborted. Its abortSignal.reason will be set to whichever
one of the signals caused it to be aborted.】
事件:'abort'#>
【Event: 'abort'】
当调用 abortController.abort() 方法时,会触发 'abort' 事件。回调函数会使用一个包含单个 type 属性且值为 'abort' 的对象作为参数被调用:
【The 'abort' event is emitted when the abortController.abort() method
is called. The callback is invoked with a single object argument with a
single type property set to 'abort':】
const ac = new AbortController();
// Use either the onabort property...
ac.signal.onabort = () => console.log('aborted!');
// Or the EventTarget API...
ac.signal.addEventListener('abort', (event) => {
console.log(event.type); // Prints 'abort'
}, { once: true });
ac.abort();
AbortSignal 所关联的 AbortController 只会触发一次 'abort' 事件。我们建议在添加 'abort' 事件监听器之前,代码先检查 abortSignal.aborted 属性是否为 false。
【The AbortController with which the AbortSignal is associated will only
ever trigger the 'abort' event once. We recommended that code check
that the abortSignal.aborted attribute is false before adding an 'abort'
event listener.】
附加到 AbortSignal 的任何事件监听器都应使用 { once: true } 选项(或者如果使用 EventEmitter API 附加监听器,则使用 once() 方法),以确保事件监听器在处理 'abort' 事件后立即被移除。否则可能会导致内存泄漏。
【Any event listeners attached to the AbortSignal should use the
{ once: true } option (or, if using the EventEmitter APIs to attach a
listener, use the once() method) to ensure that the event listener is
removed as soon as the 'abort' event is handled. Failure to do so may
result in memory leaks.】
abortSignal.aborted#>
- 类型:<boolean> 在
AbortController被中止后为 true。
abortSignal.onabort#>
- 类型:<Function>
一个可选的回调函数,用户代码可以设置它以在调用 abortController.abort() 函数时收到通知。
【An optional callback function that may be set by user code to be notified
when the abortController.abort() function has been called.】
abortSignal.reason#>
- 类型:<any>
当 AbortSignal 被触发时指定的可选原因。
【An optional reason specified when the AbortSignal was triggered.】
const ac = new AbortController();
ac.abort(new Error('boom!'));
console.log(ac.signal.reason); // Error: boom!
abortSignal.throwIfAborted()#>
如果 abortSignal.aborted 为 true,则抛出 abortSignal.reason。
【If abortSignal.aborted is true, throws abortSignal.reason.】
类:Blob#>
【Class: Blob】
参见 <Blob>。
【See <Blob>.】
类:Buffer#>
【Class: Buffer】
- 类型:<Function>
用于处理二进制数据。请参见 缓冲区段。
【Used to handle binary data. See the buffer section.】
类:ByteLengthQueuingStrategy#>
【Class: ByteLengthQueuingStrategy】
ByteLengthQueuingStrategy 的浏览器兼容实现。
【A browser-compatible implementation of ByteLengthQueuingStrategy.】
__dirname#>
这个变量看起来可能是全局的,但实际上不是。参见 __dirname。
【This variable may appear to be global but is not. See __dirname.】
__filename#>
这个变量看起来可能是全局的,但实际上不是。参见 __filename。
【This variable may appear to be global but is not. See __filename.】
atob(data)#>
Buffer.from(data, 'base64')。buffer.atob() 的全球别名。
【Global alias for buffer.atob().】
类:BroadcastChannel#>
【Class: BroadcastChannel】
【See <BroadcastChannel>.】
btoa(data)#>
buf.toString('base64')。buffer.btoa() 的全球别名。
【Global alias for buffer.btoa().】
clearImmediate(immediateObject)#>
clearImmediate 在 定时器 部分中有所描述。
clearInterval(intervalObject)#>
clearInterval 在 定时器 部分中有所描述。
clearTimeout(timeoutObject)#>
clearTimeout 在 定时器 部分中有描述。
类:CloseEvent#>
【Class: CloseEvent】
适用于浏览器的 CloseEvent 实现。使用 --no-experimental-websocket CLI 标志可禁用此 API。
【A browser-compatible implementation of CloseEvent. Disable this API
with the --no-experimental-websocket CLI flag.】
类:CompressionStream#>
【Class: CompressionStream】
CompressionStream 的浏览器兼容实现。
【A browser-compatible implementation of CompressionStream.】
console#>
- 类型: <Object>
用于打印到标准输出和标准错误。请参见 console 部分。
【Used to print to stdout and stderr. See the console section.】
类:CountQueuingStrategy#>
【Class: CountQueuingStrategy】
CountQueuingStrategy 的浏览器兼容实现。
【A browser-compatible implementation of CountQueuingStrategy.】
类:Crypto#>
【Class: Crypto】
一个与浏览器兼容的 <Crypto> 实现。仅当 Node.js 二进制文件在编译时包含对 node:crypto 模块的支持时,才可使用此全局对象。
【A browser-compatible implementation of <Crypto>. This global is available
only if the Node.js binary was compiled with including support for the
node:crypto module.】
crypto#>
网络加密 API 的浏览器兼容实现。
【A browser-compatible implementation of the Web Crypto API.】
类:CryptoKey#>
【Class: CryptoKey】
兼容浏览器的 <CryptoKey> 实现。仅当 Node.js 二进制文件在编译时包含对 node:crypto 模块的支持时,此全局变量才可用。
【A browser-compatible implementation of <CryptoKey>. This global is available
only if the Node.js binary was compiled with including support for the
node:crypto module.】
类:CustomEvent#>
【Class: CustomEvent】
一个与浏览器兼容的 <CustomEvent> 实现。
【A browser-compatible implementation of <CustomEvent>.】
类:DecompressionStream#>
【Class: DecompressionStream】
DecompressionStream 的浏览器兼容实现。
【A browser-compatible implementation of DecompressionStream.】
ErrorEvent#>
一个与浏览器兼容的 ErrorEvent 实现。
【A browser-compatible implementation of ErrorEvent.】
类:Event#>
【Class: Event】
一个与浏览器兼容的 Event 类实现。更多详情请参见 EventTarget 和 Event API。
【A browser-compatible implementation of the Event class. See
EventTarget and Event API for more details.】
类:EventSource#>
【Class: EventSource】
--experimental-eventsource CLI 标志启用此 API。一个与浏览器兼容的 EventSource 实现。
【A browser-compatible implementation of EventSource.】
类:EventTarget#>
【Class: EventTarget】
EventTarget 类的浏览器兼容实现。更多详情请参见 EventTarget 和 Event API。
【A browser-compatible implementation of the EventTarget class. See
EventTarget and Event API for more details.】
exports#>
这个变量看起来可能是全局的,但实际上不是。参见 exports。
【This variable may appear to be global but is not. See exports.】
fetch#>
一个与浏览器兼容的 fetch() 函数实现。
【A browser-compatible implementation of the fetch() function.】
const res = await fetch('https://nodejs.cn/api/documentation.json');
if (res.ok) {
const data = await res.json();
console.log(data);
}
该实现基于 undici,这是一个为 Node.js 从零编写的 HTTP/1.1 客户端。你可以通过读取 process.versions.undici 属性来查看你的 Node.js 进程中打包了哪个版本的 undici。
【The implementation is based upon undici, an HTTP/1.1 client
written from scratch for Node.js. You can figure out which version of undici is bundled
in your Node.js process reading the process.versions.undici property.】
自定义调度程序#>
【Custom dispatcher】
你可以使用自定义调度器来分发请求,将其传递到 fetch 的选项对象中。调度器必须与 undici 的 Dispatcher 类 兼容。
【You can use a custom dispatcher to dispatch requests passing it in fetch's options object.
The dispatcher must be compatible with undici's
Dispatcher class.】
fetch(url, { dispatcher: new MyAgent() });
可以通过安装 undici 并使用 setGlobalDispatcher() 方法来更改 Node.js 中的全局调度器。调用此方法将影响 undici 和 Node.js。
【It is possible to change the global dispatcher in Node.js by installing undici and using
the setGlobalDispatcher() method. Calling this method will affect both undici and
Node.js.】
import { setGlobalDispatcher } from 'undici';
setGlobalDispatcher(new MyAgent());
相关类#>
【Related classes】
以下全局变量可与 fetch 一起使用:
【The following globals are available to use with fetch:】
类:File#>
【Class: File】
参见 <File>。
【See <File>.】
类:FormData#>
【Class: FormData】
一个与浏览器兼容的 <FormData> 实现。
【A browser-compatible implementation of <FormData>.】
global#>
globalThis。- 类型:<Object> 全局命名空间对象。
在浏览器中,顶层作用域传统上是全局作用域。这意味着 var something 会定义一个新的全局变量,除非在 ECMAScript 模块中。在 Node.js 中情况有所不同。顶层作用域不是全局作用域;Node.js 模块内部的 var something 将是该模块的局部变量,无论它是 CommonJS 模块 还是 ECMAScript 模块。
【In browsers, the top-level scope has traditionally been the global scope. This
means that var something will define a new global variable, except within
ECMAScript modules. In Node.js, this is different. The top-level scope is not
the global scope; var something inside a Node.js module will be local to that
module, regardless of whether it is a CommonJS module or an
ECMAScript module.】
类:Headers#>
【Class: Headers】
一个与浏览器兼容的 <Headers> 实现。
【A browser-compatible implementation of <Headers>.】
localStorage#>
localStorage 的浏览器兼容实现。数据以未加密形式存储在 --localstorage-file CLI 标志指定的文件中。可存储的最大数据量为 10 MB。通过 Web Storage API 以外的方式修改此数据不受支持。可使用 --no-webstorage(或其别名 --no-experimental-webstorage)CLI 标志禁用此 API。在服务器环境中使用时,localStorage 数据不会按用户或请求单独存储,而是在所有用户和请求之间共享。
【A browser-compatible implementation of localStorage. Data is stored
unencrypted in the file specified by the --localstorage-file CLI flag.
The maximum amount of data that can be stored is 10 MB.
Any modification of this data outside of the Web Storage API is not supported.
Disable this API with the --no-webstorage (or its alias --no-experimental-webstorage) CLI flag.
localStorage data is not stored per user or per request when used in the context
of a server, it is shared across all users and requests.】
类:MessageChannel#>
【Class: MessageChannel】
MessageChannel 类。更多详情请参见 MessageChannel。
【The MessageChannel class. See MessageChannel for more details.】
类:MessageEvent#>
【Class: MessageEvent】
一个与浏览器兼容的 MessageEvent 实现。
【A browser-compatible implementation of MessageEvent.】
类:MessagePort#>
【Class: MessagePort】
MessagePort 类。更多详情请参见 MessagePort。
【The MessagePort class. See MessagePort for more details.】
module#>
这个变量看起来可能是全局的,但实际上不是。参见 module。
【This variable may appear to be global but is not. See module.】
类:Navigator#>
【Class: Navigator】
--no-experimental-global-navigator CLI 标志可以禁用此 API。导航器 API 的部分实现。
【A partial implementation of the Navigator API.】
navigator#>
--no-experimental-global-navigator CLI 标志可以禁用此 API。window.navigator 的部分实现。
【A partial implementation of window.navigator.】
navigator.hardwareConcurrency#>
- 类型:<number>
navigator.hardwareConcurrency 只读属性返回当前 Node.js 实例可用的逻辑处理器数量。
【The navigator.hardwareConcurrency read-only property returns the number of
logical processors available to the current Node.js instance.】
console.log(`This process is running on ${navigator.hardwareConcurrency} logical processors`);
navigator.language#>
- 类型:<string>
navigator.language 只读属性返回一个字符串,表示 Node.js 实例的首选语言。该语言将由 Node.js 在运行时使用的 ICU 库根据操作系统的默认语言来确定。
【The navigator.language read-only property returns a string representing the
preferred language of the Node.js instance. The language will be determined by
the ICU library used by Node.js at runtime based on the
default language of the operating system.】
该值表示在 RFC 5646 中定义的语言版本。
【The value is representing the language version as defined in RFC 5646.】
在没有 ICU 的构建中,回退值为 'en-US'。
【The fallback value on builds without ICU is 'en-US'.】
console.log(`The preferred language of the Node.js instance has the tag '${navigator.language}'`);
navigator.languages#>
- 类型:{Array
}
navigator.languages 只读属性返回一个字符串数组,表示 Node.js 实例的首选语言。默认情况下,navigator.languages 仅包含 navigator.language 的值,该值将由 Node.js 在运行时使用的 ICU 库根据操作系统的默认语言来确定。
【The navigator.languages read-only property returns an array of strings
representing the preferred languages of the Node.js instance.
By default navigator.languages contains only the value of
navigator.language, which will be determined by the ICU library used by
Node.js at runtime based on the default language of the operating system.】
在没有 ICU 的构建中,回退值是 ['en-US']。
【The fallback value on builds without ICU is ['en-US'].】
console.log(`The preferred languages are '${navigator.languages}'`);
navigator.platform#>
- 类型:<string>
navigator.platform 只读属性返回一个字符串,用于识别 Node.js 实例运行的平台。
【The navigator.platform read-only property returns a string identifying the
platform on which the Node.js instance is running.】
console.log(`This process is running on ${navigator.platform}`);
navigator.userAgent#>
- 类型:<string>
navigator.userAgent 只读属性返回包含运行时名称和主要版本号的用户代理信息。
【The navigator.userAgent read-only property returns user agent
consisting of the runtime name and major version number.】
console.log(`The user-agent is ${navigator.userAgent}`); // Prints "Node.js/21"
navigator.locks#>
navigator.locks 只读属性返回一个 LockManager 实例,可用于协调对可能在同一进程的多个线程之间共享的资源的访问。这个全局实现与 浏览器 LockManager API 的语义相匹配。
【The navigator.locks read-only property returns a LockManager instance that
can be used to coordinate access to resources that may be shared across multiple
threads within the same process. This global implementation matches the semantics
of the browser LockManager API.】
// Request an exclusive lock
await navigator.locks.request('my_resource', async (lock) => {
// The lock has been acquired.
console.log(`Lock acquired: ${lock.name}`);
// Lock is automatically released when the function returns
});
// Request a shared lock
await navigator.locks.request('shared_resource', { mode: 'shared' }, async (lock) => {
// Multiple shared locks can be held simultaneously
console.log(`Shared lock acquired: ${lock.name}`);
});// Request an exclusive lock
navigator.locks.request('my_resource', async (lock) => {
// The lock has been acquired.
console.log(`Lock acquired: ${lock.name}`);
// Lock is automatically released when the function returns
}).then(() => {
console.log('Lock released');
});
// Request a shared lock
navigator.locks.request('shared_resource', { mode: 'shared' }, async (lock) => {
// Multiple shared locks can be held simultaneously
console.log(`Shared lock acquired: ${lock.name}`);
}).then(() => {
console.log('Shared lock released');
});
请参阅 worker_threads.locks 以获取详细的 API 文档。
【See worker_threads.locks for detailed API documentation.】
类:PerformanceEntry#>
【Class: PerformanceEntry】
PerformanceEntry 类。更多详情请参见 PerformanceEntry。
【The PerformanceEntry class. See PerformanceEntry for more details.】
类:PerformanceMark#>
【Class: PerformanceMark】
PerformanceMark 类。更多详情请参见 PerformanceMark。
【The PerformanceMark class. See PerformanceMark for more details.】
类:PerformanceMeasure#>
【Class: PerformanceMeasure】
PerformanceMeasure 类。更多详情请参见 PerformanceMeasure。
【The PerformanceMeasure class. See PerformanceMeasure for more details.】
类:PerformanceObserver#>
【Class: PerformanceObserver】
PerformanceObserver 类。更多详情请参见 PerformanceObserver。
【The PerformanceObserver class. See PerformanceObserver for more details.】
类:PerformanceObserverEntryList#>
【Class: PerformanceObserverEntryList】
PerformanceObserverEntryList 类。详情请参见 PerformanceObserverEntryList。
【The PerformanceObserverEntryList class. See
PerformanceObserverEntryList for more details.】
类:PerformanceResourceTiming#>
【Class: PerformanceResourceTiming】
PerformanceResourceTiming 类。更多详情请参见 PerformanceResourceTiming。
【The PerformanceResourceTiming class. See PerformanceResourceTiming for
more details.】
performance#>
【The perf_hooks.performance object.】
process#>
- 类型: <Object>
process 对象。请参阅 process 对象 部分。
【The process object. See the process object section.】
queueMicrotask(callback)#>
callback<Function> 要排队的函数。
queueMicrotask() 方法将微任务排队以调用 callback。如果 callback 抛出异常,将触发 process 对象 'uncaughtException' 事件。
【The queueMicrotask() method queues a microtask to invoke callback. If
callback throws an exception, the process object 'uncaughtException'
event will be emitted.】
微任务队列由 V8 管理,并且可以以类似于由 Node.js 管理的 process.nextTick() 队列的方式使用。在 Node.js 事件循环的每一轮中,process.nextTick() 队列总是在微任务队列之前处理。
【The microtask queue is managed by V8 and may be used in a similar manner to
the process.nextTick() queue, which is managed by Node.js. The
process.nextTick() queue is always processed before the microtask queue
within each turn of the Node.js event loop.】
// Here, `queueMicrotask()` is used to ensure the 'load' event is always
// emitted asynchronously, and therefore consistently. Using
// `process.nextTick()` here would result in the 'load' event always emitting
// before any other promise jobs.
DataHandler.prototype.load = async function load(key) {
const hit = this._cache.get(key);
if (hit !== undefined) {
queueMicrotask(() => {
this.emit('load', hit);
});
return;
}
const data = await fetchData(key);
this._cache.set(key, data);
this.emit('load', data);
};
类:ReadableByteStreamController#>
【Class: ReadableByteStreamController】
ReadableByteStreamController 的浏览器兼容实现。
【A browser-compatible implementation of ReadableByteStreamController.】
类:ReadableStream#>
【Class: ReadableStream】
ReadableStream 的浏览器兼容实现。
【A browser-compatible implementation of ReadableStream.】
类:ReadableStreamBYOBReader#>
【Class: ReadableStreamBYOBReader】
ReadableStreamBYOBReader 的浏览器兼容实现。
【A browser-compatible implementation of ReadableStreamBYOBReader.】
类:ReadableStreamBYOBRequest#>
【Class: ReadableStreamBYOBRequest】
ReadableStreamBYOBRequest 的浏览器兼容实现。
【A browser-compatible implementation of ReadableStreamBYOBRequest.】
类:ReadableStreamDefaultController#>
【Class: ReadableStreamDefaultController】
ReadableStreamDefaultController 的浏览器兼容实现。
【A browser-compatible implementation of ReadableStreamDefaultController.】
类:ReadableStreamDefaultReader#>
【Class: ReadableStreamDefaultReader】
ReadableStreamDefaultReader 的浏览器兼容实现。
【A browser-compatible implementation of ReadableStreamDefaultReader.】
require()#>
这个变量看起来可能是全局的,但实际上不是。参见 require()。
【This variable may appear to be global but is not. See require().】
类:Response#>
【Class: Response】
一个与浏览器兼容的 <Response> 实现。
【A browser-compatible implementation of <Response>.】
类:Request#>
【Class: Request】
一个与浏览器兼容的 <Request> 实现。
【A browser-compatible implementation of <Request>.】
sessionStorage#>
sessionStorage 的浏览器兼容实现。数据存储在内存中,存储配额为 10 MB。sessionStorage 数据仅在当前运行的进程内保留,不在不同的工作线程之间共享。
【A browser-compatible implementation of sessionStorage. Data is stored in
memory, with a storage quota of 10 MB. sessionStorage data persists only within
the currently running process, and is not shared between workers.】
setImmediate(callback[, ...args])#>
setImmediate 在 定时器 部分中有所描述。
setInterval(callback, delay[, ...args])#>
setInterval 在 定时器 部分中有所描述。
setTimeout(callback, delay[, ...args])#>
setTimeout 在 定时器 部分中有所描述。
类:Storage#>
【Class: Storage】
一个与浏览器兼容的 Storage 实现。可以使用 --no-webstorage(或其别名 --no-experimental-webstorage)命令行标志禁用此 API。
【A browser-compatible implementation of Storage. Disable this API with the
--no-webstorage (or its alias --no-experimental-webstorage) CLI flag.】
structuredClone(value[, options])#>
WHATWG structuredClone 方法。
【The WHATWG structuredClone method.】
类:SubtleCrypto#>
【Class: SubtleCrypto】
一个与浏览器兼容的 <SubtleCrypto> 实现。仅当 Node.js 二进制文件在编译时包含对 node:crypto 模块的支持时,才可使用此全局对象。
【A browser-compatible implementation of <SubtleCrypto>. This global is available
only if the Node.js binary was compiled with including support for the
node:crypto module.】
类:DOMException#>
【Class: DOMException】
WHATWG DOMException 类。
【The WHATWG DOMException class.】
类:TextDecoder#>
【Class: TextDecoder】
WHATWG TextDecoder 类。请参见 TextDecoder 节。
【The WHATWG TextDecoder class. See the TextDecoder section.】
类:TextDecoderStream#>
【Class: TextDecoderStream】
TextDecoderStream 的浏览器兼容实现。
【A browser-compatible implementation of TextDecoderStream.】
类:TextEncoder#>
【Class: TextEncoder】
WHATWG TextEncoder 类。请参见 TextEncoder 节。
【The WHATWG TextEncoder class. See the TextEncoder section.】
类:TextEncoderStream#>
【Class: TextEncoderStream】
TextEncoderStream 的浏览器兼容实现。
【A browser-compatible implementation of TextEncoderStream.】
类:TransformStream#>
【Class: TransformStream】
TransformStream 的浏览器兼容实现。
【A browser-compatible implementation of TransformStream.】
类:TransformStreamDefaultController#>
【Class: TransformStreamDefaultController】
TransformStreamDefaultController 的浏览器兼容实现。
【A browser-compatible implementation of TransformStreamDefaultController.】
类:URL#>
【Class: URL】
WHATWG 的 URL 类。参见 URL 节。
【The WHATWG URL class. See the URL section.】
类:URLPattern#>
【Class: URLPattern】
WHATWG URLPattern 类。请参见 URLPattern 部分。
【The WHATWG URLPattern class. See the URLPattern section.】
类:URLSearchParams#>
【Class: URLSearchParams】
WHATWG 的 URLSearchParams 类。参见 URLSearchParams 部分。
【The WHATWG URLSearchParams class. See the URLSearchParams section.】
类:WebAssembly#>
【Class: WebAssembly】
- 类型: <Object>
作为所有 W3C WebAssembly 相关功能命名空间的对象。有关用法和兼容性,请参见 Mozilla 开发者网络。
【The object that acts as the namespace for all W3C WebAssembly related functionality. See the Mozilla Developer Network for usage and compatibility.】
类:WebSocket#>
【Class: WebSocket】
适用于浏览器的 WebSocket 实现。使用 --no-experimental-websocket CLI 标志禁用此 API。
【A browser-compatible implementation of WebSocket. Disable this API
with the --no-experimental-websocket CLI flag.】
类:WritableStream#>
【Class: WritableStream】
WritableStream 的浏览器兼容实现。
【A browser-compatible implementation of WritableStream.】
类:WritableStreamDefaultController#>
【Class: WritableStreamDefaultController】
WritableStreamDefaultController 的浏览器兼容实现。
【A browser-compatible implementation of WritableStreamDefaultController.】
类:WritableStreamDefaultWriter#>
【Class: WritableStreamDefaultWriter】
WritableStreamDefaultWriter 的浏览器兼容实现。
【A browser-compatible implementation of WritableStreamDefaultWriter.】