gzip-size

  • Version 7.0.0
  • Published
  • 8.3 kB
  • 1 dependency
  • MIT license

Install

npm i gzip-size
yarn add gzip-size
pnpm add gzip-size

Overview

Get the gzipped size of a string or buffer

Index

Functions

function gzipSize

gzipSize: (input: string | Buffer, options?: any) => Promise<number>;
  • Get the gzipped size of a string or buffer.

    Returns

    The gzipped size of input.

    Example 1

    import {gzipSize} from '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(await gzipSize(text));
    //=> 78

function gzipSizeFromFile

gzipSizeFromFile: (filePath: string, options?: any) => Promise<number>;
  • Get the gzipped size of a file.

    Returns

    The size of the file.

function gzipSizeFromFileSync

gzipSizeFromFileSync: (filePath: string, options?: any) => number;
  • Synchronously get the gzipped size of a file.

    Returns

    The size of the file.

function gzipSizeStream

gzipSizeStream: (options?: any) => GzipSizeStream;
  • Returns

    A stream that emits a gzip-size event and has a gzipSize property.

function gzipSizeSync

gzipSizeSync: (input: string | Buffer, options?: any) => number;
  • Synchronously get the gzipped size of a string or buffer.

    Returns

    The gzipped size of input.

    Example 1

    import {gzipSizeSync} from '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(gzipSizeSync(text));
    //=> 78

Interfaces

interface GzipSizeStream

interface GzipSizeStream extends PassThroughStream {}

    property gzipSize

    gzipSize?: number;
    • 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.

    method addListener

    addListener: {
    (event: 'gzip-size', listener: (size: number) => void): this;
    (event: string | symbol, listener: (...args: any[]) => void): this;
    };

      method emit

      emit: {
      (event: 'gzip-size', size: number): boolean;
      (event: string | symbol, ...args: any[]): boolean;
      };

        method off

        off: {
        (event: 'gzip-size', listener: (size: number) => void): this;
        (event: string | symbol, listener: (...args: any[]) => void): this;
        };

          method on

          on: {
          (event: 'gzip-size', listener: (size: number) => void): this;
          (event: string | symbol, listener: (...args: any[]) => void): this;
          };

            method once

            once: {
            (event: 'gzip-size', listener: (size: number) => void): this;
            (event: string | symbol, listener: (...args: any[]) => void): this;
            };

              method prependListener

              prependListener: {
              (event: 'gzip-size', listener: (size: number) => void): this;
              (event: string | symbol, listener: (...args: any[]) => void): this;
              };

                method prependOnceListener

                prependOnceListener: {
                (event: 'gzip-size', listener: (size: number) => void): this;
                (event: string | symbol, listener: (...args: any[]) => void): this;
                };

                  method removeListener

                  removeListener: {
                  (event: 'gzip-size', listener: (size: number) => void): this;
                  (event: string | symbol, listener: (...args: any[]) => void): this;
                  };

                    Type Aliases

                    type Options

                    type Options = ZlibOptions;

                      Package Files (1)

                      Dependencies (1)

                      Dev Dependencies (4)

                      Peer Dependencies (0)

                      No peer dependencies.

                      Badge

                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/gzip-size.

                      • Markdown
                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/gzip-size)
                      • HTML
                        <a href="https://www.jsdocs.io/package/gzip-size"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>