Skip to content
Skills Library
Programming · Building & coding

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.

Licence
MIT
Last repository change
28.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 28.10.2026, without references to retired models or APIs.

Licence

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

  1. When to use
  2. Prerequisites
  3. Step-by-step workflow
  4. Commands / code examples
  5. Common mistakes & pitfalls
  6. Verification checklist
  7. Related skills
Original SKILL.md headings · 69 lines, 345 words
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)…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.