Skip to content

Commit

Permalink
Require Node.js 10 (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
realityking committed Nov 16, 2020
1 parent 5499cd4 commit 211169f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '14'
- '12'
- '10'
- '8'
- '6'
10 changes: 5 additions & 5 deletions index.d.ts
Expand Up @@ -6,6 +6,11 @@ declare namespace gzipSize {
type Options = ZlibOptions;

interface GzipSizeStream extends stream.PassThrough {
/**
Contains the gzip size of the stream after it is finished. Since this happens asynchronously, it is recommended you use the `gzip-size` event instead.
*/
gzipSize?: number;

addListener(event: 'gzip-size', listener: (size: number) => void): this;
addListener(
event: string | symbol,
Expand Down Expand Up @@ -37,11 +42,6 @@ declare namespace gzipSize {
event: string | symbol,
listener: (...args: any[]) => void
): this;

/**
Contains the gzip size of the stream after it is finished. Since this happens asynchronously, it is recommended you use the `gzip-size` event instead.
*/
gzipSize?: number;
}
}

Expand Down
12 changes: 7 additions & 5 deletions index.js
Expand Up @@ -2,17 +2,19 @@
const fs = require('fs');
const stream = require('stream');
const zlib = require('zlib');
const {promisify} = require('util');
const duplexer = require('duplexer');
const pify = require('pify');

const getOptions = options => Object.assign({level: 9}, options);
const getOptions = options => ({level: 9, ...options});
const gzip = promisify(zlib.gzip);

module.exports = (input, options) => {
module.exports = async (input, options) => {
if (!input) {
return Promise.resolve(0);
return 0;
}

return pify(zlib.gzip)(input, getOptions(options)).then(data => data.length).catch(_ => 0);
const data = await gzip(input, getOptions(options));
return data.length;
};

module.exports.sync = (input, options) => zlib.gzipSync(input, getOptions(options)).length;
Expand Down
13 changes: 6 additions & 7 deletions package.json
Expand Up @@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=10"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -30,13 +30,12 @@
"buffer"
],
"dependencies": {
"duplexer": "^0.1.1",
"pify": "^4.0.1"
"duplexer": "^0.1.1"
},
"devDependencies": {
"ava": "^1.4.1",
"p-event": "^2.1.0",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^2.4.0",
"p-event": "^4.2.0",
"tsd": "^0.13.1",
"xo": "^0.34.2"
}
}

0 comments on commit 211169f

Please sign in to comment.