feat: more mixins

This commit is contained in:
2026-06-23 17:04:03 +02:00
parent 3dc22e3f62
commit edd6a68d9d
10 changed files with 771 additions and 62 deletions
+48 -2
View File
@@ -9,5 +9,51 @@ export const never = undefined as never;
export type Constraint<T, U extends T> = U;
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export type Empty = Constraint<Record<PropertyKey, unknown>, {}>;
export class AssertionError extends Error {
public constructor(msg?: string) {
super(msg);
this.name = "AssertionError";
}
}
export function assert(
condition: unknown,
msg?: string,
): asserts condition {
if (!Boolean(condition))
throw new AssertionError(
["Assertion error", msg]
.filter((v) => v !== undefined)
.join(": "),
);
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters, @typescript-eslint/no-unused-vars
export function assertType<T>(_v: unknown): asserts _v is T {
/* empty */
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
type FunctionProto = Function;
export interface HidePrototype {
/** @deprecated */
apply: FunctionProto["apply"];
/** @deprecated */
arguments: FunctionProto["arguments"];
/** @deprecated */
bind: FunctionProto["bind"];
/** @deprecated */
call: FunctionProto["call"];
/** @deprecated */
caller: FunctionProto["caller"];
/** @deprecated */
length: FunctionProto["length"];
/** @deprecated */
name: FunctionProto["name"];
/** @deprecated */
prototype: FunctionProto["prototype"];
/** @deprecated */
toString: FunctionProto["toString"];
/** @deprecated */
Symbol: SymbolConstructor;
}