bump package version to 3.0.3
[squeep-logger-json-console] / lib / json-replacers.js
index 51eacb3cb5f2c8a259ce0bf55496ec64391fbb79..0ccea720bd7e77ff7ca8702fa74e2cecb2a941e8 100644 (file)
@@ -8,9 +8,9 @@ const http = require('node:http');
 
 /**
  * Convert any Error to a plain Object.
- * @param {String} _key
- * @param {*} value
- * @returns {Object}
+ * @param {string} _key key, unused
+ * @param {*} value value to possibly replace
+ * @returns {object} value or replaced value
  */
 function replacerError(_key, value) {
   if (value instanceof Error) {
@@ -24,9 +24,9 @@ function replacerError(_key, value) {
 
 /**
  * Convert any BigInt type to a String.
- * @param {String} _key
- * @param {*} value
- * @returns {String}
+ * @param {string} _key key, unused
+ * @param {*} value value to possibly replace
+ * @returns {string} value or replaced value
  */
 function replacerBigInt(_key, value) {
   if (typeof value === 'bigint') {
@@ -41,9 +41,9 @@ function replacerBigInt(_key, value) {
  * Also sanitizes any Authorization header.  We do this here rather than
  * in sanitization stage so that we do not have to rely on a set path to
  * this object.
- * @param {String} _key
- * @param {*} value
- * @returns {Object}
+ * @param {string} _key key, unused
+ * @param {*} value value to possibly replace
+ * @returns {object} value or replaved value
  */
 function replacerHttpIncomingMessage(_key, value) {
   if (value instanceof http.IncomingMessage) {
@@ -62,9 +62,10 @@ function replacerHttpIncomingMessage(_key, value) {
       // This blurs entire auth string if no space found, because -1 from indexOf.
       const blurredAuthHeader = authHeader.slice(0, spaceIndex + 1) + '*'.repeat(authHeader.length - (spaceIndex + 1));
       // New headers object, as we change it.
-      newValue.headers = Object.assign({}, newValue.headers, {
+      newValue.headers = {
+        ...newValue.headers,
         authorization: blurredAuthHeader,
-      });
+      };
     }
     value = newValue;
   }
@@ -74,9 +75,9 @@ function replacerHttpIncomingMessage(_key, value) {
 
 /**
  * Convert any ServerResponse or OutgoingMessage to a subset Object.
- * @param {String} _key
- * @param {*} value
- * @returns {Object}
+ * @param {string} _key key, unused
+ * @param {*} value value to possibly replace
+ * @returns {object} value or replaced value
  */
 function replacerHttpServerResponse(_key, value) {
   if (value instanceof http.OutgoingMessage || value instanceof http.ServerResponse) {