diff --git a/.gitignore b/.gitignore index 4581ef2..7315843 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,12 @@ *.exe *.out *.app + +# Editors +.vscode + +# Node Related Folders +build +node_modules +coverage +.nyc_output \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index b2b65dd..e04a361 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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++ diff --git a/README.md b/README.md index 3a8fed2..f5a4e1a 100644 --- a/README.md +++ b/README.md @@ -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] diff --git a/deps/zstd b/deps/zstd index 38816f9..2555975 160000 --- a/deps/zstd +++ b/deps/zstd @@ -1 +1 @@ -Subproject commit 38816f93ff151de020e78dde24f6317e9dfb3ed5 +Subproject commit 255597502c3a4ef150abc964e376d4202a8c2929 diff --git a/index.js b/index.js index 9022396..c411411 100644 --- a/index.js +++ b/index.js @@ -130,7 +130,7 @@ TransformStreamCompressor.prototype._flush = function(done) { that.push(output[i]); } } - done(); + return done(); }, !this.sync); }; @@ -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(); } } @@ -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; @@ -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); } diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..c07d563 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1453 @@ +{ + "name": "node-zstd", + "version": "2.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/code-frame": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.51.tgz", + "integrity": "sha1-vXHZsZKvl435FYKdOdQJRFZDmgw=", + "requires": { + "@babel/highlight": "7.0.0-beta.51" + } + }, + "@babel/generator": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.0.0-beta.51.tgz", + "integrity": "sha1-bHV1/952HQdIXgS67cA5LG2eMPY=", + "requires": { + "@babel/types": "7.0.0-beta.51", + "jsesc": "^2.5.1", + "lodash": "^4.17.5", + "source-map": "^0.5.0", + "trim-right": "^1.0.1" + } + }, + "@babel/helper-function-name": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.51.tgz", + "integrity": "sha1-IbSHSiJ8+Z7K/MMKkDAtpaJkBWE=", + "requires": { + "@babel/helper-get-function-arity": "7.0.0-beta.51", + "@babel/template": "7.0.0-beta.51", + "@babel/types": "7.0.0-beta.51" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.51.tgz", + "integrity": "sha1-MoGy0EWvlcFyzpGyCCXYXqRnZBE=", + "requires": { + "@babel/types": "7.0.0-beta.51" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.51.tgz", + "integrity": "sha1-imw/ZsTSZTUvwHdIT59ugKUauXg=", + "requires": { + "@babel/types": "7.0.0-beta.51" + } + }, + "@babel/highlight": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.51.tgz", + "integrity": "sha1-6IRK4loVlcz9QriWI7Q3bKBtIl0=", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^3.0.0" + } + }, + "@babel/parser": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.0.0-beta.51.tgz", + "integrity": "sha1-J87C30Cd9gr1gnDtj2qlVAnqhvY=" + }, + "@babel/template": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.0.0-beta.51.tgz", + "integrity": "sha1-lgKkCuvPNXrpZ34lMu9fyBD1+/8=", + "requires": { + "@babel/code-frame": "7.0.0-beta.51", + "@babel/parser": "7.0.0-beta.51", + "@babel/types": "7.0.0-beta.51", + "lodash": "^4.17.5" + } + }, + "@babel/traverse": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.0.0-beta.51.tgz", + "integrity": "sha1-mB2vLOw0emIx06odnhgDsDqqpKg=", + "requires": { + "@babel/code-frame": "7.0.0-beta.51", + "@babel/generator": "7.0.0-beta.51", + "@babel/helper-function-name": "7.0.0-beta.51", + "@babel/helper-split-export-declaration": "7.0.0-beta.51", + "@babel/parser": "7.0.0-beta.51", + "@babel/types": "7.0.0-beta.51", + "debug": "^3.1.0", + "globals": "^11.1.0", + "invariant": "^2.2.0", + "lodash": "^4.17.5" + } + }, + "@babel/types": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.0.0-beta.51.tgz", + "integrity": "sha1-2AK3tUO1g2x3iqaReXq/APPZfqk=", + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.5", + "to-fast-properties": "^2.0.0" + } + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "bindings": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz", + "integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "chai": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", + "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", + "dev": true, + "requires": { + "assertion-error": "^1.0.1", + "check-error": "^1.0.1", + "deep-eql": "^3.0.0", + "get-func-name": "^2.0.0", + "pathval": "^1.0.0", + "type-detect": "^4.0.0" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.15.1", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "globals": { + "version": "11.7.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.7.0.tgz", + "integrity": "sha512-K8BNSPySfeShBQXsahYB/AbbWruVOTyVpgoIDnl8odPpeSfP2J5QO2oLFFdl2j7GfDCtZj2bMKar2T49itTPCg==" + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "invariant": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", + "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "requires": { + "loose-envify": "^1.0.0" + } + }, + "istanbul-lib-coverage": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", + "integrity": "sha512-nPvSZsVlbG9aLhZYaC3Oi1gT/tpyo3Yt5fNyf6NmcKIayz4VV/txxJFFKAK/gU4dcNn8ehsanBbVHVl0+amOLA==" + }, + "istanbul-lib-instrument": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-2.3.2.tgz", + "integrity": "sha512-l7TD/VnBsIB2OJvSyxaLW/ab1+92dxZNH9wLH7uHPPioy3JZ8tnx2UXUdKmdkgmP2EFPzg64CToUP6dAS3U32Q==", + "requires": { + "@babel/generator": "7.0.0-beta.51", + "@babel/parser": "7.0.0-beta.51", + "@babel/template": "7.0.0-beta.51", + "@babel/traverse": "7.0.0-beta.51", + "@babel/types": "7.0.0-beta.51", + "istanbul-lib-coverage": "^2.0.1", + "semver": "^5.5.0" + } + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" + }, + "jsesc": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.1.tgz", + "integrity": "sha1-5CGiqOINawgZ3yiQj3glJrlt0f4=" + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "nan": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.0.tgz", + "integrity": "sha512-F4miItu2rGnV2ySkXOQoA8FKz/SR2Q2sWP0sbTxNxz/tuokeC8WxOhPMcwi0qIyGtVn/rrSeLbvVkznqCdwYnw==" + }, + "nyc": { + "version": "13.0.1", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-13.0.1.tgz", + "integrity": "sha512-Op/bjhEF74IMtzMmgYt+ModTeMHoPZzHe4qseUguPBwg5qC6r4rYMBt1L3yRXQIbjUpEqmn24/1xAC/umQGU7w==", + "requires": { + "archy": "^1.0.0", + "arrify": "^1.0.1", + "caching-transform": "^2.0.0", + "convert-source-map": "^1.5.1", + "debug-log": "^1.0.1", + "find-cache-dir": "^2.0.0", + "find-up": "^3.0.0", + "foreground-child": "^1.5.6", + "glob": "^7.1.2", + "istanbul-lib-coverage": "^2.0.1", + "istanbul-lib-hook": "^2.0.1", + "istanbul-lib-instrument": "^2.3.2", + "istanbul-lib-report": "^2.0.1", + "istanbul-lib-source-maps": "^2.0.1", + "istanbul-reports": "^2.0.0", + "make-dir": "^1.3.0", + "merge-source-map": "^1.1.0", + "resolve-from": "^4.0.0", + "rimraf": "^2.6.2", + "signal-exit": "^3.0.2", + "spawn-wrap": "^1.4.2", + "test-exclude": "^5.0.0", + "uuid": "^3.3.2", + "yargs": "11.1.0", + "yargs-parser": "^9.0.2" + }, + "dependencies": { + "align-text": { + "version": "0.1.4", + "bundled": true, + "requires": { + "kind-of": "^3.0.2", + "longest": "^1.0.1", + "repeat-string": "^1.5.2" + } + }, + "amdefine": { + "version": "1.0.1", + "bundled": true + }, + "ansi-regex": { + "version": "3.0.0", + "bundled": true + }, + "append-transform": { + "version": "1.0.0", + "bundled": true, + "requires": { + "default-require-extensions": "^2.0.0" + } + }, + "archy": { + "version": "1.0.0", + "bundled": true + }, + "arrify": { + "version": "1.0.1", + "bundled": true + }, + "async": { + "version": "1.5.2", + "bundled": true + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "bundled": true + }, + "caching-transform": { + "version": "2.0.0", + "bundled": true, + "requires": { + "make-dir": "^1.0.0", + "md5-hex": "^2.0.0", + "package-hash": "^2.0.0", + "write-file-atomic": "^2.0.0" + } + }, + "camelcase": { + "version": "1.2.1", + "bundled": true, + "optional": true + }, + "center-align": { + "version": "0.1.3", + "bundled": true, + "optional": true, + "requires": { + "align-text": "^0.1.3", + "lazy-cache": "^1.0.3" + } + }, + "cliui": { + "version": "2.1.0", + "bundled": true, + "optional": true, + "requires": { + "center-align": "^0.1.1", + "right-align": "^0.1.1", + "wordwrap": "0.0.2" + }, + "dependencies": { + "wordwrap": { + "version": "0.0.2", + "bundled": true, + "optional": true + } + } + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true + }, + "commondir": { + "version": "1.0.1", + "bundled": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true + }, + "convert-source-map": { + "version": "1.5.1", + "bundled": true + }, + "cross-spawn": { + "version": "4.0.2", + "bundled": true, + "requires": { + "lru-cache": "^4.0.1", + "which": "^1.2.9" + } + }, + "debug": { + "version": "3.1.0", + "bundled": true, + "requires": { + "ms": "2.0.0" + } + }, + "debug-log": { + "version": "1.0.1", + "bundled": true + }, + "decamelize": { + "version": "1.2.0", + "bundled": true + }, + "default-require-extensions": { + "version": "2.0.0", + "bundled": true, + "requires": { + "strip-bom": "^3.0.0" + } + }, + "error-ex": { + "version": "1.3.2", + "bundled": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es6-error": { + "version": "4.1.1", + "bundled": true + }, + "execa": { + "version": "0.7.0", + "bundled": true, + "requires": { + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + }, + "dependencies": { + "cross-spawn": { + "version": "5.1.0", + "bundled": true, + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + } + } + }, + "find-cache-dir": { + "version": "2.0.0", + "bundled": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^1.0.0", + "pkg-dir": "^3.0.0" + } + }, + "find-up": { + "version": "3.0.0", + "bundled": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "foreground-child": { + "version": "1.5.6", + "bundled": true, + "requires": { + "cross-spawn": "^4", + "signal-exit": "^3.0.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true + }, + "get-caller-file": { + "version": "1.0.3", + "bundled": true + }, + "get-stream": { + "version": "3.0.0", + "bundled": true + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.1.11", + "bundled": true + }, + "handlebars": { + "version": "4.0.11", + "bundled": true, + "requires": { + "async": "^1.4.0", + "optimist": "^0.6.1", + "source-map": "^0.4.4", + "uglify-js": "^2.6" + }, + "dependencies": { + "source-map": { + "version": "0.4.4", + "bundled": true, + "requires": { + "amdefine": ">=0.0.4" + } + } + } + }, + "has-flag": { + "version": "3.0.0", + "bundled": true + }, + "hosted-git-info": { + "version": "2.7.1", + "bundled": true + }, + "imurmurhash": { + "version": "0.1.4", + "bundled": true + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true + }, + "invert-kv": { + "version": "1.0.0", + "bundled": true + }, + "is-arrayish": { + "version": "0.2.1", + "bundled": true + }, + "is-buffer": { + "version": "1.1.6", + "bundled": true + }, + "is-builtin-module": { + "version": "1.0.0", + "bundled": true, + "requires": { + "builtin-modules": "^1.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "bundled": true + }, + "is-stream": { + "version": "1.1.0", + "bundled": true + }, + "isexe": { + "version": "2.0.0", + "bundled": true + }, + "istanbul-lib-coverage": { + "version": "2.0.1", + "bundled": true + }, + "istanbul-lib-hook": { + "version": "2.0.1", + "bundled": true, + "requires": { + "append-transform": "^1.0.0" + } + }, + "istanbul-lib-report": { + "version": "2.0.1", + "bundled": true, + "requires": { + "istanbul-lib-coverage": "^2.0.1", + "make-dir": "^1.3.0", + "supports-color": "^5.4.0" + } + }, + "istanbul-lib-source-maps": { + "version": "2.0.1", + "bundled": true, + "requires": { + "debug": "^3.1.0", + "istanbul-lib-coverage": "^2.0.1", + "make-dir": "^1.3.0", + "rimraf": "^2.6.2", + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "bundled": true + } + } + }, + "istanbul-reports": { + "version": "2.0.0", + "bundled": true, + "requires": { + "handlebars": "^4.0.11" + } + }, + "json-parse-better-errors": { + "version": "1.0.2", + "bundled": true + }, + "kind-of": { + "version": "3.2.2", + "bundled": true, + "requires": { + "is-buffer": "^1.1.5" + } + }, + "lazy-cache": { + "version": "1.0.4", + "bundled": true, + "optional": true + }, + "lcid": { + "version": "1.0.0", + "bundled": true, + "requires": { + "invert-kv": "^1.0.0" + } + }, + "load-json-file": { + "version": "4.0.0", + "bundled": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^4.0.0", + "pify": "^3.0.0", + "strip-bom": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "bundled": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "lodash.flattendeep": { + "version": "4.4.0", + "bundled": true + }, + "longest": { + "version": "1.0.1", + "bundled": true + }, + "lru-cache": { + "version": "4.1.3", + "bundled": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "make-dir": { + "version": "1.3.0", + "bundled": true, + "requires": { + "pify": "^3.0.0" + } + }, + "md5-hex": { + "version": "2.0.0", + "bundled": true, + "requires": { + "md5-o-matic": "^0.1.1" + } + }, + "md5-o-matic": { + "version": "0.1.1", + "bundled": true + }, + "mem": { + "version": "1.1.0", + "bundled": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "merge-source-map": { + "version": "1.1.0", + "bundled": true, + "requires": { + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "bundled": true + } + } + }, + "mimic-fn": { + "version": "1.2.0", + "bundled": true + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.10", + "bundled": true + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "bundled": true + } + } + }, + "ms": { + "version": "2.0.0", + "bundled": true + }, + "normalize-package-data": { + "version": "2.4.0", + "bundled": true, + "requires": { + "hosted-git-info": "^2.1.4", + "is-builtin-module": "^1.0.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "npm-run-path": { + "version": "2.0.2", + "bundled": true, + "requires": { + "path-key": "^2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "requires": { + "wrappy": "1" + } + }, + "optimist": { + "version": "0.6.1", + "bundled": true, + "requires": { + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true + }, + "os-locale": { + "version": "2.1.0", + "bundled": true, + "requires": { + "execa": "^0.7.0", + "lcid": "^1.0.0", + "mem": "^1.1.0" + } + }, + "p-finally": { + "version": "1.0.0", + "bundled": true + }, + "p-limit": { + "version": "2.0.0", + "bundled": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "bundled": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.0.0", + "bundled": true + }, + "package-hash": { + "version": "2.0.0", + "bundled": true, + "requires": { + "graceful-fs": "^4.1.11", + "lodash.flattendeep": "^4.4.0", + "md5-hex": "^2.0.0", + "release-zalgo": "^1.0.0" + } + }, + "parse-json": { + "version": "4.0.0", + "bundled": true, + "requires": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + } + }, + "path-exists": { + "version": "3.0.0", + "bundled": true + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true + }, + "path-key": { + "version": "2.0.1", + "bundled": true + }, + "path-type": { + "version": "3.0.0", + "bundled": true, + "requires": { + "pify": "^3.0.0" + } + }, + "pify": { + "version": "3.0.0", + "bundled": true + }, + "pkg-dir": { + "version": "3.0.0", + "bundled": true, + "requires": { + "find-up": "^3.0.0" + } + }, + "pseudomap": { + "version": "1.0.2", + "bundled": true + }, + "read-pkg": { + "version": "3.0.0", + "bundled": true, + "requires": { + "load-json-file": "^4.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^3.0.0" + } + }, + "read-pkg-up": { + "version": "4.0.0", + "bundled": true, + "requires": { + "find-up": "^3.0.0", + "read-pkg": "^3.0.0" + } + }, + "release-zalgo": { + "version": "1.0.0", + "bundled": true, + "requires": { + "es6-error": "^4.0.1" + } + }, + "repeat-string": { + "version": "1.6.1", + "bundled": true + }, + "require-directory": { + "version": "2.1.1", + "bundled": true + }, + "require-main-filename": { + "version": "1.0.1", + "bundled": true + }, + "resolve-from": { + "version": "4.0.0", + "bundled": true + }, + "right-align": { + "version": "0.1.3", + "bundled": true, + "optional": true, + "requires": { + "align-text": "^0.1.1" + } + }, + "rimraf": { + "version": "2.6.2", + "bundled": true, + "requires": { + "glob": "^7.0.5" + } + }, + "semver": { + "version": "5.5.0", + "bundled": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true + }, + "shebang-command": { + "version": "1.2.0", + "bundled": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "bundled": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true + }, + "source-map": { + "version": "0.5.7", + "bundled": true, + "optional": true + }, + "spawn-wrap": { + "version": "1.4.2", + "bundled": true, + "requires": { + "foreground-child": "^1.5.6", + "mkdirp": "^0.5.0", + "os-homedir": "^1.0.1", + "rimraf": "^2.6.2", + "signal-exit": "^3.0.2", + "which": "^1.3.0" + } + }, + "spdx-correct": { + "version": "3.0.0", + "bundled": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.1.0", + "bundled": true + }, + "spdx-expression-parse": { + "version": "3.0.0", + "bundled": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.0", + "bundled": true + }, + "string-width": { + "version": "2.1.1", + "bundled": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "bundled": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "bundled": true + }, + "strip-eof": { + "version": "1.0.0", + "bundled": true + }, + "supports-color": { + "version": "5.4.0", + "bundled": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "test-exclude": { + "version": "5.0.0", + "bundled": true, + "requires": { + "arrify": "^1.0.1", + "minimatch": "^3.0.4", + "read-pkg-up": "^4.0.0", + "require-main-filename": "^1.0.1" + } + }, + "uglify-js": { + "version": "2.8.29", + "bundled": true, + "optional": true, + "requires": { + "source-map": "~0.5.1", + "uglify-to-browserify": "~1.0.0", + "yargs": "~3.10.0" + }, + "dependencies": { + "yargs": { + "version": "3.10.0", + "bundled": true, + "optional": true, + "requires": { + "camelcase": "^1.0.2", + "cliui": "^2.1.0", + "decamelize": "^1.0.0", + "window-size": "0.1.0" + } + } + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "bundled": true, + "optional": true + }, + "uuid": { + "version": "3.3.2", + "bundled": true + }, + "validate-npm-package-license": { + "version": "3.0.3", + "bundled": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "which": { + "version": "1.3.1", + "bundled": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "bundled": true + }, + "window-size": { + "version": "0.1.0", + "bundled": true, + "optional": true + }, + "wordwrap": { + "version": "0.0.3", + "bundled": true + }, + "wrap-ansi": { + "version": "2.1.0", + "bundled": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "bundled": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true + }, + "write-file-atomic": { + "version": "2.3.0", + "bundled": true, + "requires": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + }, + "y18n": { + "version": "3.2.1", + "bundled": true + }, + "yallist": { + "version": "2.1.2", + "bundled": true + }, + "yargs": { + "version": "11.1.0", + "bundled": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^1.1.1", + "find-up": "^2.1.0", + "get-caller-file": "^1.0.1", + "os-locale": "^2.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1", + "yargs-parser": "^9.0.2" + }, + "dependencies": { + "cliui": { + "version": "4.1.0", + "bundled": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" + } + }, + "find-up": { + "version": "2.1.0", + "bundled": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "bundled": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "1.3.0", + "bundled": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "bundled": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "bundled": true + } + } + }, + "yargs-parser": { + "version": "9.0.2", + "bundled": true, + "requires": { + "camelcase": "^4.1.0" + }, + "dependencies": { + "camelcase": { + "version": "4.1.0", + "bundled": true + } + } + } + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "segfault-handler": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/segfault-handler/-/segfault-handler-1.0.1.tgz", + "integrity": "sha512-3koBV3F0IPxTYacnoL7WoFlaMndXsXj62tiVbbW9Kzp3K+F9Y6GWW5XmKSv7j+7nf2M+qjNzc4W1iZoa8vocjw==", + "requires": { + "bindings": "^1.2.1", + "nan": "^2.0.9" + } + }, + "semver": { + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz", + "integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==" + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" + }, + "trim-right": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", + "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=" + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } +} diff --git a/package.json b/package.json index cc939a1..b2043b1 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,12 @@ "description": "Zstd wrapper for Nodejs", "main": "index.js", "scripts": { - "test": "mocha" + "test": "mocha -t 5000", + "build:dev": "node-gyp -j 16 build --debug", + "build": "node-gyp -j 16 build", + "rebuild:dev": "node-gyp -j 16 rebuild --debug", + "rebuild": "node-gyp -j 16 rebuild", + "clean": "node-gyp clean" }, "repository": { "type": "git", @@ -16,6 +21,13 @@ "decompression" ], "author": "zwb-ict", + "contributors": [ + { + "name": "Tyler Stiene", + "email": "tystiene@gmail.com", + "url": "https://github.com/Stieneee" + } + ], "license": "MIT", "bugs": { "url": "https://github.com/zwb-ict/node-zstd/issues" @@ -23,10 +35,12 @@ "homepage": "https://github.com/zwb-ict/node-zstd#readme", "dependencies": { "bindings": "^1.2.1", - "nan": "^2.4.0" + "nan": "^2.4.0", + "nyc": "^13.0.1", + "segfault-handler": "^1.0.1" }, "devDependencies": { - "chai": "^3.5.0", - "mocha": "^3.1.0" + "chai": "^4.1.2", + "mocha": "^5.2.0" } } diff --git a/src/compress/stream_compress_worker.cc b/src/compress/stream_compress_worker.cc index 42b46eb..ef2e675 100644 --- a/src/compress/stream_compress_worker.cc +++ b/src/compress/stream_compress_worker.cc @@ -12,15 +12,11 @@ namespace ZSTD_NODE { StreamCompressWorker::StreamCompressWorker(Callback *callback, StreamCompressor* sc, bool isLast) : AsyncWorker(callback), sc(sc), isLast(isLast) { - zInBuf = {sc->input, sc->pos, 0}; - size_t dstSize = ZSTD_CStreamOutSize(); - void *dst = sc->alloc.Alloc(dstSize); - zOutBuf = {dst, dstSize, 0}; + zInBuf = {sc->input, sc->inPos, 0}; + zOutBuf = {sc->dst, sc->dstSize, 0}; } - StreamCompressWorker::~StreamCompressWorker() { - sc->alloc.Free(zOutBuf.dst); - } + StreamCompressWorker::~StreamCompressWorker() {} void StreamCompressWorker::Execute() { while (zInBuf.pos < zInBuf.size) { @@ -64,7 +60,7 @@ namespace ZSTD_NODE { Nan::Null(), sc->PendingChunksAsArray() }; - callback->Call(argc, argv); + callback->Call(argc, argv, async_resource); sc->alloc.ReportMemoryToV8(); } @@ -76,7 +72,7 @@ namespace ZSTD_NODE { Local argv[argc] = { Error(Nan::New(ErrorMessage()).ToLocalChecked()) }; - callback->Call(argc, argv); + callback->Call(argc, argv, async_resource); sc->alloc.ReportMemoryToV8(); } diff --git a/src/compress/stream_compressor.cc b/src/compress/stream_compressor.cc index 6baa27d..06cf62c 100644 --- a/src/compress/stream_compressor.cc +++ b/src/compress/stream_compressor.cc @@ -59,7 +59,11 @@ namespace ZSTD_NODE { inputSize = ZSTD_CStreamInSize(); input = alloc.Alloc(inputSize); - pos = 0; + inPos = 0; + + dstSize = ZSTD_CStreamOutSize(); + dst = alloc.Alloc(dstSize); + dstPos = 0; ZSTD_customMem zcm = {Allocator::Alloc, Allocator::Free, &alloc}; zcs = ZSTD_createCStream_advanced(zcm); @@ -78,22 +82,19 @@ namespace ZSTD_NODE { if (input != NULL) { alloc.Free(input); } + if (dst != NULL) { + alloc.Free(dst); + } ZSTD_freeCStream(zcs); } NAN_METHOD(StreamCompressor::New) { - if (info.IsConstructCall()) { - StreamCompressor *sc = new StreamCompressor(info[0]->ToObject()); - sc->Wrap(info.This()); - info.GetReturnValue().Set(info.This()); - } else { - const int argc = 1; - Local argv[argc] = {info[0]}; - Local cons = Nan::New(constructor()); - // info.GetReturnValue().Set(cons->NewInstance(GetCurrentContext(), - //argc, argv).ToLocalChecked()); - info.GetReturnValue().Set(cons->NewInstance(argc, argv)); + if (!info.IsConstructCall()) { + return Nan::ThrowError("StreamCompressor() must be called as a constructor"); } + StreamCompressor *sc = new StreamCompressor(info[0]->ToObject()); + sc->Wrap(info.This()); + info.GetReturnValue().Set(info.This()); } NAN_METHOD(StreamCompressor::GetBlockSize) { @@ -106,12 +107,12 @@ namespace ZSTD_NODE { char *chunk = Data(chunkBuf); size_t chunkSize = Length(chunkBuf); if (chunkSize != 0) { - if (sc->pos == sc->inputSize) { - sc->pos = 0; + if (sc->inPos == sc->inputSize) { + sc->inPos = 0; } - char *pos = static_cast(sc->input) + sc->pos; + char *pos = static_cast(sc->input) + sc->inPos; memcpy(pos, chunk, chunkSize); - sc->pos += chunkSize; + sc->inPos += chunkSize; } } @@ -125,7 +126,6 @@ namespace ZSTD_NODE { } else { worker->Execute(); worker->WorkComplete(); - worker->Destroy(); } } diff --git a/src/compress/stream_compressor.h b/src/compress/stream_compressor.h index 30264e6..7991bbe 100644 --- a/src/compress/stream_compressor.h +++ b/src/compress/stream_compressor.h @@ -32,9 +32,15 @@ namespace ZSTD_NODE { static inline Persistent& constructor(); ZSTD_CStream *zcs; + size_t inputSize; - size_t pos; + size_t dstSize; + + size_t inPos; + size_t dstPos; + void *input; + void *dst; void *dict; }; diff --git a/src/decompress/stream_decompress_worker.cc b/src/decompress/stream_decompress_worker.cc index 332eac8..c0e71c0 100644 --- a/src/decompress/stream_decompress_worker.cc +++ b/src/decompress/stream_decompress_worker.cc @@ -12,27 +12,21 @@ namespace ZSTD_NODE { StreamDecompressWorker::StreamDecompressWorker(Callback *callback, StreamDecompressor* sd) : AsyncWorker(callback), sd(sd) { - zInBuf = {sd->input, sd->pos, 0}; - size_t dstSize = ZSTD_DStreamOutSize(); - void *dst = sd->alloc.Alloc(dstSize); - zOutBuf = {dst, dstSize, 0}; + zInBuf = {sd->input, sd->inPos, 0}; + zOutBuf = {sd->dst, sd->dstSize, 0}; } - StreamDecompressWorker::~StreamDecompressWorker() { - sd->alloc.Free(zOutBuf.dst); - } + StreamDecompressWorker::~StreamDecompressWorker() {} void StreamDecompressWorker::Execute() { while (zInBuf.pos < zInBuf.size) { - do { - zOutBuf.pos = 0; - ret = ZSTD_decompressStream(sd->zds, &zOutBuf, &zInBuf); - if (ZSTD_isError(ret)) { - SetErrorMessage(ZSTD_getErrorName(ret)); - return; - } - pushToPendingOutput(); - } while (ret == 1); + zOutBuf.pos = 0; + ret = ZSTD_decompressStream(sd->zds, &zOutBuf, &zInBuf); + if (ZSTD_isError(ret)) { + SetErrorMessage(ZSTD_getErrorName(ret)); + return; + } + pushToPendingOutput(); } } @@ -56,7 +50,7 @@ namespace ZSTD_NODE { Nan::Null(), sd->PendingChunksAsArray() }; - callback->Call(argc, argv); + callback->Call(argc, argv, async_resource); sd->alloc.ReportMemoryToV8(); } @@ -68,7 +62,7 @@ namespace ZSTD_NODE { Local argv[argc] = { Error(Nan::New(ErrorMessage()).ToLocalChecked()) }; - callback->Call(argc, argv); + callback->Call(argc, argv, async_resource); sd->alloc.ReportMemoryToV8(); } diff --git a/src/decompress/stream_decompress_worker.h b/src/decompress/stream_decompress_worker.h index d2885fd..018402a 100644 --- a/src/decompress/stream_decompress_worker.h +++ b/src/decompress/stream_decompress_worker.h @@ -24,6 +24,7 @@ namespace ZSTD_NODE { StreamDecompressor *sd; ZSTD_outBuffer zOutBuf; ZSTD_inBuffer zInBuf; + size_t ret; }; diff --git a/src/decompress/stream_decompressor.cc b/src/decompress/stream_decompressor.cc index dd68e58..d72066d 100644 --- a/src/decompress/stream_decompressor.cc +++ b/src/decompress/stream_decompressor.cc @@ -54,7 +54,11 @@ namespace ZSTD_NODE { inputSize = ZSTD_DStreamInSize(); input = alloc.Alloc(inputSize); - pos = 0; + inPos = 0; + + dstSize = ZSTD_DStreamOutSize(); + dst = alloc.Alloc(dstSize); + dstPos = 0; ZSTD_customMem zcm = {Allocator::Alloc, Allocator::Free, &alloc}; zds = ZSTD_createDStream_advanced(zcm); @@ -73,22 +77,19 @@ namespace ZSTD_NODE { if (input != NULL) { alloc.Free(input); } + if (dst != NULL) { + alloc.Free(dst); + } ZSTD_freeDStream(zds); } NAN_METHOD(StreamDecompressor::New) { - if (info.IsConstructCall()) { - StreamDecompressor *sd = new StreamDecompressor(info[0]->ToObject()); - sd->Wrap(info.This()); - info.GetReturnValue().Set(info.This()); - } else { - const int argc = 1; - Local argv[argc] = {info[0]}; - Local cons = Nan::New(constructor()); - // info.GetReturnValue().Set(cons->NewInstance(GetCurrentContext(), - // argc, argv).ToLocalChecked()); - info.GetReturnValue().Set(cons->NewInstance(argc, argv)); + if (!info.IsConstructCall()) { + return Nan::ThrowError("StreamDecompressor() must be called as a constructor"); } + StreamDecompressor *sd = new StreamDecompressor(info[0]->ToObject()); + sd->Wrap(info.This()); + info.GetReturnValue().Set(info.This()); } NAN_METHOD(StreamDecompressor::GetBlockSize) { @@ -101,12 +102,12 @@ namespace ZSTD_NODE { char *chunk = Data(chunkBuf); size_t chunkSize = Length(chunkBuf); if (chunkSize != 0) { - if (sd->pos == sd->inputSize) { - sd->pos = 0; + if (sd->inPos == sd->inputSize) { + sd->inPos = 0; } - char *pos = static_cast(sd->input) + sd->pos; + char *pos = static_cast(sd->input) + sd->inPos; memcpy(pos, chunk, chunkSize); - sd->pos += chunkSize; + sd->inPos += chunkSize; } } @@ -120,7 +121,6 @@ namespace ZSTD_NODE { } else { worker->Execute(); worker->WorkComplete(); - worker->Destroy(); } } diff --git a/src/decompress/stream_decompressor.h b/src/decompress/stream_decompressor.h index 1a965dc..3fe9d2e 100644 --- a/src/decompress/stream_decompressor.h +++ b/src/decompress/stream_decompressor.h @@ -32,9 +32,15 @@ namespace ZSTD_NODE { static inline Persistent& constructor(); ZSTD_DStream *zds; + size_t inputSize; - size_t pos; + size_t dstSize; + + size_t inPos; + size_t dstPos; + void *input; + void *dst; void *dict; }; diff --git a/test/zstdBufferAsync.js b/test/zstdBufferAsync.js index 7001aa3..3c20036 100644 --- a/test/zstdBufferAsync.js +++ b/test/zstdBufferAsync.js @@ -44,7 +44,7 @@ describe('ZSTD Buffer Async', function() { }); it('should compress text data with dict=(new Buffer("hello zstd"))', function(done) { - testBufferAsync(zstd.compress, 'data.txt', 'data.txt.zst.09.dict', done, {level: 9, dict: new Buffer("hello zstd")}); + testBufferAsync(zstd.compress, 'data.txt', 'data.txt.zst.09.dict', done, {level: 9, dict: Buffer.from("hello zstd")}); }); it('should compress an empty buffer', function(done) { @@ -66,8 +66,8 @@ describe('ZSTD Buffer Async', function() { testBufferAsync(zstd.decompress, 'data.txt.zst', 'data.txt', done); }); - it('should decompress text data with dict=(new Buffer("hello zstd"))', function() { - testBufferAsync(zstd.decompress, 'data.txt.zst.09.dict', 'data.txt', {level: 9, dict: new Buffer("hello zstd")}); + it('should decompress text data with dict=(new Buffer("hello zstd"))', function(done) { + testBufferAsync(zstd.decompress, 'data.txt.zst.09.dict', 'data.txt', done, {level: 9, dict: Buffer.from("hello zstd")}); }); it('should decompress to an empty buffer', function(done) { diff --git a/test/zstdBufferSync.js b/test/zstdBufferSync.js index 2a5607a..1b1e0fd 100644 --- a/test/zstdBufferSync.js +++ b/test/zstdBufferSync.js @@ -32,7 +32,7 @@ describe('ZSTD Buffer Sync', function() { }); it('should compress text data with dict=(new Buffer("hello zstd"))', function() { - testBufferSync(zstd.compressSync, 'data.txt', 'data.txt.zst.09.dict', {level: 9, dict: new Buffer("hello zstd")}); + testBufferSync(zstd.compressSync, 'data.txt', 'data.txt.zst.09.dict', {level: 9, dict: Buffer.from("hello zstd")}); }); it('should compress an empty buffer', function() { @@ -40,7 +40,6 @@ describe('ZSTD Buffer Sync', function() { }); it('should compress a large buffer', function() { - this.timeout(30000); testBufferSync(zstd.compressSync, 'large.txt', 'large.txt.zst'); }); }); @@ -55,7 +54,7 @@ describe('ZSTD Buffer Sync', function() { }); it('should decompress text data with dict=(new Buffer("hello zstd"))', function() { - testBufferSync(zstd.decompressSync, 'data.txt.zst.09.dict', 'data.txt', {level: 9, dict: new Buffer("hello zstd")}); + testBufferSync(zstd.decompressSync, 'data.txt.zst.09.dict', 'data.txt', {level: 9, dict: Buffer.from("hello zstd")}); }); it('should decompress to an empty buffer', function() { diff --git a/test/zstdStream.js b/test/zstdStream.js index d11d523..cb45dd9 100644 --- a/test/zstdStream.js +++ b/test/zstdStream.js @@ -9,7 +9,7 @@ var path = require('path'); function BufferWriter() { Writable.call(this); - this.data = new Buffer(0); + this.data = Buffer.alloc(0); } util.inherits(BufferWriter, Writable); @@ -51,7 +51,7 @@ describe('ZSTD Stream', function() { }); it('should compress text data with dict=(new Buffer("hello zstd"))', function(done) { - testStream(zstd.compressStream, 'data.txt', 'data.txt.zst.09.dict', done, {level: 9, dict: new Buffer("hello zstd")}); + testStream(zstd.compressStream, 'data.txt', 'data.txt.zst.09.dict', done, {level: 9, dict: Buffer.from("hello zstd")}); }); it('should compress an empty buffer', function(done) { @@ -73,8 +73,8 @@ describe('ZSTD Stream', function() { testStream(zstd.decompressStream, 'data.txt.zst', 'data.txt', done); }); - it('should decompress text data with dict=(new Buffer("hello zstd"))', function() { - testStream(zstd.decompressStream, 'data.txt.zst.09.dict', 'data.txt', {level: 9, dict: new Buffer("hello zstd")}); + it('should decompress text data with dict=(new Buffer("hello zstd"))', function(done) { + testStream(zstd.decompressStream, 'data.txt.zst.09.dict', 'data.txt', done, {level: 9, dict: Buffer.from("hello zstd")}); }); it('should decompress to an empty buffer', function(done) {