mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-04 10:50:59 +01:00
Benchmark update: use modern zlib sync api
This commit is contained in:
parent
a1fc42542a
commit
dfc3b0e2a1
2 changed files with 3 additions and 66 deletions
|
@ -2,38 +2,6 @@
|
|||
|
||||
var zlib = require('zlib');
|
||||
|
||||
exports.async = true;
|
||||
|
||||
exports.run = function(data, level, callback) {
|
||||
//zlib.deflate(new Buffer(data), callback);
|
||||
|
||||
var zlibStream = zlib.createDeflate({
|
||||
/*chunkSize: 128*1024,*/
|
||||
level: level
|
||||
});
|
||||
var buffers = [], nread = 0;
|
||||
|
||||
|
||||
zlibStream.on('error', function(err) {
|
||||
zlibStream.removeAllListeners();
|
||||
zlibStream=null;
|
||||
callback(err);
|
||||
});
|
||||
|
||||
zlibStream.on('data', function(chunk) {
|
||||
buffers.push(chunk);
|
||||
nread += chunk.length;
|
||||
});
|
||||
|
||||
zlibStream.on('end', function() {
|
||||
zlibStream.removeAllListeners();
|
||||
zlibStream=null;
|
||||
|
||||
var buffer = Buffer.concat(buffers);
|
||||
|
||||
callback(null);
|
||||
});
|
||||
|
||||
zlibStream.write(data.buffer);
|
||||
zlibStream.end();
|
||||
zlib.deflateSync(data.buffer, {level:level});
|
||||
}
|
||||
|
|
|
@ -2,37 +2,6 @@
|
|||
|
||||
var zlib = require('zlib');
|
||||
|
||||
exports.async = true;
|
||||
|
||||
exports.run = function(data, level, callback) {
|
||||
//zlib.inflate(data.deflateBuffer, callback);
|
||||
|
||||
var zlibStream = zlib.createInflate({
|
||||
//chunkSize: 128*1024
|
||||
});
|
||||
var buffers = [], nread = 0;
|
||||
|
||||
|
||||
zlibStream.on('error', function(err) {
|
||||
zlibStream.removeAllListeners();
|
||||
zlibStream=null;
|
||||
callback(err);
|
||||
});
|
||||
|
||||
zlibStream.on('data', function(chunk) {
|
||||
buffers.push(chunk);
|
||||
nread += chunk.length;
|
||||
});
|
||||
|
||||
zlibStream.on('end', function() {
|
||||
zlibStream.removeAllListeners();
|
||||
zlibStream=null;
|
||||
|
||||
var buffer = Buffer.concat(buffers);
|
||||
|
||||
callback(null);
|
||||
});
|
||||
|
||||
zlibStream.write(data.deflateBuffer);
|
||||
zlibStream.end();
|
||||
exports.run = function(data) {
|
||||
zlib.inflateSync(data.deflateBuffer);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue