Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created February 21, 2013 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynos/5001063 to your computer and use it in GitHub Desktop.
Save Raynos/5001063 to your computer and use it in GitHub Desktop.
var assert = require('assert');
var Readable = require('../../readable');
var common = require('../common');
var r = new Readable({
highWaterMark: 5
});
r._read = function () {}
r.on('readable', function () {
console.log("READABLE?");
});
r.push("1");
r.push("2");
r.push("3");
var v1 = r.push("4");
var v2 = r.push("5");
assert.equal(r._readableState.needReadable, false)
assert.equal(v1, true)
assert.equal(v2, false)
console.log('v1', v1, 'v2', v2)
var chunk = r.read(500)
assert.equal(chunk, null)
var v3 = r.push("6");
// It's false
// How are you supposed to read 500 bytes from a stream with
// a hwm of 5? How is the source supposed to know that someone
// wants you to fill the buffer upto 500 bytes because he wants
// to read 500 bytes??! >:(
assert.equal(v3, true)
var chunk = r.read(500)
assert.equal(chunk, null)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment