UNPKG

node-apparatus

Version:

A mix of common components needed for awesome node experience

37 lines 1.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InjectableConstructor = void 0; /** * InjectableConstructor is a class that is used to create instances of classes.(this helps with dependency injection & mocking). */ class InjectableConstructor { /** * Creates an instance of a class with a constructor. * @param typeConstructor The class constructor * @param constructorArguments The arguments to pass to the constructor(optional) * @returns The instance of the class */ createInstance(typeConstructor, constructorArguments) { return new typeConstructor(...(constructorArguments || [])); } /** * Creates an instance of a class without a constructor asynchronously. * @param typeConstructorFunction The class constructor ASYNC function. * @param constructorFunctionArguments the arguments to pass to the constructor(optional) * @returns The instance of the class */ async createAsyncInstanceWithoutConstructor(typeConstructorFunction, constructorFunctionArguments) { return await typeConstructorFunction(...(constructorFunctionArguments || [])); } /** * Creates an instance of a class without a constructor. * @param typeConstructorFunction The class constructor function. * @param constructorFunctionArguments the arguments to pass to the constructor(optional) * @returns The instance of the class */ createInstanceWithoutConstructor(typeConstructorFunction, constructorFunctionArguments) { return typeConstructorFunction(...(constructorFunctionArguments || [])); } } exports.InjectableConstructor = InjectableConstructor; //# sourceMappingURL=injectable-constructor.js.map