Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@
*.exe
*.out
*.app

# Editors
.vscode

# Node Related Folders
build
node_modules
coverage
.nyc_output
9 changes: 3 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
language: node_js
node_js:
- "0.12"
- "4"
- "5"
- "6"
env:
- CXX=g++-4.8
- "8"
- "10"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- g++
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node-zstd [![version](https://img.shields.io/npm/v/node-zstd.svg)](https://www.npmjs.com/package/node-zstd) [![ZSTD/v1.0.0](https://img.shields.io/badge/ZSTD-v1.0.0-green.svg)](https://github.com/facebook/zstd/releases/tag/v1.0.0)
node-zstd [![version](https://img.shields.io/npm/v/node-zstd.svg)](https://www.npmjs.com/package/node-zstd) [![ZSTD/v1.3.4](https://img.shields.io/badge/ZSTD-v1.3.4-green.svg)](https://github.com/facebook/zstd/releases/tag/v1.3.4)
=====

[![Build Status][1]][2]
Expand Down
2 changes: 1 addition & 1 deletion deps/zstd
Submodule zstd updated 409 files
56 changes: 21 additions & 35 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ TransformStreamCompressor.prototype._flush = function(done) {
that.push(output[i]);
}
}
done();
return done();
}, !this.sync);
};

Expand All @@ -153,12 +153,12 @@ function compressStreamChunk(stream, chunk, compressor, status, sync, done) {
stream.push(output[i]);
}
}
compressStreamChunk(stream, chunk, compressor, status, sync, done);
return compressStreamChunk(stream, chunk, compressor, status, sync, done);
}, !sync);
} else if (length <= status.remaining) {
status.remaining -= length;
compressor.copy(chunk);
done();
return done();
}
}

Expand All @@ -183,6 +183,21 @@ TransformStreamDecompressor.prototype._transform = function(chunk, encoding, nex
decompressStreamChunk(this, chunk, this.decompressor, this.status, this.sync, next);
};

TransformStreamDecompressor.prototype._flush = function(done) {
var that = this;
this.decompressor.decompress(function(err, output) {
if (err) {
return done(err);
}
if (output) {
for (var i = 0; i < output.length; i++) {
that.push(output[i]);
}
}
return done();
}, !this.sync);
};

// We need to fill the blockSize for better compression results
function decompressStreamChunk(stream, chunk, decompressor, status, sync, done) {
var length = chunk.length;
Expand All @@ -202,44 +217,15 @@ function decompressStreamChunk(stream, chunk, decompressor, status, sync, done)
stream.push(output[i]);
}
}
decompressStreamChunk(stream, chunk, decompressor, status, sync, done);
return decompressStreamChunk(stream, chunk, decompressor, status, sync, done);
}, !sync);
} else if (length < status.remaining) {
} else if (length <= status.remaining) {
status.remaining -= length;
decompressor.copy(chunk);
done();
} else { // length === status.remaining
status.remaining = status.blockSize;
decompressor.copy(chunk);
decompressor.decompress(function(err, output) {
if (err) {
return done(err);
}
if (output) {
for (var i = 0; i < output.length; i++) {
stream.push(output[i]);
}
}
done();
}, !sync);
return done();
}
}

TransformStreamDecompressor.prototype._flush = function(done) {
var that = this;
this.decompressor.decompress(function(err, output) {
if (err) {
return done(err);
}
if (output) {
for (var i = 0; i < output.length; i++) {
that.push(output[i]);
}
}
done();
}, !this.sync);
};

function decompressStream(params) {
return new TransformStreamDecompressor(params);
}
Loading