From 3550e922b439fb6e5a1da879d97f30e8295eb136 Mon Sep 17 00:00:00 2001 From: Voltrex <62040526+VoltrexMaster@users.noreply.github.com> Date: Fri, 4 Jun 2021 23:11:25 +0430 Subject: [PATCH 1/2] vm: use missing validator The `vm` lib module's `isContext()` function should use a validator. --- lib/vm.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/vm.js b/lib/vm.js index 0b643110ae9465..8a10deae358313 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -206,9 +206,8 @@ function getContextOptions(options) { } function isContext(object) { - if (typeof object !== 'object' || object === null) { - throw new ERR_INVALID_ARG_TYPE('object', 'Object', object); - } + validateObject(object, 'object'); + return _isContext(object); } From 1f98445a0832dd94059c0b1fa4e69de6fdad0267 Mon Sep 17 00:00:00 2001 From: Voltrex <62040526+VoltrexMaster@users.noreply.github.com> Date: Sat, 5 Jun 2021 00:45:30 +0430 Subject: [PATCH 2/2] fixup! vm: use missing validator Arrays are also passed to `isContext()` when used in the internals so its a good approach to allow arrays. --- lib/vm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vm.js b/lib/vm.js index 8a10deae358313..d8e3d6586036f3 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -206,7 +206,7 @@ function getContextOptions(options) { } function isContext(object) { - validateObject(object, 'object'); + validateObject(object, 'object', { allowArray: true }); return _isContext(object); }