# 2-thenable 中文文档

规范地址：https://npmcn.com/package/2-thenable/

版本：1\.0\.0
npm 元数据更新时间：2022-04-04T10:17:13.782Z
中文译文更新时间：2026-11-05T16:58:02.095Z
软件包许可：ISC

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

原始 npm 页面：https://www.npmjs.com/package/2-thenable
原文对照：https://npmcn.com/package/2-thenable/?lang=original
项目主页：https://github.com/medikoo/2-thenable#readme
源码仓库：https://github.com/medikoo/2-thenable

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

- 包体积（解压后）：7 kB，7 个文件
- TypeScript 类型：未声明
- 运行依赖：2 个
- 首次发布：2019-01-16T16:05:32.807Z
- 最新版本发布：2019-01-16T16:05:32.932Z
- 近 30 天下载量：2849522（2026-10-04 至 2026-11-02，npm 官方下载统计）
- 已发布版本数：1（近 12 个月 0 个）

## 中文简介

将任意对象转换为可导对象

## 安装

```sh
npm install 2-thenable
```

也可以使用：`pnpm add 2-thenable`、`yarn add 2-thenable`、`bun add 2-thenable`

## README

[![\*nix build status](https://semaphoreci.com/api/v1/medikoo-org/2-thenable/branches/master/shields_badge.svg)](https://semaphoreci.com/medikoo-org/2-thenable) [![Windows build status](https://ci.appveyor.com/api/projects/status/?svg=true)](https://ci.appveyor.com/api/project/medikoo/2-thenable) [![Tests coverage](https://img.shields.io/codecov/c/github/medikoo/2-thenable.svg)](https://codecov.io/gh/medikoo/2-thenable) ![Transpilation status](https://img.shields.io/badge/transpilation-free-brightgreen.svg)

# 2-可兑换

## 将对象转换为可当量

当我们想要在一些非承诺对象上 暗示一个同步的表示时,是有用的.

拥有该目标对象可以被组合成承诺链或async/await语法. 一种用法就是 转出一个流出的例子 所以它也是一个承诺.

### 安装

```bash
npm install 2-thenable
```

### 如何运作

工具占用 `target` 财务报告和审定财务报表 `promise` 参数. `target` 以 `then`, (中文(简体) ), `catch` 财务报告和审定财务报表 `finally` 方法。 。 . 虽然 `promise` 预计将是一个反映解决办法的本土承诺实例,应将其绘制成地图 `target`

# 使用量

将流转换为可当量的示例

```javascript
const toThenable = require("2-thenable");

// Example of converting a simple utf8 string stream to thenable
toThenable(stream, new Promise((resolve, reject) => {
    let result = '';
    stream.on('error', reject);
    stream.on('data', data => (result += data));
    stream.on('end', () => resolve(result));
});

stream.then(result => {
    console.log("Cumulated string data", result);
});
```

### 测试

```bash
npm test
```

## 常见问题

### 2-thenable 是什么？

将任意对象转换为可导对象

### 如何安装 2-thenable？

在项目目录运行 npm install 2-thenable，或使用 pnpm add / yarn add / bun add。

### 2-thenable 支持 TypeScript 吗？

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

### 2-thenable 可以商用吗？

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

### 2-thenable 的下载量有多少？

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

### 2-thenable 还在维护吗？

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

