Networking and Streams Q&A: Streams
Transcript from the "Q&A: Streams" Lesson
>> What does adding that transformed because ultimately when I've been running it, it does exactly the same thing. What were you saying the trends in adding the transform?
>> So if the transform here, which is this line, turns these chunks of data into uppercase. So that's what this example does.
[00:00:23] Is it just-
>> Don't you have the same thing or-
>> I think he means the core versus the-
>> Yeah, well, the core versus-
>> Yeah, so it does the same thing, it's meant to be the same. It's just more of like a comparison of using core stream versus userland 32 package.
>> Okay, so that transform-
>> Use whichever one-
>> Object is basically what you could use in the core package rather than-
>> The 32 package.
>> Yeah, I like the 32 one a little bit better cuz it's more terse, but the core one is fine, too.
[00:00:53] Use whichever one you like the best. But you should readable stream, instead of core stream because if you don't, it will come to bite you eventually. [LAUGH] There's a great blog post by Rod Vagg about exactly that problem. [LAUGH]
>> Why does node continue to have their own, like if that's a better way, then shouldn't node just be like, use userland.
>> I agree.
>> Wouldn't that be good? [LAUGH] But that's not the world that we live in, it seems.
>> Because I guess if they did that, then it would break [LAUGH] everything that uses the core said there.
>> Yeah, everything can just stop, stop.
>> Stop supporting it.
>> Yeah, just like babysit the versions of VA, I don't know. That would be, I don't know, people will always wanna change stuff and you've always gotta deal with different kinds of like, something is never gonna be perfect as well. So change is kind of inevitable, but at least by using userland packages, you're sort of shielded from a lot of that change.
[00:02:00] So that's why I highly recommend using userland packages wherever possible, even for things like query string cuz that also had some changes over time. You can make more guarantees about the versions of these things that people are going to have when they install it no matter what version of node they're running.
[00:02:24] Okay, so there are some questions on the chat, I guess, that I can answer. So one of them is about if you want to close this stream, what do you do? So this gets in a little bit to some notes that I have later on about paused mode versus flow mode streams.
[00:02:49] So I think that we'll be able to, maybe that upcoming section should address that question. There are ways to destroy streams sometimes. Sometimes, streams provide a destroy method, but usually it's not required. And then another thing is if you're piping, how do other transform functions know you're closed?
[00:03:21] They don't have to is the question or is the is the answer. So yeah, but I'll get into that a bit more later. So