@prexjs/unpipe
v1.0.0
Published
Unpipe a Node.js stream from all destinations with compatibility fallback across stream versions.
Readme
@prexjs/unpipe
Unpipe a Node.js stream from all destinations with compatibility fallback across stream versions.
@prexjs/unpipe unpipes a stream from all its destinations, ensuring cleanup of attached data and pipe listeners across all Node.js stream versions.
Features
- Safely unpipes readable streams from all destinations.
- Handles legacy stream listener cleanup and modern
.unpipe()calls. - Dual ES Module (
.mjs) and CommonJS (.cjs) support with TypeScript definitions. - Zero runtime dependencies.
Installation
Install using your preferred package manager:
# npm
npm install @prexjs/unpipe
# pnpm
pnpm add @prexjs/unpipe
# Yarn
yarn add @prexjs/unpipe
# Bun
bun add @prexjs/unpipeQuick start
import fs from 'node:fs';
import unpipe from '@prexjs/unpipe';
const readable = fs.createReadStream('input.txt');
const writable = fs.createWriteStream('output.txt');
readable.pipe(writable);
// Later, unpipe from all destinations:
unpipe(readable);Both default and named exports are supported:
import unpipe, { unpipe as namedUnpipe, type UnpipeStream } from '@prexjs/unpipe';Compatibility
@prexjs/unpipe is designed for Node.js, Deno, and Bun stream environments.
License
This project is licensed under the MIT License. See LICENSE for the full license text.
Related projects
- prex.js — prex.js monorepo and ecosystem.
