web-streams-api
/web-streams-api
Przetwarza strumienie danych sieciowych, pobierania po kawałkach i duże teksty przez ReadableStream i TransformStream.
- Autor
- nextboxis ↗
- Repozytorium
- library-skill-agents ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 28.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 28.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Przetwarza strumienie danych sieciowych, pobierania po kawałkach i duże teksty przez ReadableStream i TransformStream.
Oryginalny opis (EN)
Use this skill when processing streaming network payloads, chunked downloads, or large text streams with ReadableStream, WritableStream, and TransformStream.
Jak działa
- When to use
- Prerequisites
- Step-by-step workflow
- Commands / code examples
- Common mistakes & pitfalls
- Verification checklist
- Related skills
Podgląd SKILL.md
---
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
Wersje
W bazie nie ma innych skilli o nazwie web-streams-api.
Migawka bazy z 13.11.2026 · wersja paczki 12d891d2f460 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 95java-streams-api
Pomaga przetwarzać kolekcje w Javie w stylu funkcyjnym przy użyciu Streams API. - 84implementing-io-pipelines
Wdraża strumieniowe przetwarzanie danych przez System.IO.Pipelines w .NET, przy protokołach sieciowych i dużych strumieniach. - 100server-sent-events-sse
Pomaga przesyłać na żywo aktualizacje danych, telemetrię i strumienie tokenów LLM do przeglądarki przez HTTP. - 100kafka-expert
Wspiera pracę z Apache Kafka, strumieniowaniem zdarzeń, Kafka Streams i rozproszonym przesyłaniem wiadomości. - 100streaming-architecture
Wyjaśnia architekturę strumieniową: producent, strumień, konsument, backpressure i zakończenie, różnice względem request-response i pub-sub oraz współpracę WHATWG Streams, SSE, chunked HTTP, WebSockets, gRPC i RSC. - 95backend-data-streaming
Projektuje potoki strumieniowe na Kafce z Flink lub Kafka Streams: partycje, grupy konsumentów, offsety i przetwarzanie stanowe.