UNPKG

1.94 kBTypeScriptView Raw
1import { ITypedHash } from "@pnp/common";
2export declare type ValidProxyMethods = "apply" | "get" | "has" | "set";
3export declare type ExtensionDelegateType<T extends Record<string, unknown>> = {
4 (op: string, target: T, ...rest: any[]): void;
5};
6export declare type ExtensionType<T extends Record<string, unknown> = {}> = Pick<ProxyHandler<T>, ValidProxyMethods> | ExtensionDelegateType<T> | ITypedHash<any>;
7/**
8 * Creates global extensions across all invokable objects
9 *
10 * @param e The global extensions to apply
11 */
12export declare const extendGlobal: (e: ExtensionType | ExtensionType[]) => void;
13/**
14 * Applies the supplied extensions to a single instance
15 *
16 * @param target Object to which extensions are applied
17 * @param extensions Extensions to apply
18 */
19export declare const extendObj: <T extends object>(target: T, extensions: ExtensionType | ExtensionType[]) => T;
20/**
21 * Allows applying extensions to all instances created from the supplied factory
22 *
23 * @param factory The Invokable Factory method to extend
24 * @param extensions Extensions to apply
25 */
26export declare const extendFactory: <T extends (...args: any[]) => any>(factory: T, extensions: ExtensionType | ExtensionType[]) => void;
27/**
28 * Clears all global extensions
29 */
30export declare const clearGlobalExtensions: () => void;
31/**
32 * Disables all extensions
33 */
34export declare const disableExtensions: () => void;
35/**
36 * Enables all extensions
37 */
38export declare const enableExtensions: () => void;
39/**
40 * Applies a set of extension previously applied to a factory using extendFactory to an object created from that factory
41 *
42 * @param factory
43 * @param args
44 */
45export declare const applyFactoryExtensions: <T extends object = {}>(factory: (args: any[]) => T, args: any[]) => T;
46export declare function extensionOrDefault(op: ValidProxyMethods, or: (...args: any[]) => any, target: any, ...rest: any[]): any;
47//# sourceMappingURL=invokable-extensions.d.ts.map
\No newline at end of file