Streaming interface for unified processors
npm install unified-stream[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
Streaming interface for [unified][unified].
* What is this?
* When should I use this?
* Install
* Use
* API
* stream(processor)
* MinimalDuplex
* Types
* Compatibility
* Contribute
* License
This package turns a unified processor into a (duplex) Node.js stream.
> 👉 Note: the interface is streaming but the code buffers.
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.
This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:
``sh`
npm install unified-stream
In Deno with [esm.sh][esm-sh]:
`js`
import {stream} from 'https://esm.sh/unified-stream@3'
In browsers with [esm.sh][esm-sh]:
`html`
`js
import process from 'node:process'
import rehypeFormat from 'rehype-format'
import rehypeParse from 'rehype-parse'
import rehypeStringify from 'rehype-stringify'
import {unified} from 'unified'
import {stream} from 'unified-stream'
// Pipe stdin, into an HTML formatter, to stdout.
process.stdin
.pipe(
stream(unified().use(rehypeParse).use(rehypeFormat).use(rehypeStringify))
)
.pipe(process.stdout)
`
This package exports the identifier [stream][api-stream].
There is no default export.
Create a duplex (readable and writable) stream that transforms with
processor.
###### Parameters
* processor ([Processor][processor])
— unified processor
###### Returns
Duplex stream ([MinimalDuplex][api-minimal-duplex]).
Simple readable and writable ([duplex][]) stream (TypeScript type).
This package is fully typed with [TypeScript][].
It exports the additional type [MinimalDuplex][api-minimal-duplex].
Projects maintained by the unified collective are compatible with maintained
versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, unified-stream@^3,
compatible with Node.js 16.
See [contributing.md][contributing] in [unifiedjs/.github][health] for wayssupport.md`][support] for ways to get help.
to get started.
See [
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
[MIT][license] © [Titus Wormer][author]
[build-badge]: https://github.com/unifiedjs/unified-stream/workflows/main/badge.svg
[build]: https://github.com/unifiedjs/unified-stream/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/unifiedjs/unified-stream.svg
[coverage]: https://codecov.io/github/unifiedjs/unified-stream
[downloads-badge]: https://img.shields.io/npm/dm/unified-stream.svg
[downloads]: https://www.npmjs.com/package/unified-stream
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://github.com/unifiedjs/unified/discussions
[npm]: https://docs.npmjs.com/cli/install
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esm-sh]: https://esm.sh
[typescript]: https://www.typescriptlang.org
[health]: https://github.com/unifiedjs/.github
[contributing]: https://github.com/unifiedjs/.github/blob/main/contributing.md
[support]: https://github.com/unifiedjs/.github/blob/main/support.md
[coc]: https://github.com/unifiedjs/.github/blob/main/code-of-conduct.md
[license]: license
[author]: https://wooorm.com
[unified]: https://github.com/unifiedjs/unified
[processor]: https://github.com/unifiedjs/unified#processor
[duplex]: https://nodejs.org/api/stream.html#class-streamduplex
[api-stream]: #streamprocessor
[api-minimal-duplex]: #minimalduplex