@clinic/doctor

中文文档
11.0.0发布于 2023/06/28MIT近 30 天下载 18.1万

Programmable interface to Clinic.js Doctor

原始使用文档
文档目录7 节
  1. Issues
  2. Installation
  3. Supported node versions
  4. Example
  5. Documentation
  6. new ClinicDoctor([settings])
  7. License

Clinic.js Doctor

Greenkeeper badge npm version Stability Stable Github Actions build status Downloads Code style

Programmable interface to Clinic.js Doctor. Learn more about Clinic.js: https://clinicjs.org/

Screenshot

Issues

To open an issue, please use the main repository with the doctor label.

Installation

npm i -S @clinic/doctor

Supported node versions

  • Node.js 16 and above

Example

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
  });
})

You can find examples in node-clinic-doctor-examples

Documentation

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

new ClinicDoctor([settings])

  • settings <Object>
    • sampleInterval <Number> Time between each sample in milliseconds. Default: 10
    • detectPort <boolean> Default: false
    • dest <String> The folder where the collected data is stored. Default: '.'
    • debug <boolean> If set to true, the generated html will not be minified. Default: false
    • collectDelay <Number> Default: 0

doctor.collect(args, callback)

Starts a process by using:

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

The injected sampler will produce a file in the current working directory, with the process PID in its filename. The filepath relative to the current working directory will be the value in the callback.

stdout, stderr, and stdin will be relayed to the calling process. As will the SIGINT event.

doctor.visualize(dataFilename, outputFilename, callback)

Will consume the datafile specified by dataFilename, this datafile will be produced by the sampler using doctor.collect.

doctor.visualize will then output a standalone HTML file to outputFilename. When completed the callback will be called with no extra arguments, except a possible error.

License

MIT

版本与发布记录

@clinic/doctor 共发布 7 个版本,首次发布于 2021/11/14;过去 12 个月发布了 0 个版本。

版本发布日期距今
11.0.0latest2023/06/283 年前
10.1.02023/03/163 年前
10.0.02022/08/264 年前
9.2.12022/01/314 年前
9.2.02022/01/174 年前
9.1.02021/12/174 年前

关于 @clinic/doctor 的常见问题

@clinic/doctor 是什么?

Programmable interface to Clinic.js Doctor

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