From 4ee323864389c73af10006367a88013fc655b7a2 Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Sun, 1 Jan 2023 19:50:33 +0900 Subject: [PATCH] async_hooks: refactor to use `validateObject` PR-URL: https://github.com/nodejs/node/pull/46004 Reviewed-By: Antoine du Hamel Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- lib/async_hooks.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/async_hooks.js b/lib/async_hooks.js index 187d29281f9652..c120a4828855e9 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -24,6 +24,7 @@ const { const { kEmptyObject } = require('internal/util'); const { validateFunction, + validateObject, validateString, } = require('internal/validators'); const internal_async_hooks = require('internal/async_hooks'); @@ -276,9 +277,7 @@ const storageHook = createHook({ class AsyncLocalStorage { constructor(options = kEmptyObject) { - if (typeof options !== 'object' || options === null) { - throw new ERR_INVALID_ARG_TYPE('options', 'Object', options); - } + validateObject(options, 'options'); const { onPropagate = null } = options; if (onPropagate !== null && typeof onPropagate !== 'function') {