web-streams-api
/web-streams-api
Use this skill when processing streaming network payloads, chunked downloads, or large text streams with ReadableStream, WritableStream, and TransformStream.
- Author
- nextboxis ↗
- Repository
- library-skill-agents ↗
- Licence
- MIT
- Last repository change
- 28.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 28.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Use this skill when processing streaming network payloads, chunked downloads, or large text streams with ReadableStream, WritableStream, and TransformStream.
Original author description
Use this skill when processing streaming network payloads, chunked downloads, or large text streams with ReadableStream, WritableStream, and TransformStream.
How it works
- When to use
- Prerequisites
- Step-by-step workflow
- Commands / code examples
- Common mistakes & pitfalls
- Verification checklist
- Related skills
SKILL.md preview
---
name: web-streams-api
description: Use this skill when processing streaming network payloads, chunked downloads, or large text streams with ReadableStream, WritableStream, and TransformStream.
---
# Web Streams API
## When to use
Use this skill when streaming LLM completions, parsing gigabyte-scale CSVs or JSON arrays, processing media chunks in real time, or handling backpressure.
## Prerequisites
- Modern browser or Node.js 18+ runtime supporting the Streams standard.
- Understanding of promises, async iterators, and backpressure mechanisms.
## Step-by-step workflow
1. **Acquire readable stream**: Obtain a `ReadableStream` from `response.body` after invoking `fetch()`.
2. **Lock stream with reader**: Acquire a dedicated reader using `stream.getReader()` to consume chunks sequentially.
3. **Implement transform pipelines**: Pipe readable streams through `TransformStream` instances (e.g., `TextDecoderStream`) using `.pipeThrough()`.
4. **Consume chunks with loop**: Read data chunks using `while (true)` until `{ done: true }` is returned.
5. **Handle cancellation and errors**: Always handle stream errors with `try/catch` and call `reader.cancel()` if the user aborts consumption.
## Commands / code examples
```ts
export async function streamLLMCompletion(
url: string,
onToken: (token: string) => void
): Promise<string> {
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ prompt: 'Explain distributed consensus algorithms.' }),
});
if (!response.body) throw new Error('Response body is null');
// Pipe raw bytes through text decoder stream
const textStream = response.body.pipeThrough(new TextDecoderStream());
const reader = textStream.getReader();
let fullResponse = '';
try {
while (true) {
const { value, done } = await reader.read();
if (done) break;
if (value) {
fullResponse += value;
onToken(value);
}
}
} finally {
reader.releaseLock();
}
return fullResponse;
}
```
## Common mistakes & pitfalls
- Attempting to read a stream after it has already been locked by another reader without releasing the lock.
- Reading entire payloads into memory with `response.text()` when progressive chunk rendering is required.
- Failing to release stream locks or cancel underlying readers when user navigates away.
## Verification checklist
- [ ] Streams are decoded chunk-by-chunk without accumulating unbounded buffers.
- [ ] Readers release locks inside `finally` blocks.
- [ ] Network dropouts and stream terminations are caught cleanly.
- [ ] Stream pipelines leverage `pipeThrough` for modular transformations.
## Related skills
- server-sent-events-sse
- web-workers-multithreading
- restful-api-design-best-practices
- performance-code-review-complexity-allocations
Versions
The database has no other skills named web-streams-api.
Database snapshot: 13.11.2026 · package version 12d891d2f460 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 95java-streams-api
Use when Java Streams API for functional-style data processing. Use when processing collections with streams. - 84implementing-io-pipelines
Implements high-performance streaming using System.IO.Pipelines in .NET. Use when building network protocols, parsing binary data, or processing large streams efficiently. - 100server-sent-events-sse
Use this skill when streaming real-time data updates, live telemetry, or LLM token streams to web clients over HTTP. - 100kafka-expert
Expert-level Apache Kafka, event streaming, Kafka Streams, and distributed messaging. Use when the user mentions streaming, messaging, event driven, or Kafka Streams. - 100streaming-architecture
Use when reasoning about systems that emit a sequence of values over time and consume them incrementally: the producer/stream/consumer/backpressure/termination primitives, the difference between streaming and request-response, the difference between streaming and pub-sub… - 95backend-data-streaming
Use this skill when the user says 'data streaming', 'kafka architecture', 'stream processing', 'flink job', 'kafka streams', 'exactly once', 'watermarks', 'windowed aggregation', 'consumer lag', 'log compaction'. Designs backend streaming pipelines on Kafka (or compatible logs)…