From 6318078d2cb9980c4dc218d7fbe658cb77454165 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 2 Jun 2017 23:49:55 +0200 Subject: async_hooks: make sure `.{en|dis}able() === this` Make sure that `hook.enable()` and `hook.disable()` return `hook` consistently, as the documentation indicates. PR-URL: https://github.com/nodejs/node/pull/13418 Reviewed-By: Refael Ackermann Reviewed-By: Andreas Madsen Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Trevor Norris --- lib/async_hooks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/async_hooks.js b/lib/async_hooks.js index aec73ed770..d343a0e3de 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -96,7 +96,7 @@ class AsyncHook { // Each hook is only allowed to be added once. if (hooks_array.includes(this)) - return; + return this; if (!setupHooksCalled) { setupHooksCalled = true; @@ -124,7 +124,7 @@ class AsyncHook { const index = hooks_array.indexOf(this); if (index === -1) - return; + return this; hook_fields[kInit] -= +!!this[init_symbol]; hook_fields[kBefore] -= +!!this[before_symbol]; -- cgit v1.2.3