Pipe

wrBytes

Humanise byte counts using binary (1024-based) units.

Import

import { WrBytes } from 'ngwr/pipes';

@Component({ imports: [WrBytes] })
export class MyComponent { /* ... */ }

Basic usage

{{ 1234 | wrBytes }}  <!-- "1.2 KB" -->
532 B · 120.6 kB · 1.1 GB

Decimals

Second argument controls the fraction digits.

{{ 1234567 | wrBytes: 0 }}  <!-- "1 MB" -->
{{ 1234567 | wrBytes: 2 }}  <!-- "1.18 MB" -->
1 MB · 1.18 MB · 1.177 MB

Playground

1.2 MB

{{ 1234567 | wrBytes: 1 }}

Customize

Bytes
1234567
Decimals
1

API

NameDescriptionTypeDefault
wrBytesHumanise byte counts using binary (1024-based) units. A null / undefined / empty value renders as an empty string, so a nullable field needs no guard around it.(value: number | string | null | undefined, decimals = 1) => string

See also