process.unref(maybeRefable)


稳定性: 1 - 实验性

  • maybeRefable <any> 可能被“取消引用”的对象。

如果一个对象实现了 Node.js 的 “Refable 协议”,那么它就是“unrefable”的。具体来说,这意味着该对象实现了 Symbol.for('nodejs.ref')Symbol.for('nodejs.unref') 方法。“Ref'd”的对象会保持 Node.js 事件循环活跃,而“unref'd”的对象则不会。历史上,这是通过直接在对象上使用 ref()unref() 方法来实现的。然而,为了更好地支持那些无法修改 API 添加 ref()unref() 方法但仍然需要支持该行为的 Web 平台 API 类型,这种模式正逐渐被“Refable 协议”取代。

【An object is "unrefable" if it implements the Node.js "Refable protocol". Specifically, this means that the object implements the Symbol.for('nodejs.ref') and Symbol.for('nodejs.unref') methods. "Ref'd" objects will keep the Node.js event loop alive, while "unref'd" objects will not. Historically, this was implemented by using ref() and unref() methods directly on the objects. This pattern, however, is being deprecated in favor of the "Refable protocol" in order to better support Web Platform API types whose APIs cannot be modified to add ref() and unref() methods but still need to support that behavior.】