# @art-suite/art-core-ts-inspect 中文文档

规范地址：https://npmcn.com/package/%40art-suite/art-core-ts-inspect/

版本：0\.2\.1
npm 元数据更新时间：2026-06-19T10:22:39.065Z
中文译文更新时间：2026-11-06T20:40:14.549Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40art-suite/art-core-ts-inspect
原文对照：https://npmcn.com/package/%40art-suite/art-core-ts-inspect/?lang=original
项目主页：https://github.com/art-suite/art-suite-ts#readme
源码仓库：https://github.com/art-suite/art-suite-ts

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：36.8 kB，9 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：1 个
- 首次发布：2025-07-20T17:23:18.224Z
- 最新版本发布：2026-06-19T10:22:38.946Z
- 近 30 天下载量：3216（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：14（近 12 个月 5 个）

## 中文简介

TypeScript 检查和日志工具库

## 安装

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

也可以使用：`pnpm add @art-suite/art-core-ts-inspect`、`yarn add @art-suite/art-core-ts-inspect`、`bun add @art-suite/art-core-ts-inspect`

## README

# @ art- suite/ art- core- ts- 检查

方便,强大的工具在运行时检查数据以加快发展.

## 为什么是这个模块?

运行时间数据检查对于加速开发至关重要,但标准记录方法往往需要代码重写并产生难以读取或再用的产出. 开发者需要将无缝地集成到表达式中的功能记录,对复杂的对象分级进行清洁检查,并且输出可以被复制到其他地方使用.

-   **功能记录 :** 这个 `log` 函数返回最后一个传递的值,因此可以在不中断代码流的情况下在表达式内部使用
-   **清洁物品检查:** 用于复杂对象分级的美丽可读输出, 这使得一目了然地理解运行时数据更加容易
-   **复制粘贴友好 :** 日志输出是合法 JavaScript , 可在其他地方直接使用
-   **多种输出格式 :** 针对不同用途案例的标准、未引用和格式化检查选项

## 安装和使用示例( 需要)

用 npm 安装 :

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

基本用途:

```ts
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);
```

## 职能概览

### 核心日志函数

-   `log(...args)` ——记录所有参数并返回上一个参数
-   `log.warn(...args)` – 日志带有控制台.warn并返回最后一个参数
-   `log.error(...args)` —— 带有控制台. error 的日志并返回最后一个参数
-   `log.unquoted(...args)` – 日志带有更清洁, 未引用的输出并返回最后一个参数

### 检查公用事业

-   `formattedInspect(value)` ——返回任何值的格式化字符串表示符

### 类型脚本

-   `LogFunction` ——功能日志接口类型

## 关键特性

### 功能编程样式

日志函数是为函数编程模式而设计的,允许您在不中断表达链的情况下检查数据:

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

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

### 内含表达式日志

这个 `log` 函数返回最后一个传递给它的值,使其适合内置调试 :

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

这使得您可以在不调整代码或创建临时变量的情况下添加日志.

### 清理对象检查

这个 `log.unquoted` 函数为复杂对象提供更清洁的输出:

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

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

### 复制便捷输出

标准日志输出是有效的JavaScript,可以直接复制和使用:

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

### 人类可读检查

这个 `log.unquoted` 函数去除符号噪声,使输出更能被人读取,在要精确但友好输出的地方适合生产代码:

```ts
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
```

### 颜色记录支持

所有记录功能都支持色输出,以提高可读性:

-   标准 `log()` 使用颜色来更好的视觉区分
-   `log.unquoted()` 提供有色、干净的输出
-   在终端环境中自动检测和使用颜色

## API 文档参考

关于所有被输出功能及其参数的详细信息,请参见源代码内的TypeScript打字和JSDoc评论.

## 常见问题

### @art-suite/art-core-ts-inspect 是什么？

TypeScript 检查和日志工具库

### 如何安装 @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 和提交记录判断。

