Skip to content

Commit

Permalink
fix(node): fix export items of events (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k authored Feb 27, 2021
1 parent f285c79 commit 332258b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion node/_stream/readable_internal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Node.js contributors. All rights reserved. MIT License.
import { Buffer } from "../buffer.ts";
import type Duplex from "./duplex.ts";
import type EventEmitter from "../events.ts";
import { EventEmitter } from "../events.ts";
import type Readable from "./readable.ts";
import type Writable from "./writable.ts";
import type { ReadableState } from "./readable.ts";
Expand Down
5 changes: 3 additions & 2 deletions node/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export let defaultMaxListeners = 10;
/**
* See also https://nodejs.org/api/events.html
*/
export default class EventEmitter {
export class EventEmitter {
public static captureRejectionSymbol = Symbol.for("nodejs.rejection");
public static errorMonitor = Symbol("events.errorMonitor");
public static get defaultMaxListeners() {
Expand Down Expand Up @@ -558,7 +558,8 @@ export default class EventEmitter {
}
}

export { EventEmitter };
export default Object.assign(EventEmitter, { EventEmitter });

export const captureRejectionSymbol = EventEmitter.captureRejectionSymbol;
export const errorMonitor = EventEmitter.errorMonitor;
export const listenerCount = EventEmitter.listenerCount;
Expand Down
5 changes: 4 additions & 1 deletion node/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,10 @@ nativeModulePolyfill.set(
createNativeModule("constants", nodeConstants),
);
nativeModulePolyfill.set("crypto", createNativeModule("crypto", nodeCrypto));
nativeModulePolyfill.set("events", createNativeModule("events", nodeEvents));
nativeModulePolyfill.set(
"events",
createNativeModule("events", nodeEvents),
);
nativeModulePolyfill.set("fs", createNativeModule("fs", nodeFS));
nativeModulePolyfill.set("os", createNativeModule("os", nodeOs));
nativeModulePolyfill.set("path", createNativeModule("path", nodePath));
Expand Down
5 changes: 5 additions & 0 deletions node/module_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,8 @@ Deno.test("native modules are extensible", () => {
Deno.test("Require file with shebang", () => {
require("./testdata/shebang.js");
});

Deno.test("EventEmitter is exported correctly", () => {
const EventEmitter = require("events");
assertEquals(EventEmitter, EventEmitter.EventEmitter);
});

0 comments on commit 332258b

Please sign in to comment.