Skip to content

Instantly share code, notes, and snippets.

@cjpartridgeb
Created December 18, 2014 02:43
Show Gist options
  • Save cjpartridgeb/a81834c87f134a05af23 to your computer and use it in GitHub Desktop.
Save cjpartridgeb/a81834c87f134a05af23 to your computer and use it in GitHub Desktop.
function maxThrough(max) {
var b=0;
return through2(function(chunk,enc,callback) {
b+=chunk.length;
if(b>max) return callback(new Error('Too many bites!'));
this.push(chunk);
callback();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment