Skip to content
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

Example code throws 'undefined' #23

Closed
nstansbury opened this issue Aug 7, 2017 · 6 comments
Closed

Example code throws 'undefined' #23

nstansbury opened this issue Aug 7, 2017 · 6 comments

Comments

@nstansbury
Copy link

Running code in examples/data/fake-stream.js with node process_name | tty-table --format=json

Output via console.log(JSON.stringify(array))

Throws undefined

Node v8.1.4

@tecfu
Copy link
Owner

tecfu commented Sep 3, 2017

I'm not quite sure what you're doing here.

node process_name | tty-table --format=json

The above line is a piped command you would run in bash. This will output a table to the CLI, given JSON input from "process_name" that is piped to tty-table in a terminal emulator.

console.log(JSON.stringify(array))

The above line is nodejs code. It wouldn't be used in conjunction with the previous line. In this context, it doesn't make sense...since its nodejs code rather than bash commands.

@tecfu tecfu closed this as completed Sep 3, 2017
@nstansbury
Copy link
Author

So how does my node process send data to stdout to be piped to tty-table, and how does tty-table read data piped to it from the output of my process?

@nstansbury
Copy link
Author

You might like to look at the code in: https://github.com/tecfu/tty-table/blob/master/examples/data/streamer.js

@tecfu
Copy link
Owner

tecfu commented Sep 4, 2017

That streamer example basically just outputs a "stream" of data to STDOUT. You then pipe it to tty-table, which reads it from STDIN. Are you running an example verbatim and finding it doesn't work?

@nstansbury
Copy link
Author

Yep I had realised what it was supposed to do. I have a real-time stream of data I was trying use tty-table to chart, and couldn't get it to work, so I copied and pasted the code from fake-stream into my node process and got the error reported.

@tecfu
Copy link
Owner

tecfu commented Sep 4, 2017

If you run the examples given, do they work?

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

No branches or pull requests

2 participants