filesize

  • Version 10.1.6
  • Published
  • 20.2 kB
  • No dependencies
  • BSD-3-Clause license

Install

npm i filesize
yarn add filesize
pnpm add filesize

Overview

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

Index

Functions

function filesize

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

    function partial

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

      Interfaces

      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.

                                                                        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/filesize.

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