-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(streams): refactor streams and buffer usage #1
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is alright, there’s probably another way to make charm the read part of the duplex but I don’t see any issues doing it this way.
One note is that _final
is only node 8 and above.
I could perhaps have the 1.x version of this new replacement use older streams syntax to be compatible with <=8 and then we could release 2.x with the new class and _final syntax. I linked a local development version of this branch to blessed-contrib and when I run it with the default
Only when I change the Any ideas why this happens? |
@cancerberoSgx tagged you here due to recent activity in blessed-contrib in hope that you might be able to help with the outstanding issue here? |
@lirantal thanks for including me. I'm not familiar with the library or PNG library but it sounds like the stream is not flushed entirely? will try to research when I have more time, thanks again. Cool lib! |
var charm = require("charm"); | ||
var x256 = require("x256"); | ||
|
||
var { Duplex } = require("stream"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should really use readable-stream.
return es.duplex(ws, c); | ||
|
||
this.c.on("end", () => { | ||
this.emit("end"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be this.push(null) to correctly end the stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for jumping in Matteo!
I saw that in the docs as well for a readable stream implementation and had tried this.push(null);
when c
streams ends but that just doesn't draw anything at all.
To add context:
Both variations of this.push(null) and this.emit('end') work well with this picture-tuber branch if you test it out with the CLI util: node bin/tube.js /Users/lirantal/projects/forks/blessed-contrib/examples/media/flower.png
:
The issue is when I use this branch of picture-tuber in blessed-contrib (its used in the picture widget). To re-construct that setup:
cd picture-tuber
git checkout feat/refactor-streams-use
npm link
cd blessed-contrib
npm link picture-tuber
cd examples
node picture.js
Refactoring the original picture-tube code to minimize the use of external modules (
event-stream
,buffers
) and use built-in Streams and Buffers support in Node.jsWould be happy if someone more experienced with terminal emulation and streams could review this. Perhaps you could help @waldyrious, @J-Cat, @reconbot, @larsonjj ?
Context: this is in follow-up of a blessed-contrib change to use a thinner
picture-tube
package with no vulnerabilities: yaronn/blessed-contrib#162