web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.4 KiB

  1. # gzip-size [![Build Status](https://travis-ci.org/sindresorhus/gzip-size.svg?branch=master)](https://travis-ci.org/sindresorhus/gzip-size)
  2. > Get the gzipped size of a string or buffer
  3. ## Install
  4. ```
  5. $ npm install gzip-size
  6. ```
  7. ## Usage
  8. ```js
  9. const gzipSize = require('gzip-size');
  10. 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.';
  11. console.log(text.length);
  12. //=> 191
  13. console.log(gzipSize.sync(text));
  14. //=> 78
  15. ```
  16. ## API
  17. ### gzipSize(input, [options])
  18. Returns a `Promise` for the size.
  19. ### gzipSize.sync(input, [options])
  20. Returns the size.
  21. #### input
  22. Type: `string` `Buffer`
  23. #### options
  24. Type: `Object`
  25. Any [`zlib` option](https://nodejs.org/api/zlib.html#zlib_class_options).
  26. ### gzipSize.stream([options])
  27. 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.
  28. ### gzipSize.file(path, [options])
  29. Returns a `Promise` for the size of the file.
  30. #### path
  31. Type: `string`
  32. ### gzipSize.fileSync(path, [options])
  33. Returns the size of the file.
  34. ## Related
  35. - [gzip-size-cli](https://github.com/sindresorhus/gzip-size-cli) - CLI for this module
  36. ## License
  37. MIT © [Sindre Sorhus](https://sindresorhus.com)