UNPKG

basebee

Version:

Basebee is a powerful key-value store built on top of Autobase and Hyperbee, designed to efficiently manage data with customizable key/value encodings, prefix-based key organization, and batch operations. It integrates stream-based APIs for handling key-v

22 lines 683 B
export function forwardEvents(source, target, events) { const listeners = events.map(event => { const listener = (...args) => { // For error events, rethrow the error if it occurs. if (event === 'error') { const [error] = args; if (error instanceof Error) { throw error; } } args.push(source); target.emit(event, ...args); }; source.on(event, listener); return {event, listener}; }); return () => { listeners.forEach(({event, listener}) => { source.off(event, listener); }); }; }