UNPKG

@hgargg-0710/one

Version:

A tiny npm library purposed for providing beautiful solutions to frequent miniature (one-line/one-expression) tasks for various JS datatypes.

29 lines (28 loc) 1.36 kB
import { Constructor } from "./main.js"; /** * Returns a function that returns `new X(...args)` */ export declare const classWrapper: <T = any, Signature extends any[] = any[]>(X: new (...args: Signature) => T) => (...args: Signature) => T; /** * Returns a method that returns `this[delegateProp][delegateMethodName](...delegateArgs)` */ export declare const delegateMethod: (delegatePropName: string) => (delegateMethodName: string) => (...delegateArgs: any[]) => any; /** * Returns a method that returns `this[delegatePropName][propName]` */ export declare const delegateProperty: (delegatePropName: string) => (propName: string) => () => any; /** * Calls `extendPrototype` for each of the passed `Constructor`s `classes`, * that are removed their `.constructor` property from. * * Useful for multiple inheritance and mixin pattern */ export declare const mixin: (Extended: Constructor, classes: Constructor[]) => void; /** * Returns the copy of the given object with the `.constructor` property removed */ export declare const withoutConstructor: (object: object) => object; /** * Returns a function that returns `called[delegatePropName][delegateMethodName].call(called, ...delegateArgs)` */ export declare const calledDelegate: (delegatePropName: string) => (delegateMethodName: string) => (called: any, ...delegateArgs: any[]) => any;