Skip to content

Add missing exports - #286

Merged
koral-- merged 2 commits into
masterfrom
parser
May 4, 2022
Merged

koral-- merged 2 commits into
masterfrom
parser

Conversation

@koral--

@koral-- koral-- commented May 4, 2022

Copy link
Copy Markdown
Member

No description provided.

Comment thread test/mock/duplex.ts
Comment on lines -26 to +28
end(...args: any[]): this {
end(cb?: () => void): this {
this.causeEnd(); // In order to better emulate socket streams
return (Stream.Duplex.prototype.end as any).apply(this, args);
return (Stream.Duplex.prototype.end as any).apply(this, cb);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct.

  1. Stream.Duplex has overloaded end() method: @types/node. You should't limit it to just a callback.
  2. args here was an array and cb is () => void | undefined. The second argument for Function.prototype.apply must be an array (or array-like).
    If the method wasn't overloaded, you should have use here either .apply(this, [cb]); or .call(this, cb)

So this method shouldn't be changed. But to make the code cleaner:

  end(...args: any[]): this {
    this.causeEnd(); // In order to better emulate socket streams
    return super.end(...args);
  }

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply

@koral-- koral-- mentioned this pull request Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants