Skip to content

Instantly share code, notes, and snippets.

@hns
Created June 28, 2010 20:06
Show Gist options
  • Save hns/456286 to your computer and use it in GitHub Desktop.
Save hns/456286 to your computer and use it in GitHub Desktop.
Stream.prototype.forEach = function(callback) {
var length = 8192;
var buffer = new ByteArray(length);
while (true) {
var read = this.readInto(buffer, 0, length);
if (read < 0)
break;
buffer.length = read;
callback(buffer);
buffer.length = length;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment