gzip-size
Advanced tools
Comparing version 4.0.1 to 4.1.0
12
index.js
'use strict'; | ||
const fs = require('fs'); | ||
const stream = require('stream'); | ||
@@ -45,1 +46,12 @@ const zlib = require('zlib'); | ||
}; | ||
module.exports.file = (path, options) => { | ||
return new Promise((resolve, reject) => { | ||
const stream = fs.createReadStream(path); | ||
stream.on('error', reject); | ||
const gzipStream = stream.pipe(module.exports.stream(options)); | ||
gzipStream.on('error', reject); | ||
gzipStream.on('gzip-size', resolve); | ||
}); | ||
}; |
{ | ||
"name": "gzip-size", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Get the gzipped size of a string or buffer", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -29,7 +29,7 @@ # gzip-size [![Build Status](https://travis-ci.org/sindresorhus/gzip-size.svg?branch=master)](https://travis-ci.org/sindresorhus/gzip-size) | ||
### gzipSize(input, options) | ||
### gzipSize(input, [options]) | ||
Returns a `Promise` for the size. | ||
### gzipSize.sync(input, options) | ||
### gzipSize.sync(input, [options]) | ||
@@ -48,7 +48,15 @@ Returns the size. | ||
### 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]) | ||
Returns a `Promise` for the size of the file. | ||
#### path | ||
Type: `string` | ||
## Related | ||
@@ -55,0 +63,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
4612
46
68
1