DefinitelyTyped icon indicating copy to clipboard operation
DefinitelyTyped copied to clipboard

Node.js typings (ReadStream methods)

Open tarurar opened this issue 10 years ago • 7 comments

I want to talk about node/node.d.ts. The method destroy of class fs.ReadStream is not available in the definition. I can call this method in regular javascript but not in typescript. Is it ok?

tarurar avatar Jun 18 '16 20:06 tarurar

please send a pull request first. I'll review it.

vvakame avatar Jun 19 '16 04:06 vvakame

@tarurar where exactly is this API documented? I can't find it on Node's site.

DanielRosenwasser avatar Jun 19 '16 05:06 DanielRosenwasser

@DanielRosenwasser I don't see it either, but if you try to examine the __proto__ of the ReadStream object you will find this method: ReadStream { open: [Function], _read: [Function], destroy: [Function], close: [Function] }

I saw examples in javascript which uses stream.destroy() to eliminate memory leaks.

tarurar avatar Jun 19 '16 05:06 tarurar

@vvakame ok, done

tarurar avatar Jun 19 '16 06:06 tarurar

@tarurar interestingly I just saw a PR relating to this pop up:

https://github.com/nodejs/node/issues/5898#issuecomment-212417054

In other words, it should probably be documented, but it should be fine to add here.

DanielRosenwasser avatar Jun 20 '16 06:06 DanielRosenwasser

Hi. Just hit this. Wanted to make a PR for this, but wanted to understand the difference between the Readable class and the ReadableStream global interface.

The class is defining more methods than the interface, but a few packages I use (like dockerode) uses the global NodeJS.ReadableStream instead of the class. Seems like that may be common.

I believe the interface should define all these methods and the class should implement them, correct?

rhyek avatar Dec 11 '20 04:12 rhyek

Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the @types modules in DefinitelyTyped.

To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the definitely-typed channel.

orta avatar Jun 23 '21 08:06 orta