Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emitter/Stream contract convertors #280

Open
tshemsedinov opened this issue Jan 29, 2025 · 0 comments
Open

Emitter/Stream contract convertors #280

tshemsedinov opened this issue Jan 29, 2025 · 0 comments
Labels
enhancement New feature or request patterns-24

Comments

@tshemsedinov
Copy link
Member

Emitter to Stream

const ee = new EventEmitter();
const readable = Stream.from(ee.toAsyncIterable('user'));
ee.emit('user', { name: 'Marcus', position: 'Imperor' });
readable.toEventEmitter()

Stream to Emitter

const readable = getReadableSomehow();
const ee = readable.toEventEmitter();
ee.on('user', (user) => {
  console.log(`Name: ${user.name}, Position: ${user.position}`);
});

Refs: #267

@tshemsedinov tshemsedinov added enhancement New feature or request patterns-24 labels Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request patterns-24
Projects
None yet
Development

No branches or pull requests

1 participant