unified

Project: unifiedjs/unified-stream

Package: unified-stream@2.0.0

  1. Dependents: 0
  2. Streaming interface for unified processors
  1. unified 175

unified-stream

Build Coverage Downloads Sponsors Backers Chat

Streaming interface for unified.

Contents

What is this?

This package turns a unified processor into a (duplex) Node.js stream.

👉 Note: the interface is streaming but the code buffers.

When should I use this?

You can use this if you have to use Node streams and are integrating with unified. As the code actually buffers, in almost all cases, you can use unified itself.

Install

This package is ESM only. In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with npm:

npm install unified-stream

Use

import {stream} from 'unified-stream'
import {unified} from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeFormat from 'rehype-format'
import rehypeStringify from 'rehype-stringify'

// Pipe stdin, into an HTML formatter, to stdout.
process.stdin
  .pipe(
    stream(unified().use(rehypeParse).use(rehypeFormat).use(rehypeStringify))
  )
  .pipe(process.stdout)

API

This package exports the identifier stream. There is no default export.

stream(processor)

Create a duplex (readable/writable) Node.js stream that transforms with processor.

Types

This package is fully typed with TypeScript. It exports the additional type MinimalDuplex.

Compatibility

Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+. Our projects sometimes work with older versions, but this is not guaranteed.

Contribute

See contributing.md in unifiedjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer