skippable
Source Code | DocumentationSee also: predicates utils/addSkip
Wraps a hook so it can be conditionally skipped based on a predicate. When the predicate returns true, the wrapped hook is skipped entirely. Commonly used with shouldSkip and addSkip for runtime hook control.
import { skippable } from 'feathers-utils/hooks';Example
import { skippable, shouldSkip } from 'feathers-utils/predicates'
const myHook = skippable(someHook(), shouldSkip('someHook'))Type declaration
Show Type Declarations
/**
* Wraps a hook so it can be conditionally skipped based on a predicate.
* When the predicate returns `true`, the wrapped hook is skipped entirely.
* Commonly used with `shouldSkip` and `addSkip` for runtime hook control.
*
* @example
* ```ts
*
*
* const myHook = skippable(someHook(), shouldSkip('someHook'))
* ```
*
* @see https://utils.feathersjs.com/hooks/skippable.html
*/
export declare const skippable: <H extends HookContext = HookContext>(
hook: HookFunction<H>,
predicate: PredicateFn<H>,
) => (context: H, next?: NextFunction) => void | H | Promise<void | H>| Argument | Type | Description |
|---|---|---|
| hook | HookFunction<H> | |
| predicate | PredicateFn<H> |
| type | methods | multi |
|---|---|---|
| before, after, around | all | yes |
Predicates
skippable is a utility function that wraps a hook to make it skippable based on a passed predicate. This is useful when you want to conditionally skip the execution of a hook based on certain criteria, such as the presence of a specific parameter in the context.
'feathers-utils' provides a set of predicates that can be used with this utility.
| Predicate | Description |
|---|---|
every | Returns a predicate that is |
isContext | Returns a predicate that checks whether the hook context matches the given criteria.
You can filter by |
isMulti | Checks if the current hook context represents a multi operation.
Returns |
isPaginated | Checks if the current |
isProvider | Returns a predicate that checks the transport provider of the service call.
Matches against |
not | Negates a sync or async predicate function, inverting its boolean result. Useful for composing conditions like "not external" or "not multi". |
shouldSkip | Returns a predicate that checks |
some | Returns a predicate that is |
