# @ahrefs/bs-atdgen-codec-runtime 中文文档

规范地址：https://npmcn.com/package/%40ahrefs/bs-atdgen-codec-runtime/

版本：2\.2\.0
npm 元数据更新时间：2025-04-28T08:15:05.661Z
中文译文更新时间：2026-11-06T12:11:13.237Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40ahrefs/bs-atdgen-codec-runtime
原文对照：https://npmcn.com/package/%40ahrefs/bs-atdgen-codec-runtime/?lang=original
项目主页：https://github.com/ahrefs/bs-atdgen-codec-runtime#readme
源码仓库：https://github.com/ahrefs/bs-atdgen-codec-runtime

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

- 包体积（解压后）：159 kB，125 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：1 个
- 首次发布：2018-08-28T13:04:21.923Z
- 最新版本发布：2021-12-03T14:53:37.628Z
- 近 30 天下载量：3259（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：18（近 12 个月 0 个）

## 中文简介

atdgen 的标定运行时间

## 安装

```sh
npm install @ahrefs/bs-atdgen-codec-runtime
```

也可以使用：`pnpm add @ahrefs/bs-atdgen-codec-runtime`、`yarn add @ahrefs/bs-atdgen-codec-runtime`、`bun add @ahrefs/bs-atdgen-codec-runtime`

## README

# bs-atdgen-codec-runtime 时间

`bs-atdgen-codec-runtime` 是一个带扣的运行时间 [选项](https://github.com/ahrefs/atd)。它基于 json 类型 由下列文件提供: [@glennsl/bs-json (英语)](https://github.com/glennsl/bs-json)。 。 。 .

## 安装

```
yarn add @ahrefs/bs-atdgen-codec-runtime
```

此软件包不考虑运行调试器以获取代码 类型定义。 这个步骤要求 `atdgen` 可以是二进制 使用 [缩写](https://opam.ocaml.org/) 或者说 [爱思](https://esy.sh/)。 。 。 .

或者,如果您的项目只使用 BuckleScript(即在后端不使用本地的OCaml 或理由), 您可以考虑使用 [`bs-atdgen-generator`](https://github.com/jchavarri/bs-atdgen-generator) 结合 这个运行时库,以生成 `.ml` 财务报告和审定财务报表 `.mli` 来自 `.atd` 来源,无需使用本地 软件包管理器喜欢 `esy` 或者说 `opam`。 。 。 .

## 使用量

添加 `@ahrefs/bs-atdgen-codec-runtime` 页:1 `bs-dependencies` 联 合 国 `bsconfig.json`。 。 。 .

要写入已填表类型定义, 请查看 [不错 文档](https://atd.readthedocs.io/en/latest/)。 。 。 .

## 简单示例

查询和解析 REST API 答复的理由代码。 这个 需求 `bs-fetch`。 。 。 .

```
let get = (url, decode) =>
  Js.Promise.(
    Fetch.fetchWithInit(
      url,
      Fetch.RequestInit.make(~method_=Get, ()),
    )
    |> then_(Fetch.Response.json)
    |> then_(json => json |> decode |> resolve)
  );

let v: Meetup_t.events =
  get(
    "http://localhost:8000/events",
    Atdgen_codec_runtime.Decode.decode(Meetup_bs.read_events),
  );
```

## 完整实例

这个 [实例](https://npmcn.com/package/%40ahrefs/bs-atdgen-codec-runtime/example) 目录包含一个简单的完整示例 cli 读取和写入 JSON 文件的数据 .

从Atdgen安装到json的完整介绍 请参考 [开始使用 attgen 和 扣上安全带](https://tech.ahrefs.com/getting-started-with-atdgen-and-bucklescript-1f3a14004081)。 。 。 .

## 常见问题

### @ahrefs/bs-atdgen-codec-runtime 是什么？

atdgen 的标定运行时间

### 如何安装 @ahrefs/bs-atdgen-codec-runtime？

在项目目录运行 npm install @ahrefs/bs-atdgen-codec-runtime，或使用 pnpm add / yarn add / bun add。

### @ahrefs/bs-atdgen-codec-runtime 支持 TypeScript 吗？

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

### @ahrefs/bs-atdgen-codec-runtime 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @ahrefs/bs-atdgen-codec-runtime 可以商用吗？

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

### @ahrefs/bs-atdgen-codec-runtime 的下载量有多少？

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

### @ahrefs/bs-atdgen-codec-runtime 还在维护吗？

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

