mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
31 lines
751 B
JavaScript
31 lines
751 B
JavaScript
import EventEmitterNative from "node:events";
|
|
import { group } from "../runner.mjs";
|
|
|
|
export const implementations = [
|
|
{
|
|
EventEmitter: EventEmitterNative,
|
|
name: process.isBun ? (EventEmitterNative.init ? "bun" : "C++") : "node:events",
|
|
monkey: true,
|
|
},
|
|
// { EventEmitter: EventEmitter3, name: "EventEmitter3" },
|
|
].filter(Boolean);
|
|
|
|
for (const impl of implementations) {
|
|
impl.EventEmitter?.setMaxListeners?.(Infinity);
|
|
}
|
|
|
|
export function groupForEmitter(name, cb) {
|
|
if (implementations.length === 1) {
|
|
return cb({
|
|
...implementations[0],
|
|
name: `${name}: ${implementations[0].name}`,
|
|
});
|
|
} else {
|
|
return group(name, () => {
|
|
for (let impl of implementations) {
|
|
cb(impl);
|
|
}
|
|
});
|
|
}
|
|
}
|