Sync alternative to `fs.openAsBlob`
未关闭
还没有人认领这个 Issue。
feature request
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.4k
- 平均合并
- 4 天 3 小时
- 30 天内合并 PR
- 272
描述
What is the problem this feature will solve?
I'm making a cross-runtime file streaming library (that needs to be fast) and this would make it way easier to do so since Bun.file() is already sync.
So the code might look like this if my suggestion made it to node:fs:
const getFile: (path: string) => File = globalThis.Bun
? Bun.file
: process.getBuiltinModule('fs').openAsWebFile;
// Usage
return new Response(getFile('./index.html'));
return new Response(getFile('./binary-data').slice(0, 100));
What is the feature you are proposing to solve the problem?
A new API, something like fs.openAsWebFile() that returns a File maybe?
It would have more info for the Response constructor to pick up as well.
What alternatives have you considered?
fs.createReadStream but that is also async and can be slower too.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先检查现有的 fs.openAsBlob 和 fs.createReadStream API 及其文档。在提出入口点之前,明确同步 File API 的形态、向 Response 暴露的元数据以及跨运行时行为。API 设计达成一致,并且其行为由测试和文档覆盖,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- backend
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 活跃
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100