hooker/000755 001751 001751 0000000000 15163626536014066 5ustar00runner000000 000000 1516362653615163626536hooker/LICENSE000644 001751 001751 0000002165 15163626536015077 0ustar00runner000000 000000 1516362653615163626536 MIT License Copyright (c) Microsoft Corporation. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE hooker/README.md000644 001751 001751 0000000730 15163626536015345 0ustar00runner000000 000000 1516362653615163626536# Installation > `npm install --save @types/hooker` # Summary This package contains type definitions for hooker (https://github.com/cowboy/javascript-hooker). # Details Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hooker. ### Additional Details * Last updated: Fri, 03 Apr 2026 03:00:46 GMT * Dependencies: none # Credits These definitions were written by [Michael Zabka](https://github.com/misak113). hooker/index.d.ts000644 001751 001751 0000012315 15163626536015771 0ustar00runner000000 000000 1516362653615163626536/* eslint-disable @typescript-eslint/no-invalid-void-type */ declare type HookerPreHookFunction any = (...args: any[]) => any> = ( ...args: Parameters ) => HookerOverride> | HookerPreempt> | HookerFilter> | Promise | void; declare type HookerPostHookFunction any = (...args: any[]) => any> = ( result: ReturnType, ...args: Parameters ) => HookerOverride> | Promise | void; /* eslint-enable @typescript-eslint/no-invalid-void-type */ declare module "hooker" { /** * Monkey-patch (hook) one or more methods of an object. Returns an array of hooked method names. * * @param object * @param props Can be a method name, array of method names or null. If null (or omitted), all enumerable methods of `object` will be hooked. * @param options */ function hook( object: T, props: K, options: IHookerOptions any ? T[K] : never>, ): string[]; /** * Monkey-patch (hook) one or more methods of an object. Returns an array of hooked method names. * * @param object * @param props Can be a method name, array of method names or null. If null (or omitted), all enumerable methods of `object` will be hooked. * @param prehookFunction A pre-hook function to be executed before the original function. Arguments passed into the method will be passed into the pre-hook function as well. */ function hook( object: T, props: K, prehookFunction: HookerPreHookFunction any ? T[K] : never>, ): string[]; /** * Monkey-patch (hook) one or more methods of an object. Returns an array of hooked method names. * * @param object * @param props Can be a method name, array of method names or null. If null (or omitted), all enumerable methods of `object` will be hooked. * @param options */ function hook(object: any, props: string[], options: IHookerOptions): string[]; /** * Monkey-patch (hook) one or more methods of an object. Returns an array of hooked method names. * * @param object * @param props Can be a method name, array of method names or null. If null (or omitted), all enumerable methods of `object` will be hooked. * @param prehookFunction A pre-hook function to be executed before the original function. Arguments passed into the method will be passed into the pre-hook function as well. */ function hook(object: any, props: string[], prehookFunction: HookerPreHookFunction): string[]; /** * Un-monkey-patch (unhook) one or more methods of an object. * * @param object * @param props Can be a method name, array of method names or null. If null (or omitted), all methods of object will be unhooked. */ function unhook(object: any, props?: string | string[]): string[]; /** * Get a reference to the original method from a hooked function. * * @param object * @param prop */ function orig(object: T, prop: K): T[K] extends (...args: any[]) => any ? T[K] : never; function orig(object: any, prop: string): Function; /** * When a pre- or post-hook returns the result of this function, the value passed will be used in place of the original function's return value. Any post-hook override value will take precedence over a pre-hook override value. * * @param value */ function override(value: T): HookerOverride; /** * When a pre-hook returns the result of this function, the value passed will be used in place of the original function's return value, and the original function will **NOT** be executed. * * @param value */ function preempt(value: T): HookerPreempt; /** * When a pre-hook returns the result of this function, the context and arguments passed will be applied into the original function. * * @param context * @param args */ function filter(context: any, args: T): HookerFilter; } declare class HookerOverride { value: T; } declare class HookerPreempt { value: T; } declare class HookerFilter { context: any; args: T; } interface IHookerOptions any = (...args: any[]) => any> { /** * A pre-hook function to be executed before the original function. Arguments passed into the method will be passed into the pre-hook function as well. */ pre?: HookerPreHookFunction; /** * A post-hook function to be executed after the original function. The original function's result is passed into the post-hook function as its first argument, followed by the method arguments. */ post?: HookerPostHookFunction; /** * If true, auto-unhook the function after the first execution. */ once?: boolean; /** * If true, pass the name of the method into the pre-hook function as its first arg (preceding all other arguments), and into the post-hook function as the second arg (after result but preceding all other arguments). */ passName?: boolean; } hooker/package.json000644 001751 001751 0000001454 15163626536016360 0ustar00runner000000 000000 1516362653615163626536{ "name": "@types/hooker", "version": "0.2.36", "description": "TypeScript definitions for hooker", "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hooker", "license": "MIT", "contributors": [ { "name": "Michael Zabka", "githubUsername": "misak113", "url": "https://github.com/misak113" } ], "main": "", "types": "index.d.ts", "repository": { "type": "git", "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", "directory": "types/hooker" }, "scripts": {}, "dependencies": {}, "peerDependencies": {}, "typesPublisherContentHash": "2e1ad44e1c7f22623a0825c35adb13835750b1ced87ccbe10071a34a7f029bcc", "typeScriptVersion": "5.3" }