/** * The enhanced dynamical `inherits` implementation. * * + load the class via dynamical name. * * requireClass *(Function)*: * * scope *(Object)*: collects the register classes. * * the inherits ctor will be added into the scope automatically. * * The default requireClass is `getClassByName`. * * @param {Function=} aDefaultRequire custom the requireClass function. * @returns {Function} the `inherits` function * * @example * * var InheritsEx = require('inherits-ex/lib/inherits-ex') * var defaultRequire = InheritsEx.requireClass; * // You should return the proper class(ctor) here. * InheritsEx.requireClass = function(className, scope){return defaultRequire.apply(null, arguments)}; * var inherits = InheritsEx() * * const requireClass = (aClassName, aScope) => getClassViaName(aClassName) * const InheritsEx = require('inherits-ex/lib/inherits-ex') * const inherits = InheritsEx(requireClass) * * class RootClass {} * class Parent {} * InheritsEx.setScope([RootClass, Parent]) * * class MyClass3 {} * inherits(MyClass3, RootClass) * */ export function InheritsEx(aDefaultRequire?: Function | undefined): Function; export namespace InheritsEx { export { getClassByName as requireClass }; export const scope: {}; export function setScope(aScope: any): void; /** * Get the class from class name in scope * @param {*} aClassName the class name to find * @param {Function|string[]|Function[]|{[name: string]: Function}=} aScope The optional additional scope with all * registered classes. It'll be called to find the class if the aScope is a `function(className):Function`. * @param {Function[]=} aValues If `aScope` is an array of strings, then `aValues` must exist and can only be an array of corresponding classes. * @returns {Function|undefined} the found class or undefined. */ export function getClass(aClassName: any, aScope?: Function | string[] | Function[] | { [name: string]: Function; }, aValues?: Function[]): Function; export function execute(ctor: any, superCtors: any, aScope: any, aValues: any): boolean; /** * Add the class to the scope * * @internal * @param {string} aName the class name * @param {*} ctor the class */ export function addClass(aName: string, ctor: any): void; } export default InheritsEx; import { getClassByName } from './get-class-by-name.js';