From c574b11394429cc261b6d025387ca6e01ad2fa89 Mon Sep 17 00:00:00 2001 From: Andrej Dyck <43913051+andrej-dyck@users.noreply.github.com> Date: Tue, 22 Oct 2024 08:21:26 +0200 Subject: [PATCH] add logObject console.dir alias --- debug/index.ts | 1 + debug/logObject.test.ts | 13 +++++++++++++ debug/logObject.ts | 2 ++ index.ts | 1 + 4 files changed, 17 insertions(+) create mode 100644 debug/index.ts create mode 100644 debug/logObject.test.ts create mode 100644 debug/logObject.ts diff --git a/debug/index.ts b/debug/index.ts new file mode 100644 index 0000000..366218b --- /dev/null +++ b/debug/index.ts @@ -0,0 +1 @@ +export * from './logObject.ts' diff --git a/debug/logObject.test.ts b/debug/logObject.test.ts new file mode 100644 index 0000000..eb57b66 --- /dev/null +++ b/debug/logObject.test.ts @@ -0,0 +1,13 @@ +import { test } from 'vitest' +import { logObject } from './logObject.js' + +test('logObject', () => { + logObject({ + id: 'a1234', + number: 10017, + data: [ + { id: 1, name: 'foo', price: { cents: 170023 } }, + { id: 1, name: 'bar', price: { cents: 45231 } }, + ], + }) +}) diff --git a/debug/logObject.ts b/debug/logObject.ts new file mode 100644 index 0000000..27bf647 --- /dev/null +++ b/debug/logObject.ts @@ -0,0 +1,2 @@ +export const logObject = (obj: unknown) => + console.dir(obj, { depth: Infinity, colors: true, numericSeparator: true }) diff --git a/index.ts b/index.ts index 402b242..723f7d9 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,5 @@ export * from './arrays/index.ts' +export * from './debug/logObject.ts' export * from './events/index.ts' export * from './json/index.ts' export * from './lazy/index.ts'