Skip to main content

hookable

JavaScript / TypeScript API reference for the module hookable.

Public API

Class: Hookable

Canonical path: hookable.Hookable

Declared in: src/hookable.ts

Signature

class Hookable <
HooksT = Record<string, HookCallback>,
HookNameT extends HookKeys<HooksT> = HookKeys<HooksT>
> {}

Constructor: constructor

Canonical path: hookable.Hookable.constructor

Declared in: src/hookable.ts

Signature

constructor () {}

Function: createDebugger

Canonical path: hookable.createDebugger

Declared in: src/utils.ts

Signature

function createDebugger (hooks: Hookable<any>, _options: CreateDebuggerOptions = {}) {}

Function: createHooks

Canonical path: hookable.createHooks

Declared in: src/hookable.ts

Signature

function createHooks<T> (): Hookable<T> {}

Function: flatHooks

Canonical path: hookable.flatHooks

Declared in: src/utils.ts

Signature

function flatHooks<T> (configHooks: NestedHooks<T>, hooks: T = {} as T, parentName?: string): T {}

Function: mergeHooks

Canonical path: hookable.mergeHooks

Declared in: src/utils.ts

Signature

function mergeHooks<T> (...hooks: NestedHooks<T>[]): T {}

Function: parallelCaller

Canonical path: hookable.parallelCaller

Declared in: src/utils.ts

Signature

function parallelCaller (hooks: HookCallback[], args?: any[]) {}

Function: serial

Canonical path: hookable.serial

Declared in: src/utils.ts

Signature

function serial<T> (tasks: T[], fn: (task: T) => Promise<any> | any) {}

Function: serialCaller

Canonical path: hookable.serialCaller

Declared in: src/utils.ts

Signature

function serialCaller (hooks: HookCallback[], args?: any[]) {}

Interface: CreateDebuggerOptions

Canonical path: hookable.CreateDebuggerOptions

Declared in: src/types.ts

Signature

interface CreateDebuggerOptions {
/** An optional tag to prefix console logs with */
tag?: string
/**
* Show hook params to the console output
*
* Enabled for browsers by default
*/
inspect?: boolean
/**
* Use group/groupEnd wrapper around logs happening during a specific hook
*
* Enabled for browsers by default
*/
group?: boolean
/** Filter which hooks to enable debugger for. Can be a string prefix or fn. */
filter?: string | ((event: string) => boolean)
}

Interface: Hooks

Canonical path: hookable.Hooks

Declared in: src/types.ts

Signature

interface Hooks { [key: string]: HookCallback }

Method: addHooks

Canonical path: hookable.Hookable.addHooks

Declared in: src/hookable.ts

Signature

addHooks (configHooks: NestedHooks<HooksT>) {}

Method: afterEach

Canonical path: hookable.Hookable.afterEach

Declared in: src/hookable.ts

Signature

afterEach (fn: (event: InferSpyEvent<HooksT>) => void) {}

Method: beforeEach

Canonical path: hookable.Hookable.beforeEach

Declared in: src/hookable.ts

Signature

beforeEach (fn: (event: InferSpyEvent<HooksT>) => void) {}

Method: callHook

Canonical path: hookable.Hookable.callHook

Declared in: src/hookable.ts

Signature

callHook<NameT extends HookNameT> (name: NameT, ...args: Parameters<InferCallback<HooksT, NameT>>): Promise<any> {}

Method: callHookParallel

Canonical path: hookable.Hookable.callHookParallel

Declared in: src/hookable.ts

Signature

callHookParallel<NameT extends HookNameT> (name: NameT, ...args: Parameters<InferCallback<HooksT, NameT>>): Promise<any[]> {}

Method: callHookWith

Canonical path: hookable.Hookable.callHookWith

Declared in: src/hookable.ts

Signature

callHookWith<NameT extends HookNameT, CallFunction extends (hooks: HookCallback[], args: Parameters<InferCallback<HooksT, NameT>>) => any> (caller: CallFunction, name: NameT, ...args: Parameters<InferCallback<HooksT, NameT>>): ReturnType<CallFunction> {}

Method: deprecateHook

Canonical path: hookable.Hookable.deprecateHook

Declared in: src/hookable.ts

Signature

deprecateHook <NameT extends HookNameT> (name: NameT, deprecated: HookKeys<HooksT> | DeprecatedHook<HooksT>) {}

Method: deprecateHooks

Canonical path: hookable.Hookable.deprecateHooks

Declared in: src/hookable.ts

Signature

deprecateHooks (deprecatedHooks: Partial<Record<HookNameT, DeprecatedHook<HooksT>>>) {}

Method: hook

Canonical path: hookable.Hookable.hook

Declared in: src/hookable.ts

Signature

hook<NameT extends HookNameT> (name: NameT, fn: InferCallback<HooksT, NameT>, opts: { allowDeprecated?: boolean } = {}) {}

Method: hookOnce

Canonical path: hookable.Hookable.hookOnce

Declared in: src/hookable.ts

Signature

hookOnce<NameT extends HookNameT> (name: NameT, fn: InferCallback<HooksT, NameT>) {}

Method: removeHook

Canonical path: hookable.Hookable.removeHook

Declared in: src/hookable.ts

Signature

removeHook<NameT extends HookNameT> (name: NameT, fn: InferCallback<HooksT, NameT>) {}

Method: removeHooks

Canonical path: hookable.Hookable.removeHooks

Declared in: src/hookable.ts

Signature

removeHooks (configHooks: NestedHooks<HooksT>) {}

Type Alias: DeprecatedHook

Canonical path: hookable.DeprecatedHook

Declared in: src/types.ts

Signature

type DeprecatedHook<T> = { message?: string, to: HookKeys<T> }

Type Alias: DeprecatedHooks

Canonical path: hookable.DeprecatedHooks

Declared in: src/types.ts

Signature

type DeprecatedHooks<T> = { [name in HookKeys<T>]: DeprecatedHook<T> }

Type Alias: HookCallback

Canonical path: hookable.HookCallback

Declared in: src/types.ts

Signature

type HookCallback = (...args: any) => Promise<void> | void

Type Alias: HookKeys

Canonical path: hookable.HookKeys

Declared in: src/types.ts

Signature

type HookKeys<T> = keyof T & string

Type Alias: NestedHooks

Canonical path: hookable.NestedHooks

Declared in: src/types.ts

Signature

type NestedHooks<T> =
(Partial<StripGeneric<T>> | Partial<OnlyGeneric<T>>) &
Partial<{ [key in Namespaces<StripGeneric<T>>]: NestedHooks<WithoutNamespace<T, key>> }> &
Partial<{ [key in BareHooks<StripGeneric<T>>]: T[key] }>