mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
* Revert "Revert "use a lazyily initialized stream for `node:crypto` `createHash` (#2652)"" This reverts commit613bb4822e. * Revert "Revert "implement `node:events` in javascript (#2604)"" This reverts commita4d0a1961a. * oops * fix entrypoints stuff * fix hash copy * use native events for node streams and crypto * requested changes * oops * make discord.js work * fix webkit hash * headers tojson
32 lines
787 B
JavaScript
32 lines
787 B
JavaScript
import EventEmitter3 from "eventemitter3";
|
|
import { group } from "mitata";
|
|
import EventEmitterNative from "node:events";
|
|
|
|
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);
|
|
}
|
|
});
|
|
}
|
|
}
|