0.1.0 • Published 5 months ago

async-mutex-stream v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

async-mutex-stream

npm version npm downloads

This package is a TypeScript library for handling asynchronous streams with mutex locking and piping capabilities.

Installation

npm install async-mutex-stream
# or
pnpm add async-mutex-stream

Dependencies

This package requires the following dependencies:

Features

  • Mutex-based synchronization for stream operations
  • Support for async generators
  • Piping between streams
  • Error handling and state management
  • Strict type checking
  • Stream multicasting

Basic Usage

Simple Stream

Create a basic stream that processes string data:

import { AsyncMutexStream } from 'async-mutex-stream';

const stream = new AsyncMutexStream({
	start: async () => {
		// Optional initialization
		console.log('Stream started');
	},
	write: async (data: string) => {
		// Process the data
		console.log(`Processing: ${data}`);
	},
	end: async () => {
		// Optional cleanup
		console.log('Stream ended');
	},
});
// Use the stream
await stream.write('Hello');
await stream.write('World');
await stream.end();

License

MIT License

0.1.0

5 months ago