# @clinic/doctor 中文文档

规范地址：https://npmcn.com/package/%40clinic/doctor/

版本：11\.0\.0
npm 元数据更新时间：2023-06-27T20:59:30.220Z
中文译文更新时间：2026-11-10T01:45:49.765Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40clinic/doctor
原文对照：https://npmcn.com/package/%40clinic/doctor/?lang=original
项目主页：https://github.com/clinicjs/node-clinic-doctor#readme
源码仓库：https://github.com/clinicjs/node-clinic-doctor

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

- 包体积（解压后）：309 kB，92 个文件
- TypeScript 类型：未声明
- 运行依赖：29 个
- 首次发布：2021-11-14T13:42:18.123Z
- 最新版本发布：2023-06-27T20:59:29.980Z
- 近 30 天下载量：181195（2026-10-10 至 2026-11-08，npm 官方下载统计）
- 已发布版本数：7（近 12 个月 0 个）

## 中文简介

Clinic.js 的可编程界面

## 安装

```sh
npm install @clinic/doctor
```

也可以使用：`pnpm add @clinic/doctor`、`yarn add @clinic/doctor`、`bun add @clinic/doctor`

## README

# 医生

[![Greenkeeper badge](https://badges.greenkeeper.io/clinic/node-clinic-doctor.svg)](https://greenkeeper.io/) [![npm version](https://img.shields.io/npm/v/@clinic/doctor.svg?style=flat-square)](https://www.npmjs.org/@clinic/doctor) [![Stability Stable](https://img.shields.io/badge/stability-stable-green.svg?style=flat-square)](https://nodejs.org/api/documentation.html#documentation_stability_index) [![Github Actions build status](https://github.com/clinicjs/node-clinic-doctor/workflows/CI/badge.svg)](https://github.com/clinicjs/node-clinic-doctor/actions) [![Downloads](http://img.shields.io/npm/dm/@clinic/doctor.svg?style=flat-square)](https://www.npmjs.org/@clinic/doctor) [![Code style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)

可编程接口到 [诊所.js](https://github.com/clinicjs/node-clinic) 医生 更多关于诊所的知识 [https://clinicjs.org/ (中文(简体) )](https://clinicjs.org/)

![Screenshot](https://npmcn.com/package/%40clinic/doctor/screenshot.png)

## 问题

打开一个问题,请使用 [主要仓库](https://github.com/clinicjs/node-clinic) 与 `doctor` 标签.

## 安装

```console
npm i -S @clinic/doctor
```

## 支持的节点版本

-   16及以上节点j

## 示例

```js
const ClinicDoctor = require('@clinic/doctor')
const doctor = new ClinicDoctor()

doctor.collect(['node', './path-to-script.js'], function (err, filepath) {
  if (err) throw err

  doctor.visualize(filepath, filepath + '.html', function (err) {
    if (err) throw err
  });
})
```

您可以在 [节点-诊所-医生-实例](https://github.com/clinicjs/node-clinic-doctor-examples)

## 文档

```js
const ClinicDoctor = require('@clinic/doctor')
const doctor = new ClinicDoctor()
```

### 新临床医生(\[设置\])

-   设置 [`<Object>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
    -   样本 [`<Number>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) 每个样本之间的时间以毫秒计. **默认**: 10个
    -   检测端口 [`<boolean>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) **默认**错误
    -   离线 [`<String>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) 存储所收集数据的文件夹 . **默认**:"'
    -   调试 [`<boolean>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) 如果设置为真, 生成的 html 将不会被修改 . **默认**错误
    -   收集延迟 [`<Number>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) **默认**编号: 0

#### `doctor.collect(args, callback)`

使用 :

```js
const { spawn } = require('child_process')
spawn(args[0], ['-r', 'sampler.js'].concat(args.slice(1)))
```

注入的采样器将在当前的工作目录中生成一个文件,其中 进程 PID 在其文件名中。 相对于当前工作的文件路径 目录将是回调中值.

stdout, stderr,和stdin会被转发到调用过程. 也一样 `SIGINT` 活动.

#### `doctor.visualize(dataFilename, outputFilename, callback)`

将消耗由 `dataFilename`,此数据文件将是 采样者使用 `doctor.collect`。 。 。 .

`doctor.visualize` 然后输出一个独立的 HTML 文件到 `outputFilename`。 。 。 . 完成后 `callback` 将被调用,除了一个 可能的错误.

## 许可证

[麻省理工学院](https://npmcn.com/package/%40clinic/doctor/LICENSE)

## 常见问题

### @clinic/doctor 是什么？

Clinic\.js 的可编程界面

### 如何安装 @clinic/doctor？

在项目目录运行 npm install @clinic/doctor，或使用 pnpm add / yarn add / bun add。

### @clinic/doctor 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/clinic\_\_doctor 是否存在。

### @clinic/doctor 可以商用吗？

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

### @clinic/doctor 的下载量有多少？

根据 npm 官方下载统计，@clinic/doctor 在 2026/10/10 – 2026/11/08 这 30 天内被下载 181,195 次，日均约 6,040 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @clinic/doctor 还在维护吗？

最新版本 11\.0\.0 发布于 2023/06/28（3 年前）；至今共发布 7 个版本，其中过去 12 个月发布了 0 个；首次发布于 2021/11/14。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

