@dynamic-labs/logger 0.0.0-exp20240808.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.
- package/CHANGELOG.md +3746 -0
- package/LICENSE +21 -0
- package/README.md +18 -0
- package/_virtual/_tslib.cjs +36 -0
- package/_virtual/_tslib.js +32 -0
- package/package.json +31 -0
- package/src/index.cjs +214 -0
- package/src/index.d.ts +48 -0
- package/src/index.js +203 -0
- package/src/types.cjs +13 -0
- package/src/types.d.ts +13 -0
- package/src/types.js +11 -0
- package/src/utils/deepMerge.cjs +57 -0
- package/src/utils/deepMerge.d.ts +1 -0
- package/src/utils/deepMerge.js +53 -0
- package/src/utils/processArgs.cjs +21 -0
- package/src/utils/processArgs.d.ts +10 -0
- package/src/utils/processArgs.js +17 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const deepMerge = (obj1, obj2) => {
|
|
7
|
+
if (typeof obj1 !== 'object' || typeof obj2 !== 'object') {
|
|
8
|
+
// If either obj1 or obj2 is not an object, return obj1
|
|
9
|
+
return obj2;
|
|
10
|
+
}
|
|
11
|
+
// Create a new object to store the merged result
|
|
12
|
+
const result = Object.assign({}, obj1);
|
|
13
|
+
for (const key in obj2) {
|
|
14
|
+
if (Object.prototype.hasOwnProperty.call(obj2, key)) {
|
|
15
|
+
if (typeof obj2[key] === 'object' &&
|
|
16
|
+
Object.prototype.hasOwnProperty.call(obj1, key) &&
|
|
17
|
+
typeof obj1[key] === 'object') {
|
|
18
|
+
// If both obj1 and obj2 have objects with the same key, recursively merge them
|
|
19
|
+
result[key] = deepMerge(obj1[key], obj2[key]);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// Otherwise, simply assign the value from obj2 to the result
|
|
23
|
+
result[key] = obj2[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
// Example usage:
|
|
30
|
+
//
|
|
31
|
+
// const obj1 = {
|
|
32
|
+
// a: 1,
|
|
33
|
+
// b: {
|
|
34
|
+
// c: 2,
|
|
35
|
+
// d: 3,
|
|
36
|
+
// },
|
|
37
|
+
// };
|
|
38
|
+
//
|
|
39
|
+
// const obj2 = {
|
|
40
|
+
// a: 4,
|
|
41
|
+
// b: {
|
|
42
|
+
// c: 5,
|
|
43
|
+
// },
|
|
44
|
+
// e: 6,
|
|
45
|
+
// };
|
|
46
|
+
//
|
|
47
|
+
// const result = {
|
|
48
|
+
// a: 4,
|
|
49
|
+
// b: {
|
|
50
|
+
// c: 5,
|
|
51
|
+
// d: 3,
|
|
52
|
+
// },
|
|
53
|
+
// e: 6,
|
|
54
|
+
// };
|
|
55
|
+
//
|
|
56
|
+
|
|
57
|
+
exports.deepMerge = deepMerge;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const deepMerge: <T>(obj1: any, obj2: any) => T;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const deepMerge = (obj1, obj2) => {
|
|
3
|
+
if (typeof obj1 !== 'object' || typeof obj2 !== 'object') {
|
|
4
|
+
// If either obj1 or obj2 is not an object, return obj1
|
|
5
|
+
return obj2;
|
|
6
|
+
}
|
|
7
|
+
// Create a new object to store the merged result
|
|
8
|
+
const result = Object.assign({}, obj1);
|
|
9
|
+
for (const key in obj2) {
|
|
10
|
+
if (Object.prototype.hasOwnProperty.call(obj2, key)) {
|
|
11
|
+
if (typeof obj2[key] === 'object' &&
|
|
12
|
+
Object.prototype.hasOwnProperty.call(obj1, key) &&
|
|
13
|
+
typeof obj1[key] === 'object') {
|
|
14
|
+
// If both obj1 and obj2 have objects with the same key, recursively merge them
|
|
15
|
+
result[key] = deepMerge(obj1[key], obj2[key]);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
// Otherwise, simply assign the value from obj2 to the result
|
|
19
|
+
result[key] = obj2[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
// Example usage:
|
|
26
|
+
//
|
|
27
|
+
// const obj1 = {
|
|
28
|
+
// a: 1,
|
|
29
|
+
// b: {
|
|
30
|
+
// c: 2,
|
|
31
|
+
// d: 3,
|
|
32
|
+
// },
|
|
33
|
+
// };
|
|
34
|
+
//
|
|
35
|
+
// const obj2 = {
|
|
36
|
+
// a: 4,
|
|
37
|
+
// b: {
|
|
38
|
+
// c: 5,
|
|
39
|
+
// },
|
|
40
|
+
// e: 6,
|
|
41
|
+
// };
|
|
42
|
+
//
|
|
43
|
+
// const result = {
|
|
44
|
+
// a: 4,
|
|
45
|
+
// b: {
|
|
46
|
+
// c: 5,
|
|
47
|
+
// d: 3,
|
|
48
|
+
// },
|
|
49
|
+
// e: 6,
|
|
50
|
+
// };
|
|
51
|
+
//
|
|
52
|
+
|
|
53
|
+
export { deepMerge };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Split args into object and non-object args
|
|
8
|
+
* @param message
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
const processArgs = (message) => {
|
|
12
|
+
// Apply object args to body
|
|
13
|
+
const objectArgs = message.args.filter((arg) => typeof arg === 'object');
|
|
14
|
+
// Capture remaining non-object args
|
|
15
|
+
const remainingArgs = message.args
|
|
16
|
+
.filter((arg) => typeof arg !== 'object' || arg instanceof Error)
|
|
17
|
+
.map((arg) => arg.toString());
|
|
18
|
+
return { objectArgs, remainingArgs };
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.processArgs = processArgs;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* Split args into object and non-object args
|
|
4
|
+
* @param message
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
const processArgs = (message) => {
|
|
8
|
+
// Apply object args to body
|
|
9
|
+
const objectArgs = message.args.filter((arg) => typeof arg === 'object');
|
|
10
|
+
// Capture remaining non-object args
|
|
11
|
+
const remainingArgs = message.args
|
|
12
|
+
.filter((arg) => typeof arg !== 'object' || arg instanceof Error)
|
|
13
|
+
.map((arg) => arg.toString());
|
|
14
|
+
return { objectArgs, remainingArgs };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { processArgs };
|