@hackylabs/deep-redact 3.0.5 → 4.0.0

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.
Files changed (49) hide show
  1. package/README.md +221 -106
  2. package/dist/adapters/console/index.cjs +74 -0
  3. package/dist/adapters/console/index.d.cts +22 -0
  4. package/dist/adapters/console/index.d.ts +22 -0
  5. package/dist/adapters/console/index.js +73 -0
  6. package/dist/index.cjs +2743 -0
  7. package/dist/index.d.cts +7 -0
  8. package/dist/index.d.ts +7 -0
  9. package/dist/index.js +2741 -55
  10. package/dist/node-console-sink-BnRUkAAr.cjs +19 -0
  11. package/dist/node-console-sink-DaQleNZ8.js +14 -0
  12. package/dist/public-Da0aARA9.d.cts +127 -0
  13. package/dist/public-Dw4ycNzO.d.ts +127 -0
  14. package/package.json +66 -106
  15. package/dist/index.mjs +0 -40
  16. package/dist/types/index.d.ts +0 -29
  17. package/dist/types/types.d.ts +0 -224
  18. package/dist/types/utils/TransformerRegistry.d.ts +0 -52
  19. package/dist/types/utils/index.d.ts +0 -131
  20. package/dist/types/utils/standardTransformers/bigint.d.ts +0 -2
  21. package/dist/types/utils/standardTransformers/date.d.ts +0 -2
  22. package/dist/types/utils/standardTransformers/error.d.ts +0 -2
  23. package/dist/types/utils/standardTransformers/index.d.ts +0 -9
  24. package/dist/types/utils/standardTransformers/map.d.ts +0 -2
  25. package/dist/types/utils/standardTransformers/regex.d.ts +0 -2
  26. package/dist/types/utils/standardTransformers/set.d.ts +0 -2
  27. package/dist/types/utils/standardTransformers/url.d.ts +0 -2
  28. package/dist/types.js +0 -2
  29. package/dist/types.mjs +0 -1
  30. package/dist/utils/TransformerRegistry.js +0 -100
  31. package/dist/utils/TransformerRegistry.mjs +0 -94
  32. package/dist/utils/index.js +0 -471
  33. package/dist/utils/index.mjs +0 -467
  34. package/dist/utils/standardTransformers/bigint.js +0 -10
  35. package/dist/utils/standardTransformers/bigint.mjs +0 -6
  36. package/dist/utils/standardTransformers/date.js +0 -9
  37. package/dist/utils/standardTransformers/date.mjs +0 -5
  38. package/dist/utils/standardTransformers/error.js +0 -16
  39. package/dist/utils/standardTransformers/error.mjs +0 -12
  40. package/dist/utils/standardTransformers/index.js +0 -38
  41. package/dist/utils/standardTransformers/index.mjs +0 -35
  42. package/dist/utils/standardTransformers/map.js +0 -9
  43. package/dist/utils/standardTransformers/map.mjs +0 -5
  44. package/dist/utils/standardTransformers/regex.js +0 -15
  45. package/dist/utils/standardTransformers/regex.mjs +0 -11
  46. package/dist/utils/standardTransformers/set.js +0 -9
  47. package/dist/utils/standardTransformers/set.mjs +0 -5
  48. package/dist/utils/standardTransformers/url.js +0 -9
  49. package/dist/utils/standardTransformers/url.mjs +0 -5
