• Version 10.1.2
  • Published
  • 53 kB
  • No dependencies
  • BSD-3-Clause license


npm i filesize
yarn add filesize
pnpm add filesize


JavaScript library to generate a human readable String describing the file size



function filesize

filesize: <Options extends FileSizeOptions = undefined>(
byteCount: number | string,
options?: Options
) => FileSizeReturnType<Options>;

    function partial

    partial: <Options extends FileSizeOptions = undefined>(
    options?: Options
    ) => (byteCount: number) => FileSizeReturnType<Options>;


      interface FileSizeOptionsArray

      interface FileSizeOptionsArray extends FileSizeOptionsBase {}

        property output

        output: 'array';

          interface FileSizeOptionsBase

          interface FileSizeOptionsBase {}

            property base

            base?: 10 | 2;

              property bits

              bits?: boolean;

                property exponent

                exponent?: number;

                  property fullform

                  fullform?: boolean;

                    property fullforms

                    fullforms?: string[];

                      property locale

                      locale?: string | boolean;

                        property localeOptions

                        localeOptions?: Intl.DateTimeFormatOptions;

                          property pad

                          pad?: boolean;

                            property precision

                            precision?: number;

                              property round

                              round?: number;

                                property roundingMethod

                                roundingMethod?: 'round' | 'floor' | 'ceil';

                                  property separator

                                  separator?: string;

                                    property spacer

                                    spacer?: string;

                                      property standard

                                      standard?: 'si' | 'iec' | 'jedec';

                                        property symbols

                                        symbols?: {};

                                          interface FileSizeOptionsExponent

                                          interface FileSizeOptionsExponent extends FileSizeOptionsBase {}

                                            property output

                                            output: 'exponent';

                                              interface FileSizeOptionsObject

                                              interface FileSizeOptionsObject extends FileSizeOptionsBase {}

                                                property output

                                                output: 'object';

                                                  interface FileSizeOptionsString

                                                  interface FileSizeOptionsString extends FileSizeOptionsBase {}

                                                    property output

                                                    output: 'string';

                                                      interface FileSizeReturnObject

                                                      interface FileSizeReturnObject {}

                                                        property exponent

                                                        exponent: number;

                                                          property symbol

                                                          symbol: string;

                                                            property unit

                                                            unit: string;

                                                              property value

                                                              value: string;

                                                                Type Aliases

                                                                type FileSizeOptions

                                                                type FileSizeOptions =
                                                                | FileSizeOptionsArray
                                                                | FileSizeOptionsExponent
                                                                | FileSizeOptionsObject
                                                                | FileSizeOptionStringOrBase
                                                                | undefined;

                                                                  type FileSizeOptionStringOrBase

                                                                  type FileSizeOptionStringOrBase = FileSizeOptionsString | FileSizeOptionsBase;

                                                                    type FileSizeReturnArray

                                                                    type FileSizeReturnArray = [number, string];

                                                                      type FileSizeReturnType

                                                                      type FileSizeReturnType<Options extends FileSizeOptions> =
                                                                      Options extends FileSizeOptionsArray
                                                                      ? FileSizeReturnArray
                                                                      : Options extends FileSizeOptionsExponent
                                                                      ? number
                                                                      : Options extends FileSizeOptionsObject
                                                                      ? FileSizeReturnObject
                                                                      : string;

                                                                        Package Files (1)

                                                                        Dependencies (0)

                                                                        No dependencies.

                                                                        Dev Dependencies (8)

                                                                        Peer Dependencies (0)

                                                                        No peer dependencies.


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

                                                                        You may also use to create a custom badge linking to

                                                                        • Markdown
                                                                        • HTML
                                                                          <a href=""><img src="" alt=""></a>