From 3482787529a9491f4969583f114a713480243c54 Mon Sep 17 00:00:00 2001 From: XmiliaH Date: Wed, 20 Oct 2021 12:50:36 +0200 Subject: [PATCH 1/2] Specs may add more types to typeof. Default these values to null. --- lib/contextify.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/contextify.js b/lib/contextify.js index 8171202..5535406 100644 --- a/lib/contextify.js +++ b/lib/contextify.js @@ -560,8 +560,14 @@ Decontextify.value = (value, traps, deepTraps, flags, mock) => { case 'undefined': return undefined; - default: // string, number, boolean, symbol + case 'string': + case 'number': + case 'boolean': + case 'symbol': return value; + + default: // new, unknown types can be dangerous + return null; } } catch (ex) { // Never pass the handled exception through! This block can't throw an exception under normal conditions. @@ -945,8 +951,14 @@ Contextify.value = (value, traps, deepTraps, flags, mock) => { case 'undefined': return undefined; - default: // string, number, boolean, symbol + case 'string': + case 'number': + case 'boolean': + case 'symbol': return value; + + default: // new, unknown types can be dangerous + return null; } } catch (ex) { // Never pass the handled exception through! This block can't throw an exception under normal conditions. From c9cbff620d7a914b930b7edbf16c41e2330afb96 Mon Sep 17 00:00:00 2001 From: XmiliaH Date: Wed, 20 Oct 2021 12:57:07 +0200 Subject: [PATCH 2/2] Add missed bigint --- lib/contextify.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/contextify.js b/lib/contextify.js index 5535406..d6ba2f2 100644 --- a/lib/contextify.js +++ b/lib/contextify.js @@ -564,6 +564,7 @@ Decontextify.value = (value, traps, deepTraps, flags, mock) => { case 'number': case 'boolean': case 'symbol': + case 'bigint': return value; default: // new, unknown types can be dangerous @@ -955,6 +956,7 @@ Contextify.value = (value, traps, deepTraps, flags, mock) => { case 'number': case 'boolean': case 'symbol': + case 'bigint': return value; default: // new, unknown types can be dangerous