UNPKG

@polyipseity/obsidian-plugin-library

Version:
28 lines 1.66 kB
export type InverseTypeofMap<T> = T extends string ? "string" : T extends number ? "number" : T extends bigint ? "bigint" : T extends boolean ? "boolean" : T extends symbol ? "symbol" : T extends undefined ? "undefined" : T extends Function ? "function" : T extends never ? never : "object"; export interface TypeofMap { string: string; number: number; bigint: bigint; boolean: boolean; symbol: symbol; undefined: undefined; function: Function; object: object | null; } export type PrimitiveOf<T> = TypeofMap[InverseTypeofMap<T>]; export type PrimitiveType = keyof TypeofMap; export declare const PRIMITIVE_TYPES: readonly ["string", "number", "bigint", "boolean", "symbol", "undefined", "function", "object"]; export declare function genericTypeofGuard<T extends PrimitiveType>(types: readonly T[], value: unknown): value is TypeofMap[T]; export declare function primitiveOf<T>(value: T): PrimitiveOf<T>; export type InverseTypeofMapE<T> = T extends null ? "null" : InverseTypeofMap<T>; export interface TypeofMapE extends TypeofMap { null: null; object: object; } export type PrimitiveOfE<T> = TypeofMapE[InverseTypeofMapE<T>]; export type PrimitiveTypeE = keyof TypeofMapE; export declare const PRIMITIVE_TYPES_E: readonly ["string", "number", "bigint", "boolean", "symbol", "undefined", "function", "object", "null"]; export declare function typeofE(value: unknown): PrimitiveTypeE; export declare function genericTypeofGuardE<T extends PrimitiveTypeE>(types: readonly T[], value: unknown): value is TypeofMapE[T]; export declare function primitiveOfE<T>(value: T): PrimitiveOfE<T>; //# sourceMappingURL=typeof.d.ts.map