import type * as Brand from "./Brand.ts"; import type * as Combiner from "./Combiner.ts"; import type * as Equ from "./Equivalence.ts"; import * as Option from "./Option.ts"; import type * as order from "./Order.ts"; import type * as Reducer from "./Reducer.ts"; declare const TypeId = "~effect/ByteSize"; /** * Represents an exact, non-negative number of bytes. * * @stability unstable * @category models * @since 4.0.0 */ export type ByteSize = Brand.Branded; /** * Values accepted by byte-size decoding operations. * * **Details** * * String inputs require a non-negative decimal integer without leading zeros, * followed by a canonical unit symbol or lowercase unit name, optionally * separated by one space. Numeric inputs are validated at runtime. * * @see {@link fromString} for external strings and fractional quantities * @see {@link fromStringUnsafe} for throwing string validation * @stability unstable * @category models * @since 4.0.0 */ export type Input = ByteSize | bigint | number | `${IntegerQuantity}${"" | " "}${InputUnit}`; type IntegerQuantity = "0" | (`${bigint}` & `${"1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"}${string}`); type InputUnit = Unit | `${"" | "kilo" | "mega" | "giga" | "tera" | "peta" | "exa" | "zetta" | "yotta" | "ronna" | "quetta" | "kibi" | "mebi" | "gibi" | "tebi" | "pebi" | "exbi" | "zebi" | "yobi"}byte${"" | "s"}`; /** * Canonical decimal byte unit symbols. * * @stability unstable * @category models * @since 4.0.0 */ export type DecimalUnit = "B" | "kB" | "MB" | "GB" | "TB" | "PB" | "EB" | "ZB" | "YB" | "RB" | "QB"; /** * Canonical binary byte unit symbols. * * @stability unstable * @category models * @since 4.0.0 */ export type BinaryUnit = "B" | "KiB" | "MiB" | "GiB" | "TiB" | "PiB" | "EiB" | "ZiB" | "YiB"; /** * Canonical decimal and binary byte unit symbols. * * @stability unstable * @category models * @since 4.0.0 */ export type Unit = DecimalUnit | BinaryUnit; /** * Options controlling compact byte-size formatting. * * @stability unstable * @category models * @since 4.0.0 */ export type FormatOptions = { readonly precision?: number | undefined; readonly trailingZeros?: boolean | undefined; } & ({ readonly system?: "decimal" | undefined; readonly unit?: DecimalUnit | undefined; } | { readonly system?: "binary" | undefined; readonly unit?: BinaryUnit | undefined; }); /** * The byte size containing zero bytes. * * @stability unstable * @category constants * @since 4.0.0 */ export declare const zero: ByteSize; /** * Parses a byte-size string and throws for invalid syntax, unsupported units, * or quantities that do not represent non-negative integral bytes. * * **Details** * * Accepts decimal fractions, canonical SI and IEC symbols, lowercase unit * names, and whitespace around the quantity and unit. Parsing uses exact * bigint arithmetic, including above the safe integer range. * * @see {@link fromString} for non-throwing validation * @stability unstable * @category constructors * @since 4.0.0 */ export declare const fromStringUnsafe: (input: string) => ByteSize; /** * Parses a byte-size string, returning `None` for invalid syntax, unsupported * units, or quantities that do not represent non-negative integral bytes. * * **Details** * * Accepts external strings and fractional quantities using the same syntax * as `fromStringUnsafe`. * * @see {@link fromStringUnsafe} for throwing validation * @stability unstable * @category constructors * @since 4.0.0 */ export declare const fromString: (input: string) => Option.Option; /** * Decodes a trusted input into a byte size and throws for invalid input. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const fromInputUnsafe: (input: Input) => ByteSize; /** * Decodes an input into a byte size, returning `None` for invalid input. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const fromInput: (input: Input) => Option.Option; /** * Creates a byte size from a non-negative byte count. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const bytes: (value: number | bigint) => ByteSize; /** * Creates a decimal kilobyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const kilobytes: (value: number | bigint) => ByteSize; /** * Creates a decimal megabyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const megabytes: (value: number | bigint) => ByteSize; /** * Creates a decimal gigabyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const gigabytes: (value: number | bigint) => ByteSize; /** * Creates a decimal terabyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const terabytes: (value: number | bigint) => ByteSize; /** * Creates a decimal petabyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const petabytes: (value: number | bigint) => ByteSize; /** * Creates a decimal exabyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const exabytes: (value: number | bigint) => ByteSize; /** * Creates a decimal zettabyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const zettabytes: (value: number | bigint) => ByteSize; /** * Creates a decimal yottabyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const yottabytes: (value: number | bigint) => ByteSize; /** * Creates a decimal ronnabyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const ronnabytes: (value: number | bigint) => ByteSize; /** * Creates a decimal quettabyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const quettabytes: (value: number | bigint) => ByteSize; /** * Creates a binary kibibyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const kibibytes: (value: number | bigint) => ByteSize; /** * Creates a binary mebibyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const mebibytes: (value: number | bigint) => ByteSize; /** * Creates a binary gibibyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const gibibytes: (value: number | bigint) => ByteSize; /** * Creates a binary tebibyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const tebibytes: (value: number | bigint) => ByteSize; /** * Creates a binary pebibyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const pebibytes: (value: number | bigint) => ByteSize; /** * Creates a binary exbibyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const exbibytes: (value: number | bigint) => ByteSize; /** * Creates a binary zebibyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const zebibytes: (value: number | bigint) => ByteSize; /** * Creates a binary yobibyte value. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const yobibytes: (value: number | bigint) => ByteSize; /** * Checks whether a value is a byte size. * * @stability unstable * @category guards * @since 4.0.0 */ export declare const isByteSize: (input: unknown) => input is ByteSize; /** * Checks whether a byte size is zero. * * @stability unstable * @category predicates * @since 4.0.0 */ export declare const isZero: (self: ByteSize) => boolean; /** * Returns the exact byte count as a bigint. * * @stability unstable * @category getters * @since 4.0.0 */ export declare const toBigInt: (self: ByteSize) => bigint; /** * Converts a byte size to a safe integer, returning `None` when it is too large. * * @stability unstable * @category converting * @since 4.0.0 */ export declare const toNumber: (self: ByteSize) => Option.Option; /** * Converts a byte size to a safe integer and throws when it is too large. * * @stability unstable * @category unsafe * @since 4.0.0 */ export declare const toNumberUnsafe: (self: ByteSize) => number; /** * Converts a byte size to an approximate number of the specified unit. * * @stability unstable * @category converting * @since 4.0.0 */ export declare const toUnit: { /** * Converts a byte size to an approximate number of the specified unit. * * @stability unstable * @category converting * @since 4.0.0 */ (unit: Unit): (self: ByteSize) => number; /** * Converts a byte size to an approximate number of the specified unit. * * @stability unstable * @category converting * @since 4.0.0 */ (self: ByteSize, unit: Unit): number; }; /** * Provides an order for byte sizes. * * @stability unstable * @category instances * @since 4.0.0 */ export declare const Order: order.Order; /** * Provides an equivalence for byte sizes. * * @stability unstable * @category instances * @since 4.0.0 */ export declare const Equivalence: Equ.Equivalence; /** * Returns whether a byte size is in an inclusive range. * * @stability unstable * @category predicates * @since 4.0.0 */ export declare const between: { /** * Returns whether a byte size is in an inclusive range. * * @stability unstable * @category predicates * @since 4.0.0 */ (options: { minimum: ByteSize; maximum: ByteSize; }): (self: ByteSize) => boolean; /** * Returns whether a byte size is in an inclusive range. * * @stability unstable * @category predicates * @since 4.0.0 */ (self: ByteSize, options: { minimum: ByteSize; maximum: ByteSize; }): boolean; }; /** * Returns the smaller byte size. * * @stability unstable * @category ordering * @since 4.0.0 */ export declare const min: { /** * Returns the smaller byte size. * * @stability unstable * @category ordering * @since 4.0.0 */ (that: ByteSize): (self: ByteSize) => ByteSize; /** * Returns the smaller byte size. * * @stability unstable * @category ordering * @since 4.0.0 */ (self: ByteSize, that: ByteSize): ByteSize; }; /** * Returns the larger byte size. * * @stability unstable * @category ordering * @since 4.0.0 */ export declare const max: { /** * Returns the larger byte size. * * @stability unstable * @category ordering * @since 4.0.0 */ (that: ByteSize): (self: ByteSize) => ByteSize; /** * Returns the larger byte size. * * @stability unstable * @category ordering * @since 4.0.0 */ (self: ByteSize, that: ByteSize): ByteSize; }; /** * Constrains a byte size to an inclusive range. * * @stability unstable * @category ordering * @since 4.0.0 */ export declare const clamp: { /** * Constrains a byte size to an inclusive range. * * @stability unstable * @category ordering * @since 4.0.0 */ (options: { minimum: ByteSize; maximum: ByteSize; }): (self: ByteSize) => ByteSize; /** * Constrains a byte size to an inclusive range. * * @stability unstable * @category ordering * @since 4.0.0 */ (self: ByteSize, options: { minimum: ByteSize; maximum: ByteSize; }): ByteSize; }; /** * Checks whether the first byte size is less than the second. * * @stability unstable * @category predicates * @since 4.0.0 */ export declare const isLessThan: { /** * Checks whether the first byte size is less than the second. * * @stability unstable * @category predicates * @since 4.0.0 */ (that: ByteSize): (self: ByteSize) => boolean; /** * Checks whether the first byte size is less than the second. * * @stability unstable * @category predicates * @since 4.0.0 */ (self: ByteSize, that: ByteSize): boolean; }; /** * Checks whether the first byte size is at most the second. * * @stability unstable * @category predicates * @since 4.0.0 */ export declare const isLessThanOrEqualTo: { /** * Checks whether the first byte size is at most the second. * * @stability unstable * @category predicates * @since 4.0.0 */ (that: ByteSize): (self: ByteSize) => boolean; /** * Checks whether the first byte size is at most the second. * * @stability unstable * @category predicates * @since 4.0.0 */ (self: ByteSize, that: ByteSize): boolean; }; /** * Checks whether the first byte size is greater than the second. * * @stability unstable * @category predicates * @since 4.0.0 */ export declare const isGreaterThan: { /** * Checks whether the first byte size is greater than the second. * * @stability unstable * @category predicates * @since 4.0.0 */ (that: ByteSize): (self: ByteSize) => boolean; /** * Checks whether the first byte size is greater than the second. * * @stability unstable * @category predicates * @since 4.0.0 */ (self: ByteSize, that: ByteSize): boolean; }; /** * Checks whether the first byte size is at least the second. * * @stability unstable * @category predicates * @since 4.0.0 */ export declare const isGreaterThanOrEqualTo: { /** * Checks whether the first byte size is at least the second. * * @stability unstable * @category predicates * @since 4.0.0 */ (that: ByteSize): (self: ByteSize) => boolean; /** * Checks whether the first byte size is at least the second. * * @stability unstable * @category predicates * @since 4.0.0 */ (self: ByteSize, that: ByteSize): boolean; }; /** * Checks whether two byte sizes contain the same count. * * @stability unstable * @category predicates * @since 4.0.0 */ export declare const equals: { /** * Checks whether two byte sizes contain the same count. * * @stability unstable * @category predicates * @since 4.0.0 */ (that: ByteSize): (self: ByteSize) => boolean; /** * Checks whether two byte sizes contain the same count. * * @stability unstable * @category predicates * @since 4.0.0 */ (self: ByteSize, that: ByteSize): boolean; }; /** * Adds two byte sizes exactly. * * @stability unstable * @category math * @since 4.0.0 */ export declare const sum: { /** * Adds two byte sizes exactly. * * @stability unstable * @category math * @since 4.0.0 */ (that: ByteSize): (self: ByteSize) => ByteSize; /** * Adds two byte sizes exactly. * * @stability unstable * @category math * @since 4.0.0 */ (self: ByteSize, that: ByteSize): ByteSize; }; /** * Subtracts byte sizes, returning `None` on underflow. * * @stability unstable * @category math * @since 4.0.0 */ export declare const subtract: { /** * Subtracts byte sizes, returning `None` on underflow. * * @stability unstable * @category math * @since 4.0.0 */ (that: ByteSize): (self: ByteSize) => Option.Option; /** * Subtracts byte sizes, returning `None` on underflow. * * @stability unstable * @category math * @since 4.0.0 */ (self: ByteSize, that: ByteSize): Option.Option; }; /** * Subtracts byte sizes and throws on underflow. * * @stability unstable * @category unsafe * @since 4.0.0 */ export declare const subtractUnsafe: { /** * Subtracts byte sizes and throws on underflow. * * @stability unstable * @category unsafe * @since 4.0.0 */ (that: ByteSize): (self: ByteSize) => ByteSize; /** * Subtracts byte sizes and throws on underflow. * * @stability unstable * @category unsafe * @since 4.0.0 */ (self: ByteSize, that: ByteSize): ByteSize; }; /** * Multiplies a byte size by a non-negative integer scalar. * * @stability unstable * @category math * @since 4.0.0 */ export declare const times: { /** * Multiplies a byte size by a non-negative integer scalar. * * @stability unstable * @category math * @since 4.0.0 */ (multiplier: number | bigint): (self: ByteSize) => Option.Option; /** * Multiplies a byte size by a non-negative integer scalar. * * @stability unstable * @category math * @since 4.0.0 */ (self: ByteSize, multiplier: number | bigint): Option.Option; }; /** * Divides a byte size by a positive integer, discarding any remainder. * * @stability unstable * @category math * @since 4.0.0 */ export declare const divide: { /** * Divides a byte size by a positive integer, discarding any remainder. * * @stability unstable * @category math * @since 4.0.0 */ (divisor: number | bigint): (self: ByteSize) => Option.Option; /** * Divides a byte size by a positive integer, discarding any remainder. * * @stability unstable * @category math * @since 4.0.0 */ (self: ByteSize, divisor: number | bigint): Option.Option; }; /** * Formats a byte size with canonical decimal or binary unit symbols. * * @stability unstable * @category converting * @since 4.0.0 */ export declare const format: (self: ByteSize, options?: FormatOptions) => string; /** * Reducer that sums byte sizes from zero. * * @stability unstable * @category math * @since 4.0.0 */ export declare const ReducerSum: Reducer.Reducer; /** * Combiner that keeps the largest byte size. * * @stability unstable * @category math * @since 4.0.0 */ export declare const CombinerMax: Combiner.Combiner; /** * Combiner that keeps the smallest byte size. * * @stability unstable * @category math * @since 4.0.0 */ export declare const CombinerMin: Combiner.Combiner; export {}; //# sourceMappingURL=ByteSize.d.ts.map