# byte-formatter

> A leight package to format byte numbers to human readable output.

Latest version **1.0.1** (published 2019-10-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install byte-formatter
pnpm add byte-formatter
yarn add byte-formatter
bun add byte-formatter
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-10-29 |
| First published | 2019-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | zekro |
| Maintainers | zekro |
| Keywords | formatting, bytes, byte formatting, human readable, formatter |

## Links

- npm: https://www.npmjs.com/package/byte-formatter
- npm.io page: https://npm.io/package/byte-formatter

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-10-29
- 1.0.0 — 2019-10-29

## README

# byte-formatter &nbsp;[![Build Status](https://travis-ci.org/zekroTJA/byte-formatter.svg?branch=master)](https://travis-ci.org/zekroTJA/byte-formatter) ![npm](https://img.shields.io/npm/v/byte-formatter) 
A leight package to format byte numbers to human readable output.

## Usage

```ts
import { byteFormatter } from 'byte-formatter';

const res = byteFormatter(624223443);
// -> res = '595.31 MiB'
```

You can also specify a custom ammount of digets behind the comma (`fix`):
```ts
import { byteFormatter } from 'byte-formatter';

const res = byteFormatter(624223443, 5);
// -> res = '595.30587 MiB'
```

If you want a custom format for the units, use one of the pre defined like `DEFAULT_FORMAT` or `EXTENDED_FORMAT`:
```ts
import { byteFormatter, EXTENDED_FORMAT } from 'byte-formatter';

const res = byteFormatter(61273868723462, 2, EXTENDED_FORMAT);
// -> res = '55.73 Tebibytes'
```

Or define a custom format by using the `Format` interface:
```ts
import { byteFormatter, Format } from 'byte-formatter';

const MY_CUSTOM_FORMAT = {
  bytes: 'b',
  kibibytes: 'kib',
  mebibytes: 'mib',
  gibibytes: 'gib',
  tebibytes: 'tib',
} as Format;

const res = byteFormatter(61273868723462, 2, MY_CUSTOM_FORMAT);
// -> res = '55.73 tib'
```

---
_Source: https://npm.io/package/byte-formatter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
