Blame view

node_modules/gzip-size/readme.md 1.3 KB
aaac7fed   liuqimichale   add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  # gzip-size [![Build Status](https://travis-ci.org/sindresorhus/gzip-size.svg?branch=master)](https://travis-ci.org/sindresorhus/gzip-size)
  
  > Get the gzipped size of a string or buffer
  
  
  ## Install
  
  ```
  $ npm install gzip-size
  ```
  
  
  ## Usage
  
  ```js
  const gzipSize = require('gzip-size');
  const text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.';
  
  console.log(text.length);
  //=> 191
  
  console.log(gzipSize.sync(text));
  //=> 78
  ```
  
  
  ## API
  
  ### gzipSize(input, [options])
  
  Returns a `Promise` for the size.
  
  ### gzipSize.sync(input, [options])
  
  Returns the size.
  
  #### input
  
  Type: `string` `Buffer`
  
  #### options
  
  Type: `Object`
  
  Any [`zlib` option](https://nodejs.org/api/zlib.html#zlib_class_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
  
  - [gzip-size-cli](https://github.com/sindresorhus/gzip-size-cli) - CLI for this module
  
  
  ## License
  
  MIT © [Sindre Sorhus](https://sindresorhus.com)