-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gather the output #2
Comments
That would definitely make multiline output easier 👍 I would argue that's what some users would expect out of the box anyway. |
Interesting module. I'd suggest |
Not sure about your last example ( I'd almost want to see something more from this. Being able to hook or filter would be awesome. const std = hookStd();
std.on('out', str => str.replace(/\n/g, '\n\t'));
std.on('err', str => str.replace(/\n/g, '\n!!\t'));
// or more practically
import chalk from chalk;
std.on('err', str => chalk.bright.red(str));
std.get('out'); // original output contents
std.get('err'); // original output contents
// same could be applied to 'in' but I couldn't think of an example off the top of my head. Maybe it could also hook |
👍
Typo. Fixed.
Why events? You can already do this with
Is |
Do you see this as primarily a test tool? If so, would it be valuable to provide convenience methods for accessing individual calls / lines? // this would be one call but two lines
process.stdout.write('foo\nbar') |
@jamestalmage Yeah, was thinking about that. Could be an option. ? |
👍 |
Hooks are usually pretty event driven, and events are a good way to break up similar functionality with different inputs, optionally. I might want to subscribe to just stderr. How would I do that with a simple constructor?
Yes; Pretty sure libuv abstracts this on windows (and I wouldn't be surprised if windows does work like that, given the C standard and whatnot). Other fd's are pretty uncommon to use via output methods. Technically you could do this: (echo "require('fs').createReadStream(null, {fd:3}).pipe(process.stdout);" | node) 3<<< "hello, world" |
But your example won't work with events as events are async and can't take a return value. So modifying the output like you're doing in your example wouldn't work.
See how I already solve it. Main export for both. Sub-prop for specific stream.
They might, but I've honestly never seen this used and I don't think I want to bother adding support for it until there's demand. |
Derp, you're right.
That doesn't seem intuitive to me, IMO, but I can't think of a better solution.
It's proper FD stuff. It'd be super complete if you did. For giggles, I wondered if writing to It doesn't. fd So it's up to you if you want to support it. It would be correct functionality, as anything written to |
I guess I could have dropped the main export and done an
I've yet to see anyone use that in Node.js and I don't see why they would when we have a better way. |
Maybe not explicitly, but if you have a FD configuration and you just want to write to standard output instead of a file descriptor for an actual file, you'd just specify But I am just a C programmer in a Javascript programmer's body. 👻 |
Currently you can do the following if you want the output of multiple calls:
Would be nicer if it did this automagically and offered the output somehow.
Maybe like this?
@jamestalmage @sotojuan Thoughts? What should the API look like?
The text was updated successfully, but these errors were encountered: