filesize

  • Version 9.0.11
  • Published
  • 63.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

Variables

variable fileSize

var fileSize: Filesize.Filesize;

    Namespaces

    namespace Filesize

    namespace Filesize {}

      interface Filesize

      interface Filesize {}

        property partial

        partial: <O extends Options>(
        options: O
        ) => (bytes: number) => ResultTypeMap<O>[CanonicalOutput<O>];

          call signature

          (bytes: number): string;

            call signature

            <O extends Options>(
            bytes: number,
            options: O
            ): ResultTypeMap<O>[CanonicalOutput<O>];

              interface Options

              interface Options {}

                property base

                base?: number;
                • Number base, default is 10

                property bits

                bits?: boolean;
                • Enables bit sizes, default is false

                property exponent

                exponent?: number;
                • Specifies the SI suffix via exponent, e.g. 2 is MB for bytes, default is -1

                property fullform

                fullform?: boolean;
                • Enables full form of unit of measure, default is false

                property fullforms

                fullforms?: string[];
                • Array of full form overrides, default is []

                property locale

                locale?: string | boolean;
                • BCP 47 language tag to specify a locale, or true to use default locale, default is ""

                property localeOptions

                localeOptions?: Intl.NumberFormatOptions;
                • ECMA-402 number format option overrides, default is "{}"

                property output

                output?: 'array' | 'exponent' | 'object' | 'string';
                • Output of function (array, exponent, object, or string), default is string

                property pad

                pad?: boolean;
                • Decimal place end padding, default is false

                property precision

                precision?: number;
                • Sets precision of numerical output, default is 0

                property round

                round?: number;
                • Decimal place, default is 2

                property roundingMethod

                roundingMethod?: 'round' | 'floor' | 'ceil';
                • Rounding method, can be round, floor, or ceil, default is round

                property separator

                separator?: string;
                • Decimal separator character, default is .

                property spacer

                spacer?: string;
                • Character between the result and suffix, default is

                property standard

                standard?: 'iec' | 'jedec';
                • Standard unit of measure, can be iec or jedec, default is iec; can be overruled by base

                property symbols

                symbols?: SiJedec;
                • Dictionary of SI/JEDEC symbols to replace for localization, defaults to english if no match is found

                property unix

                unix?: boolean;
                • Enables unix style human readable output, e.g ls -lh, default is false

                interface ResultTypeMap

                interface ResultTypeMap<O> {}

                  property array

                  array: [O extends { precision: number } ? string : number, string];

                    property exponent

                    exponent: number;

                      property object

                      object: {
                      value: number;
                      symbol: string;
                      exponent: number;
                      unit: string;
                      };

                        property string

                        string: string;

                          interface SiJedecBits

                          interface SiJedecBits {}

                            property b

                            b?: string;

                              property Eb

                              Eb?: string;

                                property Gb

                                Gb?: string;

                                  property Kb

                                  Kb?: string;

                                    property Mb

                                    Mb?: string;

                                      property Pb

                                      Pb?: string;

                                        property Tb

                                        Tb?: string;

                                          property Yb

                                          Yb?: string;

                                            property Zb

                                            Zb?: string;

                                              interface SiJedecBytes

                                              interface SiJedecBytes {}

                                                property B

                                                B?: string;

                                                  property EB

                                                  EB?: string;

                                                    property GB

                                                    GB?: string;

                                                      property KB

                                                      KB?: string;

                                                        property MB

                                                        MB?: string;

                                                          property PB

                                                          PB?: string;

                                                            property TB

                                                            TB?: string;

                                                              property YB

                                                              YB?: string;

                                                                property ZB

                                                                ZB?: string;

                                                                  type CanonicalOutput

                                                                  type CanonicalOutput<O extends Options> =
                                                                  | Extract<O['output'], keyof ResultTypeMap<O>>
                                                                  | DefaultOutput<O>;

                                                                    type DefaultOutput

                                                                    type DefaultOutput<O extends Options> = Exclude<
                                                                    O['output'],
                                                                    keyof ResultTypeMap<O>
                                                                    > extends never
                                                                    ? never
                                                                    : 'string';

                                                                      type SiJedec

                                                                      type SiJedec = SiJedecBits & SiJedecBytes & { [name: string]: string };

                                                                        Package Files (1)

                                                                        Dependencies (0)

                                                                        No dependencies.

                                                                        Dev Dependencies (9)

                                                                        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>