gnablib
Version:
A lean, zero dependency library to provide a useful base for your project.
80 lines (79 loc) • 1.98 kB
TypeScript
/*! Copyright 2025 the gnablib contributors MPL-1.1 */
interface IShiftOps<T> {
lShift(by: number): T;
lRot(by: number): T;
rShift(by: number): T;
rRot(by: number): T;
}
interface IShiftEqOps<T> {
lShiftEq(by: number): T;
lRotEq(by: number): T;
rShiftEq(by: number): T;
rRotEq(by: number): T;
}
interface ILogicOps<T> {
xor(o: T): T;
or(o: T): T;
and(o: T): T;
not(): T;
}
interface ILogicEqOps<T> {
xorEq(o: T): T;
orEq(o: T): T;
andEq(o: T): T;
notEq(): T;
}
interface IArithOps<T> {
add(o: T): T;
sub(o: T): T;
mul(o: T): T;
}
interface IArithSignOps<T> extends IArithOps<T> {
get negative(): boolean;
abs(): T;
}
interface IArithEqOps<T> {
addEq(o: T): T;
subEq(o: T): T;
mulEq(o: T): T;
}
interface IArithEqSignOps<T> extends IArithEqOps<T> {
get negative(): boolean;
absEq(): T;
}
interface IComparable<T> {
eq(o: T): boolean;
gt(o: T): boolean;
gte(o: T): boolean;
lt(o: T): boolean;
lte(o: T): boolean;
}
export interface ICtComparable<T> {
ctEq(o: T): boolean;
ctGt(o: T): boolean;
ctGte(o: T): boolean;
ctLt(o: T): boolean;
ctLte(o: T): boolean;
ctSwitch(o: T, other: boolean): T;
}
interface IBasic<T> {
get size32(): number;
clone(): T;
clone32(): Uint32Array;
toBytesBE(): Uint8Array;
toString(): string;
getByte(idx: number): number;
}
interface IBasicMut<T, Tro> {
set(v: Tro): T;
zero(): T;
}
export interface IInt<T> extends IBasic<T>, IShiftOps<T>, ILogicOps<T>, IArithOps<T>, IArithSignOps<T>, IComparable<T> {
}
export interface IUint<T> extends IBasic<T>, IShiftOps<T>, ILogicOps<T>, IArithOps<T>, IComparable<T> {
}
export interface IIntMut<T, Tro> extends IInt<Tro>, IBasicMut<T, Tro>, IShiftEqOps<T>, ILogicEqOps<T>, IArithEqSignOps<T> {
}
export interface IUintMut<T, Tro> extends IUint<Tro>, IBasicMut<T, Tro>, IShiftEqOps<T>, ILogicEqOps<T>, IArithEqOps<T> {
}
export {};