nodejs / nodejs/node

Sync alternative to `fs.openAsBlob`

オープン
#65,462 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

feature request
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、既存の fs.openAsBlob API と fs.createReadStream API、およびそれらのドキュメントを確認します。エントリーポイントを提案する前に、同期 File API の形状、Response に公開されるメタデータ、ランタイム間の動作を明確にします。API 設計について合意され、その動作がテストとドキュメントでカバーされれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
backend
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
活発
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。