From 9da6384f5af63e615a8297d73cbe0a910b6edca9 Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Thu, 30 Nov 2023 22:55:06 +0900 Subject: [PATCH] lib: refactor to use validateFunction in diagnostics_channel Use validateFunction to remove duplicate implementation. PR-URL: https://github.com/nodejs/node/pull/50955 Reviewed-By: Luigi Pinca Reviewed-By: Antoine du Hamel Reviewed-By: Minwoo Jung --- lib/diagnostics_channel.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/diagnostics_channel.js b/lib/diagnostics_channel.js index 10d35054f56535..4e73b39c451427 100644 --- a/lib/diagnostics_channel.js +++ b/lib/diagnostics_channel.js @@ -381,9 +381,7 @@ class TracingChannel { } const callback = ArrayPrototypeAt(args, position); - if (typeof callback !== 'function') { - throw new ERR_INVALID_ARG_TYPE('callback', ['function'], callback); - } + validateFunction(callback, 'callback'); ArrayPrototypeSplice(args, position, 1, wrappedCallback); return start.runStores(context, () => {