feat: more mixins
This commit is contained in:
+48
-2
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user