UNPKG

@exadel/esl

Version:

Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components

15 lines (14 loc) 1.1 kB
import type { AnyToAnyFnSignature, MethodTypedDecorator } from '../misc/functions'; /** * `@decorate` decorator: adapts a higher-order function `(fn) => wrappedFn` into a lazy method decorator. * - Applies only to class (prototype or static) methods (value descriptors) * - First instance access: binds original to `this`, passes it to `decorator(...args)`, caches wrapped fn on the instance * - Prototype (or super) access returns the original unwrapped function * - Reassignment replaces accessor with a normal writable value (no further wrapping) * - Copy of original own enumerable properties is assigned to the wrapped function * * @param decorator - higher‑order function receiving the bound original method * @param args - extra arguments forwarded to `decorator` after the original function * @throws TypeError when applied to a non-method (accessor / field) */ export declare function decorate<Args extends any[], Fn extends AnyToAnyFnSignature, Wrapped extends AnyToAnyFnSignature>(decorator: (fn: Fn, ...params: Args) => Wrapped & Fn, ...args: Args): MethodTypedDecorator<Fn>;