Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View a.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
 
 
var buf = null;
var offset = 0;
 
 
stream.on('data', function(buf_) {
assert(!buf);
buf = buf_;
stream.emit('readable');
stream.pause();
});
 
 
stream.read = function(n) {
if (!buf)
return null;
var left = buf.length - offset;
if (left > n) {
rv = buf.slice(offset, offset + n);
offset += n;
} else {
rv = buf.slice(offset, offset + left);
buf = null;
offset = 0;
stream.resume();
}
return buf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.