Comparing version 1.0.9 to 1.0.11
@@ -18,1 +18,3 @@ brotli | ||
https://groups.google.com/forum/#!forum/brotli | ||
[![Build Status](https://travis-ci.org/google/brotli.svg?branch=master)](https://travis-ci.org/google/brotli) |
83
index.js
@@ -28,3 +28,9 @@ 'use strict'; | ||
} | ||
encode.compressAsync(input, params, cb); | ||
var stream = new TransformStreamEncode(params); | ||
var chunks = []; | ||
var length = 0; | ||
stream.on('error', cb); | ||
stream.on('data', function(c) { chunks.push(c); length += c.length; }); | ||
stream.on('end', function() { cb(null, Buffer.concat(chunks, length)); }); | ||
stream.end(input); | ||
} | ||
@@ -41,3 +47,9 @@ | ||
} | ||
decode.decompressAsync(input, cb); | ||
var stream = new TransformStreamDecode(); | ||
var chunks = []; | ||
var length = 0; | ||
stream.on('error', cb); | ||
stream.on('data', function(c) { chunks.push(c); length += c.length; }); | ||
stream.on('end', function() { cb(null, Buffer.concat(chunks, length)); }); | ||
stream.end(input); | ||
} | ||
@@ -49,4 +61,9 @@ | ||
} | ||
params = params || {}; | ||
return encode.compressSync(input, params); | ||
var stream = new TransformStreamEncode(params, true); | ||
var chunks = []; | ||
var length = 0; | ||
stream.on('error', function(e) { throw e; }); | ||
stream.on('data', function(c) { chunks.push(c); length += c.length; }); | ||
stream.end(input); | ||
return Buffer.concat(chunks, length); | ||
} | ||
@@ -58,9 +75,16 @@ | ||
} | ||
return decode.decompressSync(input); | ||
var stream = new TransformStreamDecode({}, true); | ||
var chunks = []; | ||
var length = 0; | ||
stream.on('error', function(e) { throw e; }); | ||
stream.on('data', function(c) { chunks.push(c); length += c.length; }); | ||
stream.end(input); | ||
return Buffer.concat(chunks, length); | ||
} | ||
function TransformStreamEncode(params) { | ||
Transform.call(this); | ||
function TransformStreamEncode(params, sync) { | ||
Transform.call(this, params); | ||
this.encoder = new encode.StreamEncode(params || {}); | ||
this.sync = sync || false; | ||
var blockSize = this.encoder.getBlockSize(); | ||
@@ -75,3 +99,3 @@ this.status = { | ||
TransformStreamEncode.prototype._transform = function(chunk, encoding, next) { | ||
compressStreamChunk(this, chunk, this.encoder, this.status, next); | ||
compressStreamChunk(this, chunk, this.encoder, this.status, this.sync, next); | ||
}; | ||
@@ -86,10 +110,12 @@ | ||
if (output) { | ||
that.push(output); | ||
for (var i = 0; i < output.length; i++) { | ||
that.push(output[i]); | ||
} | ||
} | ||
done(); | ||
}); | ||
}, !this.sync); | ||
}; | ||
// We need to fill the blockSize for better compression results | ||
function compressStreamChunk(stream, chunk, encoder, status, done) { | ||
function compressStreamChunk(stream, chunk, encoder, status, sync, done) { | ||
var length = chunk.length; | ||
@@ -108,6 +134,8 @@ | ||
if (output) { | ||
stream.push(output); | ||
for (var i = 0; i < output.length; i++) { | ||
stream.push(output[i]); | ||
} | ||
} | ||
compressStreamChunk(stream, chunk, encoder, status, done); | ||
}); | ||
compressStreamChunk(stream, chunk, encoder, status, sync, done); | ||
}, !sync); | ||
} else if (length < status.remaining) { | ||
@@ -125,6 +153,8 @@ status.remaining -= length; | ||
if (output) { | ||
stream.push(output); | ||
for (var i = 0; i < output.length; i++) { | ||
stream.push(output[i]); | ||
} | ||
} | ||
done(); | ||
}); | ||
}, !sync); | ||
} | ||
@@ -137,5 +167,6 @@ } | ||
function TransformStreamDecode() { | ||
Transform.call(this); | ||
function TransformStreamDecode(params, sync) { | ||
Transform.call(this, params); | ||
this.sync = sync || false; | ||
this.decoder = new decode.StreamDecode(); | ||
@@ -152,6 +183,8 @@ } | ||
if (output) { | ||
that.push(output); | ||
for (var i = 0; i < output.length; i++) { | ||
that.push(output[i]); | ||
} | ||
} | ||
next(); | ||
}); | ||
}, !this.sync); | ||
}; | ||
@@ -166,10 +199,12 @@ | ||
if (output) { | ||
that.push(output); | ||
for (var i = 0; i < output.length; i++) { | ||
that.push(output[i]); | ||
} | ||
} | ||
done(); | ||
}); | ||
}, !this.sync); | ||
}; | ||
function decompressStream() { | ||
return new TransformStreamDecode(); | ||
function decompressStream(params) { | ||
return new TransformStreamDecode(params); | ||
} |
{ | ||
"name": "iltorb", | ||
"version": "1.0.9", | ||
"version": "1.0.11", | ||
"description": "Brotli compression/decompression with native bindings", | ||
@@ -25,2 +25,3 @@ "homepage": "https://github.com/MayhemYDG/iltorb", | ||
"files": [ | ||
"brotli/common", | ||
"brotli/dec", | ||
@@ -33,3 +34,3 @@ "brotli/enc", | ||
"dependencies": { | ||
"nan": "^2.1.0" | ||
"nan": "^2.3.5" | ||
}, | ||
@@ -36,0 +37,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97
180
2704858
Updatednan@^2.3.5