Socket
Socket
Sign inDemoInstall

gzip-size

Package Overview
Dependencies
1
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.1.1 to 6.0.0

10

index.d.ts

@@ -9,2 +9,7 @@ /// <reference types="node"/>

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;

@@ -41,7 +46,2 @@ addListener(

): 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;
}

@@ -48,0 +48,0 @@ }

@@ -5,13 +5,15 @@ 'use strict';

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;
};

@@ -18,0 +20,0 @@

{
"name": "gzip-size",
"version": "5.1.1",
"version": "6.0.0",
"description": "Get the gzipped size of a string or buffer",
"license": "MIT",
"repository": "sindresorhus/gzip-size",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=10"
},

@@ -33,11 +34,10 @@ "scripts": {

"dependencies": {
"duplexer": "^0.1.1",
"pify": "^4.0.1"
"duplexer": "^0.1.2"
},
"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"
}
}

@@ -1,6 +0,5 @@

# gzip-size [![Build Status](https://travis-ci.org/sindresorhus/gzip-size.svg?branch=master)](https://travis-ci.org/sindresorhus/gzip-size)
# gzip-size [![Build Status](https://travis-ci.com/sindresorhus/gzip-size.svg?branch=master)](https://travis-ci.com/github/sindresorhus/gzip-size)
> Get the gzipped size of a string or buffer
## Install

@@ -12,3 +11,2 @@

## Usage

@@ -28,10 +26,9 @@

## API
### gzipSize(input, [options])
### gzipSize(input, options?)
Returns a `Promise` for the size.
Returns a `Promise<number>` with the size.
### gzipSize.sync(input, [options])
### gzipSize.sync(input, options?)

@@ -42,17 +39,17 @@ Returns the size.

Type: `string` `Buffer`
Type: `string | Buffer`
#### options
Type: `Object`
Type: `object`
Any [`zlib` option](https://nodejs.org/api/zlib.html#zlib_class_options).
### gzipSize.stream([options])
### gzipSize.stream(options?)
Returns a [`stream.PassThrough`](https://nodejs.org/api/stream.html#stream_class_stream_passthrough). The stream emits a `gzip-size` event and has a `gzipSize` property.
### gzipSize.file(path, [options])
### gzipSize.file(path, options?)
Returns a `Promise` for the size of the file.
Returns a `Promise<number>` with the size of the file.

@@ -63,7 +60,6 @@ #### path

### gzipSize.fileSync(path, [options])
### gzipSize.fileSync(path, options?)
Returns the size of the file.
## Related

@@ -73,5 +69,12 @@

---
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-gzip-size?utm_source=npm-gzip-size&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc