From 48a2568f411cf09999b7e82992d15142ce9a45b0 Mon Sep 17 00:00:00 2001 From: Anatoli Papirovski Date: Wed, 23 May 2018 02:01:53 +0400 Subject: [PATCH] timers: add hasRef method to Timeout & Immediate Provide a way to check whether the current timer or immediate is refed. PR-URL: https://github.com/nodejs/node/pull/20898 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Jeremiah Senkpiel --- doc/api/timers.md | 18 ++++++++++++++++++ lib/timers.js | 12 ++++++++++-- test/parallel/test-timers-immediate-unref.js | 8 ++++++++ test/parallel/test-timers-unref.js | 8 +++++++- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/doc/api/timers.md b/doc/api/timers.md index 1eb511c3b92b48..b86a49a932ec1c 100644 --- a/doc/api/timers.md +++ b/doc/api/timers.md @@ -23,6 +23,15 @@ running as long as the immediate is active. The `Immediate` object returned by [`setImmediate()`][] exports both `immediate.ref()` and `immediate.unref()` functions that can be used to control this default behavior. +### immediate.hasRef() + + +* Returns: {boolean} + +If true, the `Immediate` object will keep the Node.js event loop active. + ### immediate.ref() + +* Returns: {boolean} + +If true, the `Timeout` object will keep the Node.js event loop active. + ### timeout.ref()