Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
streameAPI
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
nikawa2161
May 27, 2025
18
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
streameAPI
nikawa2161
May 27, 2025
More Decks by nikawa2161
See All by nikawa2161
Node.js Subpath imports
nikawa2161
0
44
Sagaパターン入門(続編)
nikawa2161
0
52
Sagaパターン入門
nikawa2161
0
65
沖縄観光とPostgreSQL排他制約の話
nikawa2161
0
41
20251209_プログラミング原則の学び
nikawa2161
0
41
自分のコードを数年ぶりに読んだら
nikawa2161
0
26
ユーザーインタビュー分析に参加して得られたことと気づき
nikawa2161
0
44
oEmbedとは?
nikawa2161
0
250
はじめまして、にかわです
nikawa2161
0
29
Featured
See All Featured
Practical Orchestrator
shlominoach
192
12k
Documentation Writing (for coders)
carmenintech
77
5.6k
30 Presentation Tips
portentint
PRO
1
430
Scaling GitHub
holman
464
140k
First, design no harm
axbom
PRO
2
1.3k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
How STYLIGHT went responsive
nonsquared
100
6.3k
Accessibility Awareness
sabderemane
1
250
Evolving SEO for Evolving Search Engines
ryanjones
0
320
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
470
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Transcript
WebStreamAPI
B データ出力を逐次的に、公立よく扱うためのデータ構% B データ全体(ファイル一個)をそれより細かく分割された単位の連続した 流れを表現する ストリームとは
ストリームのメリット c メモリ空間を圧迫しにくV c データを処理する分だけ少しずつ取り出7 c 書き込み先に書き込まれるのでメモリが解放され5 c 低遅 c
先頭のデータが処理されるまでの時間が早V c 完了する時間が早くなるとは限らない
Streams APIの概要 ・分割されたChunkの連続した流れ ・3種類の異なるストリームオブジェクQ ' Readable Strea ' Transform Strea
' Writable Stream
ReadableStream f ソースから流れるデータをチャンクし、分割し、ストリーム処理できる形 にすG f Readable Streamの! f Fetch APIのResponse.bod
f Blob.stream
Transform Stream ・チャンクを変換す' 4 バイナリ→文字列な) 4 データの圧縮・展開
Writable Stream ・ファイルシステム、データベースに書き込む
WebStream ・説明した3つのストリームを使って、処理する ・ストリームはパイプをつなげて処理する
ストリームの分配 ・1つのReadableStreamを2つに分配できる ・結果として同じものが出力される
ユースケース ・大量レコードをDBに書き込む時に、一定の量でインポートできる ・AIのチャットなど
Node.jsとの違い Node.jsには組み込みでStreamモジュールがあV Web Stream APIより先にあV 5種類のストリームオブジェク7
Readable(読み込み( Writable(書き込み( Duplex(双方向:読み書き両方( Transform(変換付きのDuplex( PassThrough(何もしない変換)
Node StreamとWeb Streams APIの互換性 w Web Streams API自体はNode.js21でStablr w stream
モジュールの fromWeb() / toWeb() メソッC w v24 でこれらの変換メソッドも Stablr w Web Streams APIと相互変換 が可% w fromWeb() および toWeb() を使用
Node StreamとWeb Streams APIの互換性 1 2 3 4 5 import
from const new const { Readable } ; nodeStream Readable. ( ReadableStream()); webStream Readable. (nodeStream); "node:stream" // Web Streams API → Node Stream に変換 // Node Stream → Web Streams API に変換 = = fromWeb toWeb Web Streams APIと相互変換 が可m fromWeb() および toWeb() を使用
Node Streamと比べて良くなった点(Web Streams API) o Web標準であること(=より広く使える o インターフェーw o 型情報がしっかりしてい
o エラーハンドリングがシンプa o Node Stream の課題e o 上流のストリームでエラーが起きても、下流が勝手に閉じてくれなg o Web Streams API の改善e o エラー時に自動で閉じてくれ o エラーハンドリングの動作を制御できる
まとめ d 基本構成:3種類のストリームオブジェクX d ReadableStream: 読み込み専& d TransformStream: 変換処G d
WritableStream: 書き込み専& d Node.js のストリームと相互変換可Ä d Readable.fromWeb() や Readable.toWeb()
None
None