You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
long story(about how I discovered this) short, this is the test code:
console.log(process.version);
var cipher = require("crypto").createCipher("rc4", "1111");
cipher.on("readable", function(){
var r = cipher.read(2);
if(r == null){
console.log("readable: no enough data to read");
}else{
console.log("readable: r.length = " + r.length);
}
});
cipher.on("end", function(){
console.log("end");
});
cipher.write("11");
cipher.write("1");
setTimeout(function(){
console.log("firing end");
cipher.end();
}, 1000);
the output is:
v0.12.0
readable: r.length = 2
readable: no enough data to read
firing end
readable: r.length = 1
end
according to the document, when Stream.read is call with size, "If size bytes are not available, then it will return null." but clearly when readable is triggered by end it will disregard the size parameter.
I don't know if this is Cipher only or all Stream behaves like this, I just don't know any more built-in read/writable stream class.
if this is by design, please update the documentation.
The text was updated successfully, but these errors were encountered:
If you pass in a size argument, then it will return that many
bytes. If size bytes are not available, then it will return null,
unless we've ended, in which case it will return the data remaining
in the buffer.
I believe this has been backported to v0.12, so I'll close this for now.
long story(about how I discovered this) short, this is the test code:
the output is:
according to the document, when Stream.read is call with size, "If size bytes are not available, then it will return null." but clearly when readable is triggered by end it will disregard the size parameter.
I don't know if this is Cipher only or all Stream behaves like this, I just don't know any more built-in read/writable stream class.
if this is by design, please update the documentation.
The text was updated successfully, but these errors were encountered: