Skip to content

API Reference


API Reference / @dasch-ng/utils / src / BinaryBytesPipe

Class: BinaryBytesPipe ​

Defined in: libs/ng/utils/src/lib/binary-bytes.pipe.ts:20

Formats bytes with base 1024 and IEC units (KiB, MiB, …), the counterpart to DecimalBytesPipe (base 1000, KB, MB). Use it where sizes follow memory or file-system conventions.

Mirrors decimalBytes: 0 gives '0 B', invalid values and values below 1 give 'Invalid Number'.

Example ​

html
{{ 1536 | binaryBytes }}      <!-- 1.5 KiB -->
{{ 10485760 | binaryBytes }}  <!-- 10 MiB -->

Implements ​

  • PipeTransform

Constructors ​

Constructor ​

new BinaryBytesPipe(): BinaryBytesPipe

Returns ​

BinaryBytesPipe

Methods ​

transform() ​

transform(bytes, precision?): string

Defined in: libs/ng/utils/src/lib/binary-bytes.pipe.ts:21

Parameters ​

bytes ​

unknown

precision? ​

number = 2

Returns ​

string

Implementation of ​

PipeTransform.transform

Released under the MIT License.