Created
February 21, 2013 00:57
-
-
Save Raynos/5001063 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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