ts-data-forge
Version:
[](https://www.npmjs.com/package/ts-data-forge) [](https://www.npmjs.com/package/ts-data-forge) [ => x is Int8;
/**
* Casts a number to an Int8 branded type.
*
* This function validates that the input is within the Int8 range [-128, 127]
* and is an integer, then returns it with the Int8 brand.
*
* @param value - The value to cast
* @returns The value as an Int8 branded type
* @throws {TypeError} If the value is not a valid 8-bit signed integer
*/
export declare const asInt8: (x: number) => Int8;
/**
* Namespace providing type-safe operations for Int8 (8-bit signed integer)
* branded types.
*
* Int8 represents signed integers in the range [-128, 127], equivalent to a
* signed byte in many programming languages. All operations automatically clamp
* results to stay within this range, preventing overflow/underflow issues.
*
* This type is useful for:
*
* - Binary data processing (signed bytes)
* - Small integer values with known bounds
* - Embedded systems programming
* - Memory-efficient integer storage
* - Image processing (signed pixel offsets)
*/
export declare const Int8: {
/**
* Type guard that checks if a value is an 8-bit signed integer.
*
* @param value - The value to check
* @returns `true` if the value is in range [-128, 127] and is an integer
* @see {@link isInt8} for usage examples
*/
readonly is: (x: number) => x is Int8;
/**
* The minimum value for an 8-bit signed integer.
*
* @readonly
*/
readonly MIN_VALUE: -128;
/**
* The maximum value for an 8-bit signed integer.
*
* @readonly
*/
readonly MAX_VALUE: 127;
/**
* Returns the minimum value from a list of Int8 values.
*
* @param values - The Int8 values to compare (at least one required)
* @returns The smallest value as an Int8
*/
readonly min: (...values: readonly Int8[]) => Int8;
/**
* Returns the maximum value from a list of Int8 values.
*
* @param values - The Int8 values to compare (at least one required)
* @returns The largest value as an Int8
*/
readonly max: (...values: readonly Int8[]) => Int8;
/**
* Clamps a number to the Int8 range.
*
* @param value The number to clamp.
* @returns The value clamped to [-128, 127] as an Int8.
*/
readonly clamp: (a: number) => Int8;
/**
* Returns the absolute value of an Int8.
*
* @param value The Int8 value.
* @returns The absolute value as an Int8, clamped to valid range.
*/
readonly abs: <N extends Int8>(x: N) => AbsoluteValue<N>;
/**
* Generates a random Int8 value within the specified range (inclusive).
*
* Both bounds are inclusive. If min > max, they are automatically swapped.
*
* @param min - The minimum value (inclusive)
* @param max - The maximum value (inclusive)
* @returns A random Int8 in the range [min, max]
*/
readonly random: (min: Int8, max: Int8) => Int8;
/**
* Raises x to the power of y, clamped to Int8 range.
*
* @param x - The base
* @param y - The exponent
* @returns `x ** y` clamped to [-128, 127]
*/
readonly pow: (x: Int8, y: Int8) => Int8;
/**
* Adds two Int8 values, clamped to Int8 range.
*
* @param x - First operand
* @param y - Second operand
* @returns `x + y` clamped to [-128, 127]
*/
readonly add: (x: Int8, y: Int8) => Int8;
/**
* Subtracts two Int8 values, clamped to Int8 range.
*
* @param x - First operand
* @param y - Second operand
* @returns `x - y` clamped to [-128, 127]
*/
readonly sub: (x: Int8, y: Int8) => Int8;
/**
* Multiplies two Int8 values, clamped to Int8 range.
*
* @param x - First operand
* @param y - Second operand
* @returns `x * y` clamped to [-128, 127]
*/
readonly mul: (x: Int8, y: Int8) => Int8;
/**
* Divides two Int8 values, clamped to Int8 range.
*
* @param x - The dividend
* @param y - The divisor (cannot be 0)
* @returns `⌊x / y⌋` clamped to [-128, 127]
*/
readonly div: (x: Int8, y: Exclude<Int8, 0>) => Int8;
};
//# sourceMappingURL=int8.d.mts.map