@art-suite/art-core-ts-inspect

中文文档
0.2.1发布于 2026/06/19MITTypeScriptESM + CJS近 30 天下载 3216

A TypeScript inspection and logging utility library

原始使用文档
文档目录14 节
  1. Why This Module?
  2. Example Installation and Use (Required)
  3. Functional Overview
  4. Core Logging Functions
  5. Inspection Utilities
  6. TypeScript Types
  7. Key Features
  8. Functional Programming Style
  9. Inline Expression Logging
  10. Clean Object Inspection
  11. Copy-Paste Friendly Output
  12. Human-Readable Inspection
  13. Color Logging Support
  14. API Documentation Reference

@art-suite/art-core-ts-inspect

Easy, powerful tools for inspecting data at runtime to accelerate development.

Why This Module?

Runtime data inspection is essential for accelerating development, but standard logging approaches often require code rewriting and produce output that's hard to read or reuse. Developers need functional logging that integrates seamlessly into expressions, clean inspection of complex object hierarchies, and output that can be copy-pasted for use elsewhere.

  • Functional logging: The log function returns the last value passed in, so it can be used inline inside expressions without breaking code flow
  • Clean object inspection: Beautiful, readable output for complex object hierarchies that makes understanding runtime data at a glance much easier
  • Copy-paste friendly: Logged output is legal JavaScript that can be directly used elsewhere
  • Multiple output formats: Standard, unquoted, and formatted inspection options for different use cases

Example Installation and Use (Required)

Install with npm:

npm install @art-suite/art-core-ts-inspect

Basic usage:

import { log, formattedInspect } from "@art-suite/art-core-ts-inspect";

// Functional logging - returns the last value
const result = log("Processing user:", user); // logs and returns user
const processed = processUser(log("Input:", user)); // logs inline, continues processing

// Multiple arguments
log("User ID:", userId, "Profile:", profile); // logs all, returns profile

// Different log levels
log.warn("Warning:", warningMessage); // returns warningMessage
log.error("Error occurred:", error); // returns error

// Unquoted output for cleaner object inspection
log.unquoted("User object:", user); // cleaner, more readable output

// Formatted inspection for complex objects
const formatted = formattedInspect(complexObject);
console.log(formatted);

Functional Overview

Core Logging Functions

  • log(...args) — Logs all arguments and returns the last one
  • log.warn(...args) — Logs with console.warn and returns the last argument
  • log.error(...args) — Logs with console.error and returns the last argument
  • log.unquoted(...args) — Logs with cleaner, unquoted output and returns the last argument

Inspection Utilities

  • formattedInspect(value) — Returns a formatted string representation of any value

TypeScript Types

  • LogFunction — Type for the functional logging interface

Key Features

Functional Programming Style

The logging functions are designed for functional programming patterns, allowing you to inspect data without breaking expression chains:

// Instead of:
const user = getUser();
console.log("User:", user);
const processed = processUser(user);

// You can do:
const processed = processUser(log("User:", getUser()));

Inline Expression Logging

The log function returns the last value passed to it, making it perfect for inline debugging:

const a = 123;
const b = 345;
return a + log("this is b", b);
// Output: "this is b 345"
// Returns: 468 (123 + 345)

This allows you to add logging without restructuring your code or creating temporary variables.

Clean Object Inspection

The log.unquoted function provides cleaner output for complex objects:

const user = {
  id: 123,
  name: "John Doe",
  preferences: {
    theme: "dark",
    notifications: true,
  },
};

log.unquoted("User:", user);
// Output is clean, readable, and copy-paste friendly

Copy-Paste Friendly Output

Standard logging output is valid JavaScript that can be directly copied and used:

const data = { foo: "bar", nested: { value: 42 } };
log("Data:", data);
// Output can be copied and pasted directly into code

Human-Readable Inspection

The log.unquoted function removes symbol noise to make output more human-readable, perfect for production code where you want precise but friendly output:

const user = {
  id: 123,
  name: "John Doe",
  preferences: {
    theme: "dark",
    notifications: true,
  },
};

log.unquoted("User:", user);
// Clean, human-friendly output without excessive quotes and symbols

Color Logging Support

All logging functions support color output for enhanced readability:

  • Standard log() uses colors for better visual distinction
  • log.unquoted() provides colored, clean output
  • Colors are automatically detected and used in terminal environments

API Documentation Reference

For detailed information on all exported functions and their parameters, please refer to the TypeScript typings and JSDoc comments within the source code.

版本与发布记录

@art-suite/art-core-ts-inspect 共发布 14 个版本,首次发布于 2025/07/21;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.2.1latest2026/06/194 个月前
0.2.02026/03/277 个月前
0.1.52025/12/0511 个月前
0.1.42025/12/0511 个月前
0.1.32025/12/0411 个月前
0.1.22025/10/301 年前

关于 @art-suite/art-core-ts-inspect 的常见问题

@art-suite/art-core-ts-inspect 是什么?

A TypeScript inspection and logging utility library

如何安装 @art-suite/art-core-ts-inspect?

在项目目录运行 npm install @art-suite/art-core-ts-inspect,或使用 pnpm add / yarn add / bun add。

@art-suite/art-core-ts-inspect 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@art-suite/art-core-ts-inspect 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@art-suite/art-core-ts-inspect 可以商用吗?

@art-suite/art-core-ts-inspect 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@art-suite/art-core-ts-inspect 的下载量有多少?

根据 npm 官方下载统计,@art-suite/art-core-ts-inspect 在 2026/10/07 – 2026/11/05 这 30 天内被下载 3,216 次,日均约 107 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@art-suite/art-core-ts-inspect 还在维护吗?

最新版本 0.2.1 发布于 2026/06/19(4 个月前);至今共发布 14 个版本,其中过去 12 个月发布了 5 个;首次发布于 2025/07/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。