Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/before-after-hook/index.d.ts
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

96 lines (86 sloc)
2.06 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type HookMethod<O, R> = (options: O) => R | Promise<R> | |
type BeforeHook<O> = (options: O) => void | |
type ErrorHook<O, E> = (error: E, options: O) => void | |
type AfterHook<O, R> = (result: R, options: O) => void | |
type WrapHook<O, R> = ( | |
hookMethod: HookMethod<O, R>, | |
options: O | |
) => R | Promise<R> | |
type AnyHook<O, R, E> = | |
| BeforeHook<O> | |
| ErrorHook<O, E> | |
| AfterHook<O, R> | |
| WrapHook<O, R> | |
export interface HookCollection { | |
/** | |
* Invoke before and after hooks | |
*/ | |
( | |
name: string | string[], | |
hookMethod: HookMethod<any, any>, | |
options?: any | |
): Promise<any> | |
/** | |
* Add `before` hook for given `name` | |
*/ | |
before(name: string, beforeHook: BeforeHook<any>): void | |
/** | |
* Add `error` hook for given `name` | |
*/ | |
error(name: string, errorHook: ErrorHook<any, any>): void | |
/** | |
* Add `after` hook for given `name` | |
*/ | |
after(name: string, afterHook: AfterHook<any, any>): void | |
/** | |
* Add `wrap` hook for given `name` | |
*/ | |
wrap(name: string, wrapHook: WrapHook<any, any>): void | |
/** | |
* Remove added hook for given `name` | |
*/ | |
remove(name: string, hook: AnyHook<any, any, any>): void | |
} | |
export interface HookSingular<O, R, E> { | |
/** | |
* Invoke before and after hooks | |
*/ | |
(hookMethod: HookMethod<O, R>, options?: O): Promise<R> | |
/** | |
* Add `before` hook | |
*/ | |
before(beforeHook: BeforeHook<O>): void | |
/** | |
* Add `error` hook | |
*/ | |
error(errorHook: ErrorHook<O, E>): void | |
/** | |
* Add `after` hook | |
*/ | |
after(afterHook: AfterHook<O, R>): void | |
/** | |
* Add `wrap` hook | |
*/ | |
wrap(wrapHook: WrapHook<O, R>): void | |
/** | |
* Remove added hook | |
*/ | |
remove(hook: AnyHook<O, R, E>): void | |
} | |
type Collection = new () => HookCollection | |
type Singular = new <O = any, R = any, E = any>() => HookSingular<O, R, E> | |
interface Hook { | |
new (): HookCollection | |
/** | |
* Creates a collection of hooks | |
*/ | |
Collection: Collection | |
/** | |
* Creates a nameless hook that supports strict typings | |
*/ | |
Singular: Singular | |
} | |
export const Hook: Hook | |
export const Collection: Collection | |
export const Singular: Singular | |
export default Hook |