Skip to content

Commit bb88cab

Browse files
committed
apply regex on the whole not on every chunk
1 parent 5bfbe11 commit bb88cab

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tasks/compress_attributes.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ var regexStr = [
3333
var regex = new RegExp(regexStr, 'g');
3434

3535
module.exports = function() {
36-
return through(function(buf, enc, next) {
37-
this.push(
38-
buf.toString('utf-8')
39-
.replace(regex, '')
40-
);
36+
var allChunks = [];
37+
return through(function(chunk, enc, next) {
38+
allChunks.push(chunk);
4139
next();
40+
}, function(done) {
41+
this.push(Buffer.concat(allChunks).toString().replace(regex, ''));
42+
done();
4243
});
4344
};

0 commit comments

Comments
 (0)