Transcript from the "Core Streams" Lesson
>> So I wanna list down all of the Core Streams that are available in mode both to give you an idea for maybe what you can poke around at and also just to show you where they all are, what they're good for. So, we've seen a bunch of these already.
[00:00:15] We've seen fs.createReadStream( ), we've seen fs.createWriteStream( ). We've also seen process standard in and process standard out. But there's also standard error, err, which is used for writing to file descriptor two, I think. Which is just the extra spammy info messages you can print to the terminal. If you wanna put errors there, it's a good place to put them.
[00:00:41] Also if you create a child process, there's a node module and I need just show how that works. Called child process. So it has some methods as spawn and I forget exactly what they are, but we'll just pull up the spawn and exec. So we'll use the spawn method right now to run another program in a.
[00:01:07] And we'll, we can write to it standard input and read from it standard output. So, for example, if I spawn something like grep right. So the first argument is the command name, the grep, in this case. The second argument is an array of the command line arguments that you want to pass in.
[00:01:30] So I'll do grep for potato. Now every time I write a line of input to standard in on this process object. That matches the string potato, which could be a regex if you like, then I should get that line on the output so, I can write a couple of things.
[00:01:54] Cheese, Carrots, carrot potato Potato, so the last two those automatch and then I'll call end to tell the program to end and I can pipe ps.stdout just to standard out normally. So this little program is just gonna watch that come in for us and we can use all of the string methods we've seen so far to deal with it.
[00:02:30] So here we go. We get, we ran the grep command, piped in a lot of things, but it only printed out the lines that matched the string potato. Just add that to the Repo.
>> Okay, so we've also seen net.connect and net.createServer. There's also tls.connect and tls.createServer so you can make SSL connections.
[00:02:55] But then you have to generate certificates it's a little bit complicated you have to have to bust out some open SSL commands and such. So not going to do that right now. But it's with air, those are both, just like the net methods, the TLS methods, return duplex streams that work the same way that they work.
[00:03:16] With net except you have to be a little bit more careful about which part is the plaintext, and which part is the ciphertext.