@hackylabs/deep-redact 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -159,8 +159,8 @@ class RedactorUtils {
159
159
  const { transformed } = this.applyStringTransformations(raw, false);
160
160
  return transformed;
161
161
  }
162
- if (typeof raw !== 'object' || raw === null)
163
- return raw;
162
+ if (typeof raw !== 'object' || raw === null || this.requiresTransformers(raw))
163
+ return this.applyTransformers(raw);
164
164
  const referenceMap = new WeakMap();
165
165
  const cleanedInput = this.replaceCircularReferences(raw);
166
166
  const { output, stack } = this.initialiseTraversal(cleanedInput);
@@ -425,5 +425,28 @@ class RedactorUtils {
425
425
  };
426
426
  return processValue(raw, '');
427
427
  }
428
+ /**
429
+ * Checks if a non-traversable value requires transformers
430
+ * @param value - The value to check
431
+ * @returns Whether the value requires transformers
432
+ * @private
433
+ */
434
+ requiresTransformers(value) {
435
+ if (typeof value === 'bigint')
436
+ return true;
437
+ if (value instanceof Date)
438
+ return true;
439
+ if (value instanceof Error)
440
+ return true;
441
+ if (value instanceof Map)
442
+ return true;
443
+ if (value instanceof RegExp)
444
+ return true;
445
+ if (value instanceof Set)
446
+ return true;
447
+ if (value instanceof URL)
448
+ return true;
449
+ return false;
450
+ }
428
451
  }
429
452
  exports.default = RedactorUtils;
@@ -381,6 +381,29 @@ class RedactorUtils {
381
381
  };
382
382
  return processValue(raw, '');
383
383
  }
384
+ /**
385
+ * Checks if a non-traversable value requires transformers
386
+ * @param value - The value to check
387
+ * @returns Whether the value requires transformers
388
+ * @private
389
+ */
390
+ requiresTransformers(value) {
391
+ if (typeof value === 'bigint')
392
+ return true;
393
+ if (value instanceof Date)
394
+ return true;
395
+ if (value instanceof Error)
396
+ return true;
397
+ if (value instanceof Map)
398
+ return true;
399
+ if (value instanceof RegExp)
400
+ return true;
401
+ if (value instanceof Set)
402
+ return true;
403
+ if (value instanceof URL)
404
+ return true;
405
+ return false;
406
+ }
384
407
  /**
385
408
  * Traverses the raw value
386
409
  * @param raw - The raw value to traverse
@@ -391,8 +414,8 @@ class RedactorUtils {
391
414
  const { transformed } = this.applyStringTransformations(raw, false);
392
415
  return transformed;
393
416
  }
394
- if (typeof raw !== 'object' || raw === null)
395
- return raw;
417
+ if (typeof raw !== 'object' || raw === null || this.requiresTransformers(raw))
418
+ return this.applyTransformers(raw);
396
419
  const referenceMap = new WeakMap();
397
420
  const cleanedInput = this.replaceCircularReferences(raw);
398
421
  const { output, stack } = this.initialiseTraversal(cleanedInput);
@@ -120,6 +120,13 @@ declare class RedactorUtils {
120
120
  * @private
121
121
  */
122
122
  private replaceCircularReferences;
123
+ /**
124
+ * Checks if a non-traversable value requires transformers
125
+ * @param value - The value to check
126
+ * @returns Whether the value requires transformers
127
+ * @private
128
+ */
129
+ private requiresTransformers;
123
130
  /**
124
131
  * Traverses the raw value
125
132
  * @param raw - The raw value to traverse
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hackylabs/deep-redact",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "A fast, safe and configurable zero-dependency library for redacting strings or deeply redacting arrays and objects.",
5
5
  "private": false,
6
6
  "license": "MIT",