2-thenable

中文文档
1.0.0发布于 2019/01/17ISC近 30 天下载 285万

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

中文使用文档
文档目录4 节
  1. 将对象转换为可当量
  2. 安装
  3. 如何运作
  4. 测试

*nix build status Windows build status Tests coverage Transpilation status

2-可兑换

将对象转换为可当量

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

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

安装

npm install 2-thenable

如何运作

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

使用量

将流转换为可当量的示例

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

测试

npm test

版本与发布记录

2-thenable 共发布 1 个版本,首次发布于 2019/01/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.0latest2019/01/177 年前

关于 2-thenable 的常见问题

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 和提交记录判断。