Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

BytesSize

import { BytesSize } from "https://raw.githubusercontent.com/i-xi-dev/bytes.es/4.4.2/deps.ts";
@example
const size = new BytesSize(2_048);
const unit = BytesUnit.KIB;
const kib = size.to(unit);
// kib
//   → 2

const format = new Intl.NumberFormat("en", { style: "unit", unit });
const kibStr = format.format(kib);
// kibStr
//   → "2 kB"
class BytesSize {
constructor(byteCount: SafeInteger | bigint);
to(unit: BytesUnit): number;
valueOf(): number;
}

§Constructors

§
new BytesSize(byteCount: SafeInteger | bigint)
[src]

§Methods

§
to(unit: BytesUnit): number
[src]
@param unit

The following units are supported. Units are case sensitive.

  • "byte"
  • "kilobyte"
  • "kibibyte"
  • "megabyte"
  • "mebibyte"
  • "gigabyte"
  • "gibibyte"
  • "terabyte"
  • "tebibyte"
  • "petabyte"
  • "pebibyte"
@return

The byte count expressed in specified unit.

§
valueOf(): number
[src]