We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent adbf88a commit 5338e60Copy full SHA for 5338e60
1 file changed
lib/log-capture.js
@@ -18,7 +18,7 @@ class LogCapture {
18
19
this._levels.forEach(level => {
20
console[level] = (...args) => {
21
- this._logs.push({ level, args: clone(args) });
+ this._logs.push({ level, args: this._clone(args) });
22
};
23
});
24
}
@@ -48,6 +48,18 @@ class LogCapture {
48
reset() {
49
this._logs = [];
50
51
+
52
+ _clone(args) {
53
+ if (typeof structuredClone === 'function') {
54
+ try {
55
+ return structuredClone(args);
56
+ } catch (e) {
57
+ // Fallback to `clone` for objects that structuredClone cannot handle (e.g. functions).
58
+ }
59
60
61
+ return clone(args);
62
63
64
65
module.exports = new LogCapture();
0 commit comments