From 46d335c380510fda68e62a4cdafa58e7e7b230a1 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Wed, 25 Apr 2018 12:45:34 -0400 Subject: timers: make timer.refresh() a public API Originally added in bb5575aa75fd3071724d5eccde39a3041e1af57a discussions such as https://github.com/nodejs/node/issues/20261 show the usefulness of this API to the Node.js ecosystem. PR-URL: https://github.com/nodejs/node/pull/20298 Reviewed-By: Anatoli Papirovski Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: Ujjwal Sharma Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell Reviewed-By: Tiancheng "Timothy" Gu --- lib/internal/timers.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/internal/timers.js') diff --git a/lib/internal/timers.js b/lib/internal/timers.js index 26fc3f941b..801fce1cc3 100644 --- a/lib/internal/timers.js +++ b/lib/internal/timers.js @@ -19,7 +19,6 @@ const { // Timeout values > TIMEOUT_MAX are set to 1. const TIMEOUT_MAX = 2 ** 31 - 1; -const refreshFnSymbol = Symbol('refresh()'); const unrefedSymbol = Symbol('unrefed'); module.exports = { @@ -29,7 +28,6 @@ module.exports = { trigger_async_id_symbol, Timeout, initAsyncResource, - refreshFnSymbol, setUnrefTimeout, validateTimerDuration }; @@ -82,7 +80,7 @@ function Timeout(callback, after, args, isRepeat, isUnrefed) { initAsyncResource(this, 'Timeout'); } -Timeout.prototype[refreshFnSymbol] = function refresh() { +Timeout.prototype.refresh = function() { if (this._handle) { // Would be more ideal with uv_timer_again(), however that API does not // cause libuv's sorted timers data structure (a binary heap at the time @@ -93,6 +91,8 @@ Timeout.prototype[refreshFnSymbol] = function refresh() { } else { getTimers().active(this); } + + return this; }; function setUnrefTimeout(callback, after, arg1, arg2, arg3) { -- cgit v1.2.3