UNPKG

unitsnet-js

Version:

A better way to hold unit variables and easily convert to the destination unit

1,193 lines (1,192 loc) 61.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Information = exports.InformationUnits = void 0; const base_unit_1 = require("../base-unit"); /** InformationUnits enumeration */ var InformationUnits; (function (InformationUnits) { /** */ InformationUnits["Bytes"] = "Byte"; /** */ InformationUnits["Octets"] = "Octet"; /** */ InformationUnits["Bits"] = "Bit"; /** */ InformationUnits["Kilobytes"] = "Kilobyte"; /** */ InformationUnits["Megabytes"] = "Megabyte"; /** */ InformationUnits["Gigabytes"] = "Gigabyte"; /** */ InformationUnits["Terabytes"] = "Terabyte"; /** */ InformationUnits["Petabytes"] = "Petabyte"; /** */ InformationUnits["Exabytes"] = "Exabyte"; /** */ InformationUnits["Kibibytes"] = "Kibibyte"; /** */ InformationUnits["Mebibytes"] = "Mebibyte"; /** */ InformationUnits["Gibibytes"] = "Gibibyte"; /** */ InformationUnits["Tebibytes"] = "Tebibyte"; /** */ InformationUnits["Pebibytes"] = "Pebibyte"; /** */ InformationUnits["Exbibytes"] = "Exbibyte"; /** */ InformationUnits["Kilooctets"] = "Kilooctet"; /** */ InformationUnits["Megaoctets"] = "Megaoctet"; /** */ InformationUnits["Gigaoctets"] = "Gigaoctet"; /** */ InformationUnits["Teraoctets"] = "Teraoctet"; /** */ InformationUnits["Petaoctets"] = "Petaoctet"; /** */ InformationUnits["Exaoctets"] = "Exaoctet"; /** */ InformationUnits["Kibioctets"] = "Kibioctet"; /** */ InformationUnits["Mebioctets"] = "Mebioctet"; /** */ InformationUnits["Gibioctets"] = "Gibioctet"; /** */ InformationUnits["Tebioctets"] = "Tebioctet"; /** */ InformationUnits["Pebioctets"] = "Pebioctet"; /** */ InformationUnits["Exbioctets"] = "Exbioctet"; /** */ InformationUnits["Kilobits"] = "Kilobit"; /** */ InformationUnits["Megabits"] = "Megabit"; /** */ InformationUnits["Gigabits"] = "Gigabit"; /** */ InformationUnits["Terabits"] = "Terabit"; /** */ InformationUnits["Petabits"] = "Petabit"; /** */ InformationUnits["Exabits"] = "Exabit"; /** */ InformationUnits["Kibibits"] = "Kibibit"; /** */ InformationUnits["Mebibits"] = "Mebibit"; /** */ InformationUnits["Gibibits"] = "Gibibit"; /** */ InformationUnits["Tebibits"] = "Tebibit"; /** */ InformationUnits["Pebibits"] = "Pebibit"; /** */ InformationUnits["Exbibits"] = "Exbibit"; })(InformationUnits = exports.InformationUnits || (exports.InformationUnits = {})); /** In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables. */ class Information extends base_unit_1.BaseUnit { /** * Create a new Information. * @param value The value. * @param fromUnit The ‘Information’ unit to create from. * The default unit is Bits */ constructor(value, fromUnit = InformationUnits.Bits) { super(); this.bytesLazy = null; this.octetsLazy = null; this.bitsLazy = null; this.kilobytesLazy = null; this.megabytesLazy = null; this.gigabytesLazy = null; this.terabytesLazy = null; this.petabytesLazy = null; this.exabytesLazy = null; this.kibibytesLazy = null; this.mebibytesLazy = null; this.gibibytesLazy = null; this.tebibytesLazy = null; this.pebibytesLazy = null; this.exbibytesLazy = null; this.kilooctetsLazy = null; this.megaoctetsLazy = null; this.gigaoctetsLazy = null; this.teraoctetsLazy = null; this.petaoctetsLazy = null; this.exaoctetsLazy = null; this.kibioctetsLazy = null; this.mebioctetsLazy = null; this.gibioctetsLazy = null; this.tebioctetsLazy = null; this.pebioctetsLazy = null; this.exbioctetsLazy = null; this.kilobitsLazy = null; this.megabitsLazy = null; this.gigabitsLazy = null; this.terabitsLazy = null; this.petabitsLazy = null; this.exabitsLazy = null; this.kibibitsLazy = null; this.mebibitsLazy = null; this.gibibitsLazy = null; this.tebibitsLazy = null; this.pebibitsLazy = null; this.exbibitsLazy = null; if (value === undefined || value === null || Number.isNaN(value)) { throw new TypeError('invalid unit value ‘' + value + '’'); } this.value = this.convertToBase(value, fromUnit); } /** * The base value of Information is Bits. * This accessor used when needs a value for calculations and it's better to use directly the base value */ get BaseValue() { return this.value; } /** Gets the default unit used when creating instances of the unit or its DTO */ get baseUnit() { return InformationUnits.Bits; } /** */ get Bytes() { if (this.bytesLazy !== null) { return this.bytesLazy; } return this.bytesLazy = this.convertFromBase(InformationUnits.Bytes); } /** */ get Octets() { if (this.octetsLazy !== null) { return this.octetsLazy; } return this.octetsLazy = this.convertFromBase(InformationUnits.Octets); } /** */ get Bits() { if (this.bitsLazy !== null) { return this.bitsLazy; } return this.bitsLazy = this.convertFromBase(InformationUnits.Bits); } /** */ get Kilobytes() { if (this.kilobytesLazy !== null) { return this.kilobytesLazy; } return this.kilobytesLazy = this.convertFromBase(InformationUnits.Kilobytes); } /** */ get Megabytes() { if (this.megabytesLazy !== null) { return this.megabytesLazy; } return this.megabytesLazy = this.convertFromBase(InformationUnits.Megabytes); } /** */ get Gigabytes() { if (this.gigabytesLazy !== null) { return this.gigabytesLazy; } return this.gigabytesLazy = this.convertFromBase(InformationUnits.Gigabytes); } /** */ get Terabytes() { if (this.terabytesLazy !== null) { return this.terabytesLazy; } return this.terabytesLazy = this.convertFromBase(InformationUnits.Terabytes); } /** */ get Petabytes() { if (this.petabytesLazy !== null) { return this.petabytesLazy; } return this.petabytesLazy = this.convertFromBase(InformationUnits.Petabytes); } /** */ get Exabytes() { if (this.exabytesLazy !== null) { return this.exabytesLazy; } return this.exabytesLazy = this.convertFromBase(InformationUnits.Exabytes); } /** */ get Kibibytes() { if (this.kibibytesLazy !== null) { return this.kibibytesLazy; } return this.kibibytesLazy = this.convertFromBase(InformationUnits.Kibibytes); } /** */ get Mebibytes() { if (this.mebibytesLazy !== null) { return this.mebibytesLazy; } return this.mebibytesLazy = this.convertFromBase(InformationUnits.Mebibytes); } /** */ get Gibibytes() { if (this.gibibytesLazy !== null) { return this.gibibytesLazy; } return this.gibibytesLazy = this.convertFromBase(InformationUnits.Gibibytes); } /** */ get Tebibytes() { if (this.tebibytesLazy !== null) { return this.tebibytesLazy; } return this.tebibytesLazy = this.convertFromBase(InformationUnits.Tebibytes); } /** */ get Pebibytes() { if (this.pebibytesLazy !== null) { return this.pebibytesLazy; } return this.pebibytesLazy = this.convertFromBase(InformationUnits.Pebibytes); } /** */ get Exbibytes() { if (this.exbibytesLazy !== null) { return this.exbibytesLazy; } return this.exbibytesLazy = this.convertFromBase(InformationUnits.Exbibytes); } /** */ get Kilooctets() { if (this.kilooctetsLazy !== null) { return this.kilooctetsLazy; } return this.kilooctetsLazy = this.convertFromBase(InformationUnits.Kilooctets); } /** */ get Megaoctets() { if (this.megaoctetsLazy !== null) { return this.megaoctetsLazy; } return this.megaoctetsLazy = this.convertFromBase(InformationUnits.Megaoctets); } /** */ get Gigaoctets() { if (this.gigaoctetsLazy !== null) { return this.gigaoctetsLazy; } return this.gigaoctetsLazy = this.convertFromBase(InformationUnits.Gigaoctets); } /** */ get Teraoctets() { if (this.teraoctetsLazy !== null) { return this.teraoctetsLazy; } return this.teraoctetsLazy = this.convertFromBase(InformationUnits.Teraoctets); } /** */ get Petaoctets() { if (this.petaoctetsLazy !== null) { return this.petaoctetsLazy; } return this.petaoctetsLazy = this.convertFromBase(InformationUnits.Petaoctets); } /** */ get Exaoctets() { if (this.exaoctetsLazy !== null) { return this.exaoctetsLazy; } return this.exaoctetsLazy = this.convertFromBase(InformationUnits.Exaoctets); } /** */ get Kibioctets() { if (this.kibioctetsLazy !== null) { return this.kibioctetsLazy; } return this.kibioctetsLazy = this.convertFromBase(InformationUnits.Kibioctets); } /** */ get Mebioctets() { if (this.mebioctetsLazy !== null) { return this.mebioctetsLazy; } return this.mebioctetsLazy = this.convertFromBase(InformationUnits.Mebioctets); } /** */ get Gibioctets() { if (this.gibioctetsLazy !== null) { return this.gibioctetsLazy; } return this.gibioctetsLazy = this.convertFromBase(InformationUnits.Gibioctets); } /** */ get Tebioctets() { if (this.tebioctetsLazy !== null) { return this.tebioctetsLazy; } return this.tebioctetsLazy = this.convertFromBase(InformationUnits.Tebioctets); } /** */ get Pebioctets() { if (this.pebioctetsLazy !== null) { return this.pebioctetsLazy; } return this.pebioctetsLazy = this.convertFromBase(InformationUnits.Pebioctets); } /** */ get Exbioctets() { if (this.exbioctetsLazy !== null) { return this.exbioctetsLazy; } return this.exbioctetsLazy = this.convertFromBase(InformationUnits.Exbioctets); } /** */ get Kilobits() { if (this.kilobitsLazy !== null) { return this.kilobitsLazy; } return this.kilobitsLazy = this.convertFromBase(InformationUnits.Kilobits); } /** */ get Megabits() { if (this.megabitsLazy !== null) { return this.megabitsLazy; } return this.megabitsLazy = this.convertFromBase(InformationUnits.Megabits); } /** */ get Gigabits() { if (this.gigabitsLazy !== null) { return this.gigabitsLazy; } return this.gigabitsLazy = this.convertFromBase(InformationUnits.Gigabits); } /** */ get Terabits() { if (this.terabitsLazy !== null) { return this.terabitsLazy; } return this.terabitsLazy = this.convertFromBase(InformationUnits.Terabits); } /** */ get Petabits() { if (this.petabitsLazy !== null) { return this.petabitsLazy; } return this.petabitsLazy = this.convertFromBase(InformationUnits.Petabits); } /** */ get Exabits() { if (this.exabitsLazy !== null) { return this.exabitsLazy; } return this.exabitsLazy = this.convertFromBase(InformationUnits.Exabits); } /** */ get Kibibits() { if (this.kibibitsLazy !== null) { return this.kibibitsLazy; } return this.kibibitsLazy = this.convertFromBase(InformationUnits.Kibibits); } /** */ get Mebibits() { if (this.mebibitsLazy !== null) { return this.mebibitsLazy; } return this.mebibitsLazy = this.convertFromBase(InformationUnits.Mebibits); } /** */ get Gibibits() { if (this.gibibitsLazy !== null) { return this.gibibitsLazy; } return this.gibibitsLazy = this.convertFromBase(InformationUnits.Gibibits); } /** */ get Tebibits() { if (this.tebibitsLazy !== null) { return this.tebibitsLazy; } return this.tebibitsLazy = this.convertFromBase(InformationUnits.Tebibits); } /** */ get Pebibits() { if (this.pebibitsLazy !== null) { return this.pebibitsLazy; } return this.pebibitsLazy = this.convertFromBase(InformationUnits.Pebibits); } /** */ get Exbibits() { if (this.exbibitsLazy !== null) { return this.exbibitsLazy; } return this.exbibitsLazy = this.convertFromBase(InformationUnits.Exbibits); } /** * Create a new Information instance from a Bytes * * @param value The unit as Bytes to create a new Information from. * @returns The new Information instance. */ static FromBytes(value) { return new Information(value, InformationUnits.Bytes); } /** * Create a new Information instance from a Octets * * @param value The unit as Octets to create a new Information from. * @returns The new Information instance. */ static FromOctets(value) { return new Information(value, InformationUnits.Octets); } /** * Create a new Information instance from a Bits * * @param value The unit as Bits to create a new Information from. * @returns The new Information instance. */ static FromBits(value) { return new Information(value, InformationUnits.Bits); } /** * Create a new Information instance from a Kilobytes * * @param value The unit as Kilobytes to create a new Information from. * @returns The new Information instance. */ static FromKilobytes(value) { return new Information(value, InformationUnits.Kilobytes); } /** * Create a new Information instance from a Megabytes * * @param value The unit as Megabytes to create a new Information from. * @returns The new Information instance. */ static FromMegabytes(value) { return new Information(value, InformationUnits.Megabytes); } /** * Create a new Information instance from a Gigabytes * * @param value The unit as Gigabytes to create a new Information from. * @returns The new Information instance. */ static FromGigabytes(value) { return new Information(value, InformationUnits.Gigabytes); } /** * Create a new Information instance from a Terabytes * * @param value The unit as Terabytes to create a new Information from. * @returns The new Information instance. */ static FromTerabytes(value) { return new Information(value, InformationUnits.Terabytes); } /** * Create a new Information instance from a Petabytes * * @param value The unit as Petabytes to create a new Information from. * @returns The new Information instance. */ static FromPetabytes(value) { return new Information(value, InformationUnits.Petabytes); } /** * Create a new Information instance from a Exabytes * * @param value The unit as Exabytes to create a new Information from. * @returns The new Information instance. */ static FromExabytes(value) { return new Information(value, InformationUnits.Exabytes); } /** * Create a new Information instance from a Kibibytes * * @param value The unit as Kibibytes to create a new Information from. * @returns The new Information instance. */ static FromKibibytes(value) { return new Information(value, InformationUnits.Kibibytes); } /** * Create a new Information instance from a Mebibytes * * @param value The unit as Mebibytes to create a new Information from. * @returns The new Information instance. */ static FromMebibytes(value) { return new Information(value, InformationUnits.Mebibytes); } /** * Create a new Information instance from a Gibibytes * * @param value The unit as Gibibytes to create a new Information from. * @returns The new Information instance. */ static FromGibibytes(value) { return new Information(value, InformationUnits.Gibibytes); } /** * Create a new Information instance from a Tebibytes * * @param value The unit as Tebibytes to create a new Information from. * @returns The new Information instance. */ static FromTebibytes(value) { return new Information(value, InformationUnits.Tebibytes); } /** * Create a new Information instance from a Pebibytes * * @param value The unit as Pebibytes to create a new Information from. * @returns The new Information instance. */ static FromPebibytes(value) { return new Information(value, InformationUnits.Pebibytes); } /** * Create a new Information instance from a Exbibytes * * @param value The unit as Exbibytes to create a new Information from. * @returns The new Information instance. */ static FromExbibytes(value) { return new Information(value, InformationUnits.Exbibytes); } /** * Create a new Information instance from a Kilooctets * * @param value The unit as Kilooctets to create a new Information from. * @returns The new Information instance. */ static FromKilooctets(value) { return new Information(value, InformationUnits.Kilooctets); } /** * Create a new Information instance from a Megaoctets * * @param value The unit as Megaoctets to create a new Information from. * @returns The new Information instance. */ static FromMegaoctets(value) { return new Information(value, InformationUnits.Megaoctets); } /** * Create a new Information instance from a Gigaoctets * * @param value The unit as Gigaoctets to create a new Information from. * @returns The new Information instance. */ static FromGigaoctets(value) { return new Information(value, InformationUnits.Gigaoctets); } /** * Create a new Information instance from a Teraoctets * * @param value The unit as Teraoctets to create a new Information from. * @returns The new Information instance. */ static FromTeraoctets(value) { return new Information(value, InformationUnits.Teraoctets); } /** * Create a new Information instance from a Petaoctets * * @param value The unit as Petaoctets to create a new Information from. * @returns The new Information instance. */ static FromPetaoctets(value) { return new Information(value, InformationUnits.Petaoctets); } /** * Create a new Information instance from a Exaoctets * * @param value The unit as Exaoctets to create a new Information from. * @returns The new Information instance. */ static FromExaoctets(value) { return new Information(value, InformationUnits.Exaoctets); } /** * Create a new Information instance from a Kibioctets * * @param value The unit as Kibioctets to create a new Information from. * @returns The new Information instance. */ static FromKibioctets(value) { return new Information(value, InformationUnits.Kibioctets); } /** * Create a new Information instance from a Mebioctets * * @param value The unit as Mebioctets to create a new Information from. * @returns The new Information instance. */ static FromMebioctets(value) { return new Information(value, InformationUnits.Mebioctets); } /** * Create a new Information instance from a Gibioctets * * @param value The unit as Gibioctets to create a new Information from. * @returns The new Information instance. */ static FromGibioctets(value) { return new Information(value, InformationUnits.Gibioctets); } /** * Create a new Information instance from a Tebioctets * * @param value The unit as Tebioctets to create a new Information from. * @returns The new Information instance. */ static FromTebioctets(value) { return new Information(value, InformationUnits.Tebioctets); } /** * Create a new Information instance from a Pebioctets * * @param value The unit as Pebioctets to create a new Information from. * @returns The new Information instance. */ static FromPebioctets(value) { return new Information(value, InformationUnits.Pebioctets); } /** * Create a new Information instance from a Exbioctets * * @param value The unit as Exbioctets to create a new Information from. * @returns The new Information instance. */ static FromExbioctets(value) { return new Information(value, InformationUnits.Exbioctets); } /** * Create a new Information instance from a Kilobits * * @param value The unit as Kilobits to create a new Information from. * @returns The new Information instance. */ static FromKilobits(value) { return new Information(value, InformationUnits.Kilobits); } /** * Create a new Information instance from a Megabits * * @param value The unit as Megabits to create a new Information from. * @returns The new Information instance. */ static FromMegabits(value) { return new Information(value, InformationUnits.Megabits); } /** * Create a new Information instance from a Gigabits * * @param value The unit as Gigabits to create a new Information from. * @returns The new Information instance. */ static FromGigabits(value) { return new Information(value, InformationUnits.Gigabits); } /** * Create a new Information instance from a Terabits * * @param value The unit as Terabits to create a new Information from. * @returns The new Information instance. */ static FromTerabits(value) { return new Information(value, InformationUnits.Terabits); } /** * Create a new Information instance from a Petabits * * @param value The unit as Petabits to create a new Information from. * @returns The new Information instance. */ static FromPetabits(value) { return new Information(value, InformationUnits.Petabits); } /** * Create a new Information instance from a Exabits * * @param value The unit as Exabits to create a new Information from. * @returns The new Information instance. */ static FromExabits(value) { return new Information(value, InformationUnits.Exabits); } /** * Create a new Information instance from a Kibibits * * @param value The unit as Kibibits to create a new Information from. * @returns The new Information instance. */ static FromKibibits(value) { return new Information(value, InformationUnits.Kibibits); } /** * Create a new Information instance from a Mebibits * * @param value The unit as Mebibits to create a new Information from. * @returns The new Information instance. */ static FromMebibits(value) { return new Information(value, InformationUnits.Mebibits); } /** * Create a new Information instance from a Gibibits * * @param value The unit as Gibibits to create a new Information from. * @returns The new Information instance. */ static FromGibibits(value) { return new Information(value, InformationUnits.Gibibits); } /** * Create a new Information instance from a Tebibits * * @param value The unit as Tebibits to create a new Information from. * @returns The new Information instance. */ static FromTebibits(value) { return new Information(value, InformationUnits.Tebibits); } /** * Create a new Information instance from a Pebibits * * @param value The unit as Pebibits to create a new Information from. * @returns The new Information instance. */ static FromPebibits(value) { return new Information(value, InformationUnits.Pebibits); } /** * Create a new Information instance from a Exbibits * * @param value The unit as Exbibits to create a new Information from. * @returns The new Information instance. */ static FromExbibits(value) { return new Information(value, InformationUnits.Exbibits); } /** * Gets the base unit enumeration associated with Information * @returns The unit enumeration that can be used to interact with this type */ static getUnitEnum() { return InformationUnits; } /** * Gets the default unit used when creating instances of the unit or its DTO * @returns The unit enumeration value used as a default parameter in constructor and DTO methods */ static getBaseUnit() { return InformationUnits.Bits; } /** * Create API DTO represent a Information unit. * @param holdInUnit The specific Information unit to be used in the unit representation at the DTO */ toDto(holdInUnit = InformationUnits.Bits) { return { value: this.convert(holdInUnit), unit: holdInUnit }; } /** * Create a Information unit from an API DTO representation. * @param dtoInformation The Information API DTO representation */ static FromDto(dtoInformation) { return new Information(dtoInformation.value, dtoInformation.unit); } /** * Convert Information to a specific unit value. * @param toUnit The specific unit to convert to * @returns The value of the specific unit provided. */ convert(toUnit) { switch (toUnit) { case InformationUnits.Bytes: return this.Bytes; case InformationUnits.Octets: return this.Octets; case InformationUnits.Bits: return this.Bits; case InformationUnits.Kilobytes: return this.Kilobytes; case InformationUnits.Megabytes: return this.Megabytes; case InformationUnits.Gigabytes: return this.Gigabytes; case InformationUnits.Terabytes: return this.Terabytes; case InformationUnits.Petabytes: return this.Petabytes; case InformationUnits.Exabytes: return this.Exabytes; case InformationUnits.Kibibytes: return this.Kibibytes; case InformationUnits.Mebibytes: return this.Mebibytes; case InformationUnits.Gibibytes: return this.Gibibytes; case InformationUnits.Tebibytes: return this.Tebibytes; case InformationUnits.Pebibytes: return this.Pebibytes; case InformationUnits.Exbibytes: return this.Exbibytes; case InformationUnits.Kilooctets: return this.Kilooctets; case InformationUnits.Megaoctets: return this.Megaoctets; case InformationUnits.Gigaoctets: return this.Gigaoctets; case InformationUnits.Teraoctets: return this.Teraoctets; case InformationUnits.Petaoctets: return this.Petaoctets; case InformationUnits.Exaoctets: return this.Exaoctets; case InformationUnits.Kibioctets: return this.Kibioctets; case InformationUnits.Mebioctets: return this.Mebioctets; case InformationUnits.Gibioctets: return this.Gibioctets; case InformationUnits.Tebioctets: return this.Tebioctets; case InformationUnits.Pebioctets: return this.Pebioctets; case InformationUnits.Exbioctets: return this.Exbioctets; case InformationUnits.Kilobits: return this.Kilobits; case InformationUnits.Megabits: return this.Megabits; case InformationUnits.Gigabits: return this.Gigabits; case InformationUnits.Terabits: return this.Terabits; case InformationUnits.Petabits: return this.Petabits; case InformationUnits.Exabits: return this.Exabits; case InformationUnits.Kibibits: return this.Kibibits; case InformationUnits.Mebibits: return this.Mebibits; case InformationUnits.Gibibits: return this.Gibibits; case InformationUnits.Tebibits: return this.Tebibits; case InformationUnits.Pebibits: return this.Pebibits; case InformationUnits.Exbibits: return this.Exbibits; default: break; } return Number.NaN; } convertFromBase(toUnit) { if (base_unit_1.areAnyOperatorsOverridden()) switch (toUnit) { case InformationUnits.Bytes: return super.internalDivide(this.value, 8); case InformationUnits.Octets: return super.internalDivide(this.value, 8); case InformationUnits.Bits: return this.value; case InformationUnits.Kilobytes: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1000); } case InformationUnits.Megabytes: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1000000); } case InformationUnits.Gigabytes: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1000000000); } case InformationUnits.Terabytes: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1000000000000); } case InformationUnits.Petabytes: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1000000000000000); } case InformationUnits.Exabytes: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1000000000000000000); } case InformationUnits.Kibibytes: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1024); } case InformationUnits.Mebibytes: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1048576); } case InformationUnits.Gibibytes: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1073741824); } case InformationUnits.Tebibytes: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1099511627776); } case InformationUnits.Pebibytes: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1125899906842624); } case InformationUnits.Exbibytes: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1152921504606847000); } case InformationUnits.Kilooctets: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1000); } case InformationUnits.Megaoctets: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1000000); } case InformationUnits.Gigaoctets: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1000000000); } case InformationUnits.Teraoctets: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1000000000000); } case InformationUnits.Petaoctets: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1000000000000000); } case InformationUnits.Exaoctets: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1000000000000000000); } case InformationUnits.Kibioctets: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1024); } case InformationUnits.Mebioctets: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1048576); } case InformationUnits.Gibioctets: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1073741824); } case InformationUnits.Tebioctets: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1099511627776); } case InformationUnits.Pebioctets: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1125899906842624); } case InformationUnits.Exbioctets: { const v3 = super.internalDivide(this.value, 8); return super.internalDivide(v3, 1152921504606847000); } case InformationUnits.Kilobits: return super.internalDivide(this.value, 1000); case InformationUnits.Megabits: return super.internalDivide(this.value, 1000000); case InformationUnits.Gigabits: return super.internalDivide(this.value, 1000000000); case InformationUnits.Terabits: return super.internalDivide(this.value, 1000000000000); case InformationUnits.Petabits: return super.internalDivide(this.value, 1000000000000000); case InformationUnits.Exabits: return super.internalDivide(this.value, 1000000000000000000); case InformationUnits.Kibibits: return super.internalDivide(this.value, 1024); case InformationUnits.Mebibits: return super.internalDivide(this.value, 1048576); case InformationUnits.Gibibits: return super.internalDivide(this.value, 1073741824); case InformationUnits.Tebibits: return super.internalDivide(this.value, 1099511627776); case InformationUnits.Pebibits: return super.internalDivide(this.value, 1125899906842624); case InformationUnits.Exbibits: return super.internalDivide(this.value, 1152921504606847000); default: return Number.NaN; } switch (toUnit) { case InformationUnits.Bytes: return this.value / 8; case InformationUnits.Octets: return this.value / 8; case InformationUnits.Bits: return this.value; case InformationUnits.Kilobytes: return (this.value / 8) / 1000; case InformationUnits.Megabytes: return (this.value / 8) / 1000000; case InformationUnits.Gigabytes: return (this.value / 8) / 1000000000; case InformationUnits.Terabytes: return (this.value / 8) / 1000000000000; case InformationUnits.Petabytes: return (this.value / 8) / 1000000000000000; case InformationUnits.Exabytes: return (this.value / 8) / 1000000000000000000; case InformationUnits.Kibibytes: return (this.value / 8) / 1024; case InformationUnits.Mebibytes: return (this.value / 8) / 1048576; case InformationUnits.Gibibytes: return (this.value / 8) / 1073741824; case InformationUnits.Tebibytes: return (this.value / 8) / 1099511627776; case InformationUnits.Pebibytes: return (this.value / 8) / 1125899906842624; case InformationUnits.Exbibytes: return (this.value / 8) / 1152921504606847000; case InformationUnits.Kilooctets: return (this.value / 8) / 1000; case InformationUnits.Megaoctets: return (this.value / 8) / 1000000; case InformationUnits.Gigaoctets: return (this.value / 8) / 1000000000; case InformationUnits.Teraoctets: return (this.value / 8) / 1000000000000; case InformationUnits.Petaoctets: return (this.value / 8) / 1000000000000000; case InformationUnits.Exaoctets: return (this.value / 8) / 1000000000000000000; case InformationUnits.Kibioctets: return (this.value / 8) / 1024; case InformationUnits.Mebioctets: return (this.value / 8) / 1048576; case InformationUnits.Gibioctets: return (this.value / 8) / 1073741824; case InformationUnits.Tebioctets: return (this.value / 8) / 1099511627776; case InformationUnits.Pebioctets: return (this.value / 8) / 1125899906842624; case InformationUnits.Exbioctets: return (this.value / 8) / 1152921504606847000; case InformationUnits.Kilobits: return (this.value) / 1000; case InformationUnits.Megabits: return (this.value) / 1000000; case InformationUnits.Gigabits: return (this.value) / 1000000000; case InformationUnits.Terabits: return (this.value) / 1000000000000; case InformationUnits.Petabits: return (this.value) / 1000000000000000; case InformationUnits.Exabits: return (this.value) / 1000000000000000000; case InformationUnits.Kibibits: return (this.value) / 1024; case InformationUnits.Mebibits: return (this.value) / 1048576; case InformationUnits.Gibibits: return (this.value) / 1073741824; case InformationUnits.Tebibits: return (this.value) / 1099511627776; case InformationUnits.Pebibits: return (this.value) / 1125899906842624; case InformationUnits.Exbibits: return (this.value) / 1152921504606847000; default: return Number.NaN; } } convertToBase(value, fromUnit) { if (base_unit_1.areAnyOperatorsOverridden()) switch (fromUnit) { case InformationUnits.Bytes: return super.internalMultiply(value, 8); case InformationUnits.Octets: return super.internalMultiply(value, 8); case InformationUnits.Bits: return value; case InformationUnits.Kilobytes: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1000); } case InformationUnits.Megabytes: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1000000); } case InformationUnits.Gigabytes: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1000000000); } case InformationUnits.Terabytes: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1000000000000); } case InformationUnits.Petabytes: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1000000000000000); } case InformationUnits.Exabytes: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1000000000000000000); } case InformationUnits.Kibibytes: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1024); } case InformationUnits.Mebibytes: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1048576); } case InformationUnits.Gibibytes: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1073741824); } case InformationUnits.Tebibytes: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1099511627776); } case InformationUnits.Pebibytes: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1125899906842624); } case InformationUnits.Exbibytes: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1152921504606847000); } case InformationUnits.Kilooctets: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1000); } case InformationUnits.Megaoctets: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1000000); } case InformationUnits.Gigaoctets: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1000000000); } case InformationUnits.Teraoctets: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1000000000000); } case InformationUnits.Petaoctets: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1000000000000000); } case InformationUnits.Exaoctets: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1000000000000000000); } case InformationUnits.Kibioctets: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1024); } case InformationUnits.Mebioctets: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1048576); } case InformationUnits.Gibioctets: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1073741824); } case InformationUnits.Tebioctets: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1099511627776); } case InformationUnits.Pebioctets: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1125899906842624); } case InformationUnits.Exbioctets: { const v3 = super.internalMultiply(value, 8); return super.internalMultiply(v3, 1152921504606847000); } case InformationUnits.Kilobits: return super.internalMultiply(value, 1000); case InformationUnits.Megabits: return super.internalMultiply(value, 1000000); case InformationUnits.Gigabits: return super.internalMultiply(value, 1000000000); case InformationUnits.Terabits: return super.internalMultiply(value, 1000000000000); case InformationUnits.Petabits: return super.internalMultiply(value, 1000000000000000); case InformationUnits.Exabits: return super.internalMultiply(value, 1000000000000000000); case InformationUnits.Kibibits: return super.internalMultiply(value, 1024); case InformationUnits.Mebibits: return super.internalMultiply(value, 1048576); case InformationUnits.Gibibits: return super.internalMultiply(value, 1073741824); case InformationUnits.Tebibits: return super.internalMultiply(value, 1099511627776); case InformationUnits.Pebibits: return super.internalMultiply(value, 1125899906842624); case InformationUnits.Exbibits: return super.internalMultiply(value, 1152921504606847000); default: return Number.NaN; } switch (fromUnit) { case InformationUnits.Bytes: return value * 8; case InformationUnits.Octets: return value * 8; case InformationUnits.Bits: return value; case InformationUnits.Kilobytes: return (value * 8) * 1000; case InformationUnits.Megabytes: return (value * 8) * 1000000; case InformationUnits.Gigabytes: return (value * 8) * 1000000000; case InformationUnits.Terabytes: return (value * 8) * 1000000000000; case InformationUnits.Petabytes: return (value * 8) * 1000000000000000; case InformationUnits.Exabytes: return (value * 8) * 1000000000000000000; case InformationUnits.Kibibytes: return (value * 8) * 1024; case InformationUnits.Mebibytes: return (value * 8) * 1048576; case InformationUnits.Gibibytes: return (value * 8) * 1073741824; case InformationUnits.Tebibytes: return (value * 8) * 1099511627776; case InformationUnits.Pebibytes: return (value * 8) * 1125899906842624; case InformationUnits.Exbibytes: return (value * 8) * 1152921504606847000; case InformationUnits.Kilooctets: return (value * 8) * 1000; case InformationUnits.Megaoctets: return (value * 8) * 1000000; case InformationUnits.Gigaoctets: return (value * 8) * 1000000000; case InformationUnits.Teraoctets: return (value * 8) * 1000000000000; case InformationUnits.Petaoctets: return (value * 8) * 1000000000000000; case InformationUnits.Exaoctets: return (value * 8) * 1000000000000000000; case InformationUnits.Kibioctets: return (value * 8) * 1024; case InformationUnits.Mebioctets: return (value * 8) * 1048576; case InformationUnits.Gibioctets: return (value * 8) * 1073741824; case InformationUnits.Tebioctets: return (value * 8) * 1099511627776; case InformationUnits.Pebioctets: return (value * 8) * 1125899906842624; case InformationUnits.Exbioctets: return (value * 8) * 1152921504606847000; case InformationUnits.Kilobits: return (value) * 1000; case InformationUnits.Megabits: return (value) * 1000000; case InformationUnits.Gigabits: return (value) * 1000000000; case InformationUnits.Terabits: return (value) * 1000000000000; case InformationUnits.Petabits: return (value) * 1000000000000000; case InformationUnits.Exabits: return (value) * 1000000000000000000; case InformationUnits.Kibibits: return (value) * 1024; case InformationUnits.Mebibits: return (value) * 1048576; case InformationUnits.Gibibits: return (value) * 1073741824; case InformationUnits.Tebibits: return (value) * 1099511627776; case InformationUnits.Pebibits: return (value) * 1125899906842624; case InformationUnits.Exbibits: return (value) * 1152921504606847000; default: return Number.NaN; } } /** * Format the Information to string. * Note! the default format for Information is Bits. * To specify the unit format set the 'unit' parameter. * @param unit The unit to format the Information. * @param options The ToString options, it also can be the number of fractional digits to keep that deprecated and moved to the options object. support in number will be dropped in the upcoming versions. * @returns The string format of the Information. */ toString(unit = InformationUnits.Bits, options) { if (typeof options === 'number') { console.warn('The number parameter is deprecated and moved to the options object. support in number will be dropped in the upcoming versions.'); options = { fractionalDigits: options }; } switch (unit) { case InformationUnits.Bytes: return super.truncateFractionDigits(this.Bytes, options) + ` B`; case InformationUnits.Octets: