From fcfce1470ddce72740076153f49f82af56733076 Mon Sep 17 00:00:00 2001 From: RJ David Date: Thu, 3 Mar 2022 15:03:23 +0800 Subject: [PATCH 1/2] Add check if value exists --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 4b27091..bde5eec 100644 --- a/index.js +++ b/index.js @@ -78,7 +78,7 @@ const destroyCircular = ({ } // TODO: Use `stream.isReadable()` when targeting Node.js 18. - if (typeof value === 'object' && typeof value.pipe === 'function') { + if (typeof value === 'object' && value && typeof value.pipe === 'function') { to[key] = '[object Stream]'; continue; } From 890af000a7792af73d4fe56081405c4770c13f4f Mon Sep 17 00:00:00 2001 From: rj-david <30392688+rj-david@users.noreply.github.com> Date: Mon, 21 Mar 2022 04:36:36 +0800 Subject: [PATCH 2/2] Update index.js Suggested change on checking value Co-authored-by: Sindre Sorhus --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index bde5eec..75723ad 100644 --- a/index.js +++ b/index.js @@ -78,7 +78,7 @@ const destroyCircular = ({ } // TODO: Use `stream.isReadable()` when targeting Node.js 18. - if (typeof value === 'object' && value && typeof value.pipe === 'function') { + if (value !== null && typeof value === 'object' && typeof value.pipe === 'function') { to[key] = '[object Stream]'; continue; }