Files
fluent/src/internal.ts
T
2026-07-10 18:28:43 +02:00

64 lines
1.5 KiB
TypeScript

import type { HKT } from "./base/hkt";
export interface Identity extends HKT {
new: (t: HKT.T<this>) => typeof t;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
export const never = undefined as never;
export function isArray(v: unknown): v is unknown[] {
return typeof v === "object" && v !== null && Array.isArray(v);
}
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(": "),
);
}
export namespace assert {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function type<T>(_v: unknown): asserts _v is NoInfer<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;
}