Skip to content

skippable

Source Code | Documentation

See also: predicates addSkip

Wrap a hook to make it skippable

ts
  import { 
skippable
} from 'feathers-utils/hooks';

Type declaration

ts
/**
 * Wrap a hook to make it skippable
 */
export declare const skippable: <H extends HookContext = HookContext>(
  hook: HookFunction<H>,
  predicate: PredicateFn<H>,
) => (context: H, next?: NextFunction) => void | H | Promise<void | H>
ArgumentTypeDescription
hookHookFunction<H>
predicatePredicateFn<H>

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.

every

Return the and of a series of sync or async predicate functions.

isContext

Check if the context matches the given options.

isMulti

util to check if a hook is a multi hook:

  • find: true
  • get: false
  • create: context.data is an array
  • update: false
  • patch: context.id == null
  • remove: context.id == null
isPaginated

util to check if a hook is a paginated hook using getPaginate

isProvider

Check which transport provided the service call.

not

Negate a predicate function.

shouldSkip

Util to detect if a hook should be skipped

Checks the params.skipHooks array for the hook name, type, or 'all'.

some

Return the or of a series of sync or async predicate functions.

Released under the MIT License.