• Version 3.1.4
  • Published
  • 5.03 kB
  • No dependencies
  • MIT license


npm i @types/bytes
yarn add @types/bytes
pnpm add @types/bytes


TypeScript definitions for bytes



function bytes

bytes: typeof bytes;
  • Convert the given value in bytes into a string.

  • Parse string to an integer in bytes.

function format

format: (value: number, options?: BytesOptions) => string;
  • Format the given value in bytes into a string.

    If the value is negative, it is kept as such. If it is a float, it is rounded.

function parse

parse: (value: string | number) => number;
  • Parse the string value into an integer in bytes.

    If no unit is given, it is assumed the value is in bytes.


interface BytesOptions

interface BytesOptions {}

    property decimalPlaces

    decimalPlaces?: number | undefined;

      property fixedDecimals

      fixedDecimals?: boolean | undefined;

        property thousandsSeparator

        thousandsSeparator?: string | undefined;

          property unit

          unit?: Unit | undefined;

            property unitSeparator

            unitSeparator?: string | undefined;

              Type Aliases

              type Unit

              type Unit =
              | 'b'
              | 'gb'
              | 'kb'
              | 'mb'
              | 'pb'
              | 'tb'
              | 'B'
              | 'GB'
              | 'KB'
              | 'MB'
              | 'PB'
              | 'TB';

                Package Files (1)

                Dependencies (0)

                No dependencies.

                Dev Dependencies (0)

                No dev dependencies.

                Peer Dependencies (0)

                No peer dependencies.


                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/@types/bytes.

                • Markdown
                • HTML
                  <a href="https://www.jsdocs.io/package/@types/bytes"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>