@@ -1,467 +0,0 @@
1
- import { standardTransformers } from './standardTransformers/index.mjs';
2
- import { TransformerRegistry } from './TransformerRegistry.mjs';
3
- const defaultConfig = {
4
- stringTests: [],
5
- blacklistedKeys: [],
6
- fuzzyKeyMatch: false,
7
- caseSensitiveKeyMatch: true,
8
- retainStructure: false,
9
- remove: false,
10
- replaceStringByLength: false,
11
- replacement: '[REDACTED]',
12
- types: ['string'],
13
- transformers: standardTransformers,
14
- };
15
- class RedactorUtils {
16
- /**
17
- * The configuration for the redaction.
18
- * @private
19
- */
20
- config = defaultConfig;
21
- /**
22
- * The transformed blacklist keys of flat regex patterns and complex config objects
23
- * @private
24
- */
25
- blacklistedKeysTransformed = [];
26
- /**
27
- * The transformer registry for efficient transformer lookup
28
- * @private
29
- */
30
- transformerRegistry = new TransformerRegistry();
31
- constructor(customConfig) {
32
- this.config = {
33
- ...defaultConfig,
34
- ...customConfig,
35
- };
36
- this.blacklistedKeysTransformed = (customConfig.blacklistedKeys ?? []).map((key) => this.createTransformedBlacklistedKey(key, customConfig));
37
- this.setupTransformerRegistry(this.config.transformers);
38
- }
39
- /**
40
- * Sets up the transformer registry based on the configuration
41
- * @param transformers - The transformer configuration
42
- * @private
43
- */
44
- setupTransformerRegistry(transformers) {
45
- if (Array.isArray(transformers)) {
46
- transformers.forEach(transformer => { this.transformerRegistry.addFallbackTransformer(transformer); });
47
- }
48
- else {
49
- const organised = transformers;
50
- if (organised.byType) {
51
- Object.entries(organised.byType).forEach(([type, typeTransformers]) => {
52
- if (typeTransformers) {
53
- typeTransformers.forEach(transformer => {
54
- this.transformerRegistry.addTypeTransformer(type, transformer);
55
- });
56
- }
57
- });
58
- }
59
- if (organised.byConstructor) {
60
- Object.entries(organised.byConstructor).forEach(([constructorName, constructorTransformers]) => {
61
- if (constructorTransformers) {
62
- const constructorMap = {
63
- Date,
64
- Error,
65
- Map,
66
- Set,
67
- RegExp,
68
- URL,
69
- };
70
- const constructor = constructorMap[constructorName];
71
- if (constructor) {
72
- constructorTransformers.forEach(transformer => {
73
- this.transformerRegistry.addConstructorTransformer(constructor, transformer);
74
- });
75
- }
76
- }
77
- });
78
- }
79
- }
80
- }
81
- createTransformedBlacklistedKey = (key, customConfig) => {
82
- if (key instanceof RegExp) {
83
- return {
84
- key,
85
- fuzzyKeyMatch: customConfig.fuzzyKeyMatch ?? defaultConfig.fuzzyKeyMatch,
86
- caseSensitiveKeyMatch: customConfig.caseSensitiveKeyMatch ?? defaultConfig.caseSensitiveKeyMatch,
87
- retainStructure: customConfig.retainStructure ?? defaultConfig.retainStructure,
88
- replacement: customConfig.replacement ?? defaultConfig.replacement,
89
- replaceStringByLength: customConfig.replaceStringByLength ?? defaultConfig.replaceStringByLength,
90
- remove: customConfig.remove ?? defaultConfig.remove,
91
- };
92
- }
93
- if (typeof key === 'string') {
94
- return {
95
- key,
96
- fuzzyKeyMatch: customConfig.fuzzyKeyMatch ?? defaultConfig.fuzzyKeyMatch,
97
- caseSensitiveKeyMatch: customConfig.caseSensitiveKeyMatch ?? defaultConfig.caseSensitiveKeyMatch,
98
- retainStructure: customConfig.retainStructure ?? defaultConfig.retainStructure,
99
- replacement: customConfig.replacement ?? defaultConfig.replacement,
100
- replaceStringByLength: customConfig.replaceStringByLength ?? defaultConfig.replaceStringByLength,
101
- remove: customConfig.remove ?? defaultConfig.remove,
102
- };
103
- }
104
- return {
105
- fuzzyKeyMatch: key.fuzzyKeyMatch ?? customConfig.fuzzyKeyMatch ?? defaultConfig.fuzzyKeyMatch,
106
- caseSensitiveKeyMatch: key.caseSensitiveKeyMatch ?? customConfig.caseSensitiveKeyMatch ?? defaultConfig.caseSensitiveKeyMatch,
107
- retainStructure: key.retainStructure ?? customConfig.retainStructure ?? defaultConfig.retainStructure,
108
- replacement: key.replacement ?? customConfig.replacement ?? defaultConfig.replacement,
109
- replaceStringByLength: key.replaceStringByLength ?? customConfig.replaceStringByLength ?? defaultConfig.replaceStringByLength,
110
- remove: key.remove ?? customConfig.remove ?? defaultConfig.remove,
111
- key: key.key,
112
- };
113
- };
114
- /**
115
- * Applies transformers to a value
116
- * @param value - The value to transform
117
- * @param key - The key to check
118
- * @returns The transformed value
119
- * @private
120
- */
121
- applyTransformers = (value, key, referenceMap) => {
122
- return this.transformerRegistry.applyTransformers(value, key, referenceMap);
123
- };
124
- /**
125
- * Checks if a key should be redacted
126
- * @param key - The key to check
127
- * @returns Whether the key should be redacted
128
- * @private
129
- */
130
- shouldRedactKey = (key) => {
131
- return this.blacklistedKeysTransformed.some(config => {
132
- const pattern = config.key;
133
- if (pattern instanceof RegExp)
134
- return pattern.test(key);
135
- if (!config.fuzzyKeyMatch && !config.caseSensitiveKeyMatch)
136
- return key.toLowerCase().trim().replace(/[_-]/g, '') === pattern.toLowerCase().trim().replace(/[_-]/g, '');
137
- if (config.fuzzyKeyMatch && !config.caseSensitiveKeyMatch)
138
- return key.toLowerCase().trim().replace(/[_-]/g, '').includes(pattern.toLowerCase().trim().replace(/[_-]/g, ''));
139
- if (config.fuzzyKeyMatch && config.caseSensitiveKeyMatch)
140
- return key.includes(pattern);
141
- if (!config.fuzzyKeyMatch && config.caseSensitiveKeyMatch)
142
- return key === pattern;
143
- });
144
- };
145
- /**
146
- * Checks if a value should be redacted
147
- * @param value - The value to check
148
- * @param key - The key to check
149
- * @returns Whether the value should be redacted
150
- * @private
151
- */
152
- shouldRedactValue = (value, valueKey) => {
153
- if (!this.config.types.includes(typeof value))
154
- return false;
155
- return this.shouldRedactKey(valueKey);
156
- };
157
- /**
158
- * Redacts a value based on the key-specific config
159
- * @param value - The value to redact
160
- * @param key - The key to check
161
- * @param redactingParent - Whether the parent is being redacted
162
- * @returns The redacted value
163
- * @private
164
- */
165
- redactValue = (value, redactingParent, keyConfig) => {
166
- if (!this.config.types.includes(typeof value))
167
- return { transformed: value, redactingParent };
168
- const remove = keyConfig?.remove ?? this.config.remove;
169
- const replacement = keyConfig?.replacement ?? this.config.replacement;
170
- const replaceStringByLength = keyConfig?.replaceStringByLength ?? this.config.replaceStringByLength;
171
- const retainStructure = keyConfig?.retainStructure ?? this.config.retainStructure;
172
- if (retainStructure && typeof value === 'object' && value !== null)
173
- return { transformed: value, redactingParent: true };
174
- if (remove)
175
- return { transformed: undefined, redactingParent };
176
- if (typeof replacement === 'function')
177
- return { transformed: replacement(value), redactingParent };
178
- return {
179
- redactingParent,
180
- transformed: (typeof value === 'string' && replaceStringByLength)
181
- ? replacement.toString().repeat(value.length)
182
- : replacement,
183
- };
184
- };
185
- /**
186
- * Applies string transformations
187
- * @param value - The value to transform
188
- * @param key - The key to check
189
- * @returns The transformed value
190
- * @private
191
- */
192
- applyStringTransformations(value, amRedactingParent, keyConfig) {
193
- if ((this.config.stringTests ?? []).length === 0)
194
- return { transformed: value, redactingParent: amRedactingParent };
195
- for (const test of this.config.stringTests) {
196
- if (test instanceof RegExp) {
197
- if (test.test(value)) {
198
- const { transformed, redactingParent } = this.redactValue(value, amRedactingParent, keyConfig);
199
- return { transformed: transformed, redactingParent };
200
- }
201
- }
202
- else {
203
- if (test.pattern.test(value)) {
204
- const transformed = test.replacer(value, test.pattern);
205
- return { transformed, redactingParent: amRedactingParent };
206
- }
207
- }
208
- }
209
- return { transformed: value, redactingParent: amRedactingParent };
210
- }
211
- /**
212
- * Handles primitive values
213
- * @param value - The value to handle
214
- * @param key - The key to check
215
- * @param redactingParent - Whether the parent is being redacted
216
- * @param keyConfig - The key config
217
- * @returns The transformed value
218
- * @private
219
- */
220
- handlePrimitiveValue(value, valueKey, redactingParent, keyConfig) {
221
- let transformed = value;
222
- if (redactingParent) {
223
- if (valueKey === '_transformer' || !this.config.types.includes(typeof value)) {
224
- return { transformed: value, redactingParent };
225
- }
226
- const { transformed: transformedValue } = this.redactValue(value, redactingParent, keyConfig);
227
- return { transformed: transformedValue, redactingParent };
228
- }
229
- if (keyConfig || this.shouldRedactValue(value, valueKey)) {
230
- return this.redactValue(value, redactingParent, keyConfig);
231
- }
232
- if (typeof value === 'string') {
233
- return this.applyStringTransformations(value, redactingParent, keyConfig);
234
- }
235
- return { transformed, redactingParent };
236
- }
237
- /**
238
- * Handles object values
239
- * @param value - The value to handle
240
- * @param key - The key to check
241
- * @param path - The path to the value
242
- * @param redactingParent - Whether the parent is being redacted
243
- * @param referenceMap - The reference map
244
- * @returns The transformed value and stack
245
- * @private
246
- */
247
- handleObjectValue(value, key, path, amRedactingParent, referenceMap, keyConfig) {
248
- const fullPath = path.join('.');
249
- const shouldRedact = amRedactingParent || Boolean(keyConfig) || this.shouldRedactValue(value, key);
250
- referenceMap.set(value, fullPath);
251
- if (shouldRedact && !(keyConfig?.retainStructure ?? this.config.retainStructure)) {
252
- const { transformed, redactingParent } = this.redactValue(value, amRedactingParent, keyConfig);
253
- return { transformed, redactingParent, stack: [] };
254
- }
255
- return this.handleRetainStructure(value, path, shouldRedact);
256
- }
257
- /**
258
- * Handles object values
259
- * @param value - The value to handle
260
- * @param path - The path to the value
261
- * @param redactingParent - Whether the parent is being redacted
262
- * @returns The transformed value and stack
263
- * @private
264
- */
265
- handleRetainStructure(value, path, redactingParent) {
266
- const newValue = Array.isArray(value) ? [] : {};
267
- const stack = [];
268
- if (Array.isArray(value)) {
269
- for (let i = value.length - 1; i >= 0; i--) {
270
- stack.push({
271
- parent: newValue,
272
- key: i.toString(),
273
- value: value[i],
274
- path: [...path, i],
275
- redactingParent,
276
- keyConfig: this.findMatchingKeyConfig(i.toString()),
277
- });
278
- }
279
- }
280
- else {
281
- for (const [propKey, propValue] of Object.entries(value).reverse()) {
282
- stack.push({
283
- parent: newValue,
284
- key: propKey,
285
- value: propValue,
286
- path: [...path, propKey],
287
- redactingParent,
288
- keyConfig: this.findMatchingKeyConfig(propKey),
289
- });
290
- }
291
- }
292
- return { transformed: newValue, redactingParent, stack };
293
- }
294
- /**
295
- * Finds the matching key config
296
- * @param key - The key to find
297
- * @returns The matching key config
298
- * @private
299
- */
300
- findMatchingKeyConfig(key) {
301
- return this.blacklistedKeysTransformed.find(config => {
302
- const pattern = config.key;
303
- if (pattern instanceof RegExp)
304
- return pattern.test(key);
305
- const normalisedKey = key.toLowerCase().trim().replace(/[_-]/g, '');
306
- const normalisedPattern = pattern.toLowerCase().trim().replace(/[_-]/g, '');
307
- if (config.fuzzyKeyMatch) {
308
- const compareKey = config.caseSensitiveKeyMatch ? key : normalisedKey;
309
- const comparePattern = config.caseSensitiveKeyMatch ? pattern : normalisedPattern;
310
- return compareKey.includes(comparePattern);
311
- }
312
- return config.caseSensitiveKeyMatch ? key === pattern : normalisedKey === normalisedPattern;
313
- });
314
- }
315
- /**
316
- * Initialises the traversal
317
- * @param raw - The raw value to traverse
318
- * @returns The output and stack
319
- * @private
320
- */
321
- initialiseTraversal(raw) {
322
- const output = Array.isArray(raw) ? [] : {};
323
- const stack = [];
324
- if (typeof raw === 'object' && raw !== null) {
325
- if (Array.isArray(raw)) {
326
- for (let i = raw.length - 1; i >= 0; i--) {
327
- stack.push({
328
- parent: output,
329
- key: i.toString(),
330
- value: raw[i],
331
- path: [i],
332
- redactingParent: false,
333
- keyConfig: this.findMatchingKeyConfig(i.toString()),
334
- });
335
- }
336
- }
337
- else {
338
- for (const [propKey, propValue] of Object.entries(raw).reverse()) {
339
- stack.push({
340
- parent: output,
341
- key: propKey,
342
- value: propValue,
343
- path: [propKey],
344
- redactingParent: false,
345
- keyConfig: this.findMatchingKeyConfig(propKey),
346
- });
347
- }
348
- }
349
- }
350
- return { output, stack };
351
- }
352
- /**
353
- * Pre-processes the input to replace circular references with transformer objects
354
- * @param raw - The raw value to process
355
- * @returns The processed value with circular references replaced
356
- * @private
357
- */
358
- replaceCircularReferences(raw) {
359
- if (typeof raw !== 'object' || raw === null)
360
- return raw;
361
- const visiting = new WeakSet();
362
- const pathMap = new WeakMap();
363
- const processValue = (value, path) => {
364
- if (typeof value !== 'object' || value === null)
365
- return value;
366
- if (visiting.has(value)) {
367
- const originalPath = pathMap.get(value) || '';
368
- return {
369
- _transformer: 'circular',
370
- value: originalPath,
371
- path: path
372
- };
373
- }
374
- visiting.add(value);
375
- pathMap.set(value, path);
376
- let result;
377
- if (Array.isArray(value)) {
378
- let hasCircular = false;
379
- const newArray = value.map((item, index) => {
380
- const itemPath = path ? `${path}.${index}` : index.toString();
381
- const processed = processValue(item, itemPath);
382
- if (processed !== item)
383
- hasCircular = true;
384
- return processed;
385
- });
386
- result = hasCircular ? newArray : value;
387
- }
388
- else {
389
- let hasCircular = false;
390
- const newObj = {};
391
- for (const [key, val] of Object.entries(value)) {
392
- const valuePath = path ? `${path}.${key}` : key;
393
- const processed = processValue(val, valuePath);
394
- newObj[key] = processed;
395
- if (processed !== val)
396
- hasCircular = true;
397
- }
398
- result = hasCircular ? newObj : value;
399
- }
400
- visiting.delete(value);
401
- return result;
402
- };
403
- return processValue(raw, '');
404
- }
405
- /**
406
- * Checks if a non-traversable value requires transformers
407
- * @param value - The value to check
408
- * @returns Whether the value requires transformers
409
- * @private
410
- */
411
- requiresTransformers(value) {
412
- if (typeof value === 'bigint')
413
- return true;
414
- if (value instanceof Date)
415
- return true;
416
- if (value instanceof Error)
417
- return true;
418
- if (value instanceof Map)
419
- return true;
420
- if (value instanceof RegExp)
421
- return true;
422
- if (value instanceof Set)
423
- return true;
424
- if (value instanceof URL)
425
- return true;
426
- return false;
427
- }
428
- /**
429
- * Traverses the raw value
430
- * @param raw - The raw value to traverse
431
- * @returns The transformed value
432
- */
433
- traverse = (raw) => {
434
- if (typeof raw === 'string') {
435
- const { transformed } = this.applyStringTransformations(raw, false);
436
- return transformed;
437
- }
438
- if (typeof raw !== 'object' || raw === null || this.requiresTransformers(raw))
439
- return this.applyTransformers(raw);
440
- const referenceMap = new WeakMap();
441
- const cleanedInput = this.replaceCircularReferences(raw);
442
- const { output, stack } = this.initialiseTraversal(cleanedInput);
443
- if (typeof cleanedInput === 'object' && cleanedInput !== null)
444
- referenceMap.set(cleanedInput, '');
445
- while (stack.length > 0) {
446
- const { parent, key, value, path, redactingParent: amRedactingParent, keyConfig } = stack.pop();
447
- let transformed = this.applyTransformers(value, key, referenceMap);
448
- let redactingParent = amRedactingParent;
449
- if (typeof transformed !== 'object' || transformed === null) {
450
- const primitiveResult = this.handlePrimitiveValue(transformed, key, amRedactingParent, keyConfig);
451
- redactingParent = primitiveResult.redactingParent;
452
- transformed = primitiveResult.transformed;
453
- if (typeof transformed === 'undefined')
454
- continue;
455
- }
456
- else {
457
- const objectResult = this.handleObjectValue(transformed, key, path, redactingParent, referenceMap, keyConfig);
458
- transformed = objectResult.transformed;
459
- stack.push(...objectResult.stack);
460
- }
461
- if (parent !== null && key !== null)
462
- parent[key] = transformed;
463
- }
464
- return output;
465
- };
466
- }
467
- export default RedactorUtils;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._bigint = void 0;
4
- const _bigint = (value) => {
5
- if (typeof value !== 'bigint')
6
- return value;
7
- const radix = 10;
8
- return { value: { radix, number: value.toString(radix) }, _transformer: 'bigint' };
9
- };
10
- exports._bigint = _bigint;
@@ -1,6 +0,0 @@
1
- export const _bigint = (value) => {
2
- if (typeof value !== 'bigint')
3
- return value;
4
- const radix = 10;
5
- return { value: { radix, number: value.toString(radix) }, _transformer: 'bigint' };
6
- };
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._date = void 0;
4
- const _date = (value) => {
5
- if (value instanceof Date)
6
- return { datetime: value.toISOString(), _transformer: 'date' };
7
- return value;
8
- };
9
- exports._date = _date;
@@ -1,5 +0,0 @@
1
- export const _date = (value) => {
2
- if (value instanceof Date)
3
- return { datetime: value.toISOString(), _transformer: 'date' };
4
- return value;
5
- };
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._error = void 0;
4
- const _error = (value) => {
5
- if (!(value instanceof Error))
6
- return value;
7
- return {
8
- _transformer: 'error',
9
- value: {
10
- type: value.constructor.name,
11
- message: value.message,
12
- stack: value.stack,
13
- },
14
- };
15
- };
16
- exports._error = _error;
@@ -1,12 +0,0 @@
1
- export const _error = (value) => {
2
- if (!(value instanceof Error))
3
- return value;
4
- return {
5
- _transformer: 'error',
6
- value: {
7
- type: value.constructor.name,
8
- message: value.message,
9
- stack: value.stack,
10
- },
11
- };
12
- };
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.organisedStandardTransformers = exports.standardTransformers = void 0;
4
- const bigint_js_1 = require("./bigint.js");
5
- const date_js_1 = require("./date.js");
6
- const error_js_1 = require("./error.js");
7
- const map_js_1 = require("./map.js");
8
- const regex_js_1 = require("./regex.js");
9
- const set_js_1 = require("./set.js");
10
- const url_js_1 = require("./url.js");
11
- /**
12
- * Standard transformers in array for legacy support
13
- */
14
- exports.standardTransformers = [
15
- bigint_js_1._bigint,
16
- date_js_1._date,
17
- error_js_1._error,
18
- map_js_1._map,
19
- regex_js_1._regex,
20
- set_js_1._set,
21
- url_js_1._url,
22
- ];
23
- /**
24
- * Standard transformers organised by type and constructor for performance reasons
25
- */
26
- exports.organisedStandardTransformers = {
27
- byType: {
28
- bigint: [bigint_js_1._bigint],
29
- },
30
- byConstructor: {
31
- URL: [url_js_1._url],
32
- Date: [date_js_1._date],
33
- Error: [error_js_1._error],
34
- Map: [map_js_1._map],
35
- Set: [set_js_1._set],
36
- RegExp: [regex_js_1._regex],
37
- },
38
- };
@@ -1,35 +0,0 @@
1
- import { _bigint } from "./bigint.mjs";
2
- import { _date } from "./date.mjs";
3
- import { _error } from "./error.mjs";
4
- import { _map } from "./map.mjs";
5
- import { _regex } from "./regex.mjs";
6
- import { _set } from "./set.mjs";
7
- import { _url } from "./url.mjs";
8
- /**
9
- * Standard transformers in array for legacy support
10
- */
11
- export const standardTransformers = [
12
- _bigint,
13
- _date,
14
- _error,
15
- _map,
16
- _regex,
17
- _set,
18
- _url,
19
- ];
20
- /**
21
- * Standard transformers organised by type and constructor for performance reasons
22
- */
23
- export const organisedStandardTransformers = {
24
- byType: {
25
- bigint: [_bigint],
26
- },
27
- byConstructor: {
28
- URL: [_url],
29
- Date: [_date],
30
- Error: [_error],
31
- Map: [_map],
32
- Set: [_set],
33
- RegExp: [_regex],
34
- },
35
- };
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._map = void 0;
4
- const _map = (value) => {
5
- if (value instanceof Map)
6
- return { value: Object.fromEntries(value.entries()), _transformer: 'map' };
7
- return value;
8
- };
9
- exports._map = _map;
@@ -1,5 +0,0 @@
1
- export const _map = (value) => {
2
- if (value instanceof Map)
3
- return { value: Object.fromEntries(value.entries()), _transformer: 'map' };
4
- return value;
5
- };
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._regex = void 0;
4
- const _regex = (value) => {
5
- if (!(value instanceof RegExp))
6
- return value;
7
- return {
8
- _transformer: 'regex',
9
- value: {
10
- source: value.source,
11
- flags: value.flags,
12
- },
13
- };
14
- };
15
- exports._regex = _regex;
@@ -1,11 +0,0 @@
1
- export const _regex = (value) => {
2
- if (!(value instanceof RegExp))
3
- return value;
4
- return {
5
- _transformer: 'regex',
6
- value: {
7
- source: value.source,
8
- flags: value.flags,
9
- },
10
- };
11
- };
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._set = void 0;
4
- const _set = (value) => {
5
- if (value instanceof Set)
6
- return { value: Array.from(value), _transformer: 'set' };
7
- return value;
8
- };
9
- exports._set = _set;
@@ -1,5 +0,0 @@
1
- export const _set = (value) => {
2
- if (value instanceof Set)
3
- return { value: Array.from(value), _transformer: 'set' };
4
- return value;
5
- };
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._url = void 0;
4
- const _url = (value) => {
5
- if (value instanceof URL)
6
- return { value: value.toString(), _transformer: 'url' };
7
- return value;
8
- };
9
- exports._url = _url;