@steve02081504/virtual-console 0.1.8 → 0.1.9

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 (3) hide show
  1. package/browser.mjs +8 -1
  2. package/node.mjs +9 -1
  3. package/package.json +1 -1
package/browser.mjs CHANGED
@@ -282,11 +282,18 @@ export function getGlobalConsoleReflect() {
282
282
  }
283
283
  }
284
284
 
285
+ /**
286
+ * 代理对象的基础对象,避免重复的内存分配。
287
+ * @type {object}
288
+ */
289
+ const proxyBase = {
290
+ ...originalConsole,
291
+ }
285
292
  /**
286
293
  * 导出一个代理对象作为全局 console,它将所有操作委托给当前的活动控制台。
287
294
  * 这与原始 Node.js 版本的实现完全相同。
288
295
  */
289
- export const console = globalThis.console = new FullProxy(() => Object.assign({}, globalConsoleAdditionalProperties, consoleReflect()), {
296
+ export const console = globalThis.console = new FullProxy(() => Object.assign(proxyBase, globalConsoleAdditionalProperties, consoleReflect()), {
290
297
  /**
291
298
  * 设置属性时的处理逻辑。
292
299
  * @param {object} target - 目标对象。
package/node.mjs CHANGED
@@ -402,10 +402,18 @@ export function getGlobalConsoleReflect() {
402
402
  ReflectRun: consoleReflectRun
403
403
  }
404
404
  }
405
+
406
+ /**
407
+ * 代理对象的基础对象,避免重复的内存分配。
408
+ * @type {object}
409
+ */
410
+ const proxyBase = {
411
+ ...originalConsole,
412
+ }
405
413
  /**
406
414
  * 全局控制台实例。
407
415
  */
408
- export const console = globalThis.console = new FullProxy(() => Object.assign({}, globalConsoleAdditionalProperties, consoleReflect()), {
416
+ export const console = globalThis.console = new FullProxy(() => Object.assign(proxyBase, globalConsoleAdditionalProperties, consoleReflect()), {
409
417
  /**
410
418
  * 设置属性时的处理逻辑。
411
419
  * @param {object} target - 目标对象。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steve02081504/virtual-console",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "A virtual console for capturing and manipulating terminal output.",
5
5
  "main": "main.mjs",
6
6
  "type": "module",