AbortController 类
稳定性: 1 - 实验
用于在选定的基于 Promise 的 API 中发出取消信号的实用工具类。
该 API 基于 Web API AbortController。
要使用,则使用 --experimental-abortcontroller 标志启动 Node.js。
const ac = new AbortController();
ac.signal.addEventListener('abort', () => console.log('Aborted!'),
{ once: true });
ac.abort();
console.log(ac.signal.aborted); // 打印 trueStability: 1 - Experimental
A utility class used to signal cancelation in selected Promise-based APIs.
The API is based on the Web API AbortController.
To use, launch Node.js using the --experimental-abortcontroller flag.
const ac = new AbortController();
ac.signal.addEventListener('abort', () => console.log('Aborted!'),
{ once: true });
ac.abort();
console.log(ac.signal.aborted); // Prints True