DefinitelyTyped/hooker/hooker.d.ts
Michael Zabka f9341f81d0 Add library hooker
* on github is named javascript-hooker in case of already existance of hooker repo
2015-02-26 11:50:56 +01:00

43 lines
1.4 KiB
TypeScript

// Type definitions for JavaScript Hooker v0.2.3
// Project: https://github.com/cowboy/javascript-hooker
// Definitions by: Michael Zabka <https://github.com/misak113/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare type HookerPostHookFunction = (result: any, ...args: any[]) => IHookerPostHookResult|void;
declare type HookerPreHookFunction = (...args: any[]) => IHookerPreHookResult|void;
declare module "hooker" {
function hook(object: any, props: string|string[], options: IHookerOptions): void;
function hook(object: any, props: string|string[], prehookFunction: HookerPreHookFunction): void;
function unhook(object: any, props?: string|string[]): string[];
function orig(object: any, props: string|string[]): Function;
function override(value: any): HookerOverride;
function preempt(value: any): HookerPreempt;
function filter(context: any, args: any[]): HookerFilter;
}
declare class HookerOverride implements IHookerPostHookResult, IHookerPreHookResult {
value: any;
}
declare class HookerPreempt implements IHookerPreHookResult {
value: any;
}
declare class HookerFilter implements IHookerPreHookResult {
context: any;
args: any[];
}
interface IHookerPostHookResult {}
interface IHookerPreHookResult {}
interface IHookerOptions {
pre?: HookerPreHookFunction;
post?: HookerPostHookFunction;
once?: boolean;
passName?: boolean;
}