process.unref(maybeRefable)
¥Stability: 1 - Experimental
如果对象实现了 Node.js "Refable 协议",则为 "unrefable"。具体来说,这意味着对象实现了 Symbol.for('nodejs.ref')
和 Symbol.for('nodejs.unref')
方法。"Ref'd" 对象将保持 Node.js 事件循环处于活动状态,而 "unref'd" 对象则不会。从历史上看,这是通过直接在对象上使用 ref()
和 unref()
方法实现的。但是,为了更好地支持 Web 平台 API 类型,这种模式已被弃用,取而代之的是 "Refable 协议",这些类型的 API 无法修改以添加 ref()
和 unref()
方法,但仍需要支持该行为。
¥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.