From 6eed49babe4eee4eb30ff06c090862414d0b0aea Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 3 Oct 2019 02:56:18 +0200 Subject: [PATCH 1/2] domain: do not import util for a simple type check This removes `require('util')` from the `domain` module. There was only a single simple type check used from the `util` module which is now inlined instead. --- lib/domain.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/domain.js b/lib/domain.js index 3dc56c179acaa1..f4ada456a1800f 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -28,7 +28,6 @@ const { Object, Reflect } = primordials; -const util = require('util'); const EventEmitter = require('events'); const { ERR_DOMAIN_CALLBACK_NOT_AVAILABLE, @@ -207,7 +206,7 @@ Domain.prototype.members = undefined; Domain.prototype._errorHandler = function(er) { var caught = false; - if (!util.isPrimitive(er)) { + if (typeof er === 'object' && er !== null || typeof er === 'function') { Object.defineProperty(er, 'domain', { configurable: true, enumerable: false, From 437c1f4e8510a69276cda06f0eea300386747e8f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 12 Oct 2019 20:13:14 -0700 Subject: [PATCH 2/2] fixup! domain: do not import util for a simple type check --- lib/domain.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/domain.js b/lib/domain.js index f4ada456a1800f..697ef6d8aded8b 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -206,7 +206,7 @@ Domain.prototype.members = undefined; Domain.prototype._errorHandler = function(er) { var caught = false; - if (typeof er === 'object' && er !== null || typeof er === 'function') { + if ((typeof er === 'object' && er !== null) || typeof er === 'function') { Object.defineProperty(er, 'domain', { configurable: true, enumerable: false,