Created
December 20, 2013 20:02
-
-
Save nlf/8060534 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
Person.extendModel({ | |
all: function () { | |
var stream = new Readable({ objectMode: true }); | |
stream.push({ test: true}); | |
stream.push(null); | |
return stream; | |
} | |
}); |
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
Person.extendModel({ | |
all: function () { | |
var stream = new Readable({ objectMode: true }); | |
var i = 0; | |
var timer = setInterval(function () { | |
if (i < 10) { | |
stream.push({ test: true }); | |
i += 1; | |
} else if (i === 10) { | |
stream.push(null); | |
clearInterval(timer); | |
} | |
}, 100); | |
return stream; | |
} | |
}); |
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
Person.extendModel({ | |
all: function () { | |
var stream = new Readable({ objectMode: true }); | |
var i = 0; | |
stream._read = function () { | |
var timer = setInterval(function () { | |
if (i < 10) { | |
stream.push({ test: true }); | |
i += 1; | |
} else if (i === 10) { | |
stream.push(null); | |
clearInterval(timer); | |
} | |
}, 100); | |
} | |
return stream; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment