1.0.11 • Published 10 months ago

duplex-through-with-error-handling v1.0.11

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

Duplex Through With Error Handling

A simple utility to create duplex streams with bidirectional error handling.

Uses duplex-through

Installation

To install run:

npm install duplex-through-with-error-handling

Usage

import { duplexThrough } from 'duplex-through-with-error-handling';

const [d1, d2] = duplexThrough({ /* options for duplex streams */ });

// Write data to the stream 1
d1.write('some data');

// Read data from the stream 2
d2.on('data', (data) => {
    // data === "some data"
});

d2.on("error", e => {
    // e.message === "some error from d1"
});

d1.on("error", e => {
    // e.message === "some error from d1" 
});

d1.destroy(new Error("some error from d1"))

Features

  • Creates duplex streams
  • Handles errors bidirectionally to prevent unhandled error events
  • Ensures cleanup of error handlers on stream close
1.0.11

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago