@ayonli/jsext
Version:
A JavaScript extension package for building strong and modern applications.
35 lines (34 loc) • 992 B
TypeScript
/**
* This module includes functions for dealing with classes.
* @module
*/
import { Constructor } from "./types.ts";
import _mixin from "./mixin.ts";
/** @deprecated import `mixin` from `@ayonli/jsext/mixin` instead. */
export declare const mixin: typeof _mixin;
/**
* Checks if a value is a class/constructor.
*
* @example
* ```ts
* import { isClass } from "@ayonli/jsext/class";
*
* console.assert(isClass(class Foo { }));
* console.assert(!isClass(function foo() { }));
* ```
*/
export declare function isClass(value: unknown): value is Constructor<any>;
/**
* Checks if a class is a subclass of another class.
*
* @example
* ```ts
* import { isSubclassOf } from "@ayonli/jsext/class";
*
* class Moment extends Date {}
*
* console.assert(isSubclassOf(Moment, Date));
* console.assert(isSubclassOf(Moment, Object)); // all classes are subclasses of Object
* ```
*/
export declare function isSubclassOf<A, B>(ctor1: Constructor<A>, ctor2: Constructor<B>): boolean;