Skip to content

unless

Category
Export size
min 0.97 kB · gzip 0.52 kB
See also

Executes a series of hooks when the predicate is falsy --- the inverse of iff. The predicate can be a boolean or a sync/async function. Useful for applying hooks to all contexts except those matching a condition.

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

Example

ts
import { unless, isProvider } from 'feathers-utils/predicates'

app.service('users').hooks({
  before: { all: [unless(isProvider('server'), authenticate('jwt'))] }
})

Type declaration

Show Type Declarations
ts
/**
 * Executes a series of hooks when the predicate is falsy --- the inverse of `iff`.
 * The predicate can be a boolean or a sync/async function.
 * Useful for applying hooks to all contexts except those matching a condition.
 *
 * @example
 * ```ts
 *
 *
 * app.service('users').hooks({
 *   before: { all: [unless(isProvider('server'), authenticate('jwt'))] }
 * })
 * ```
 *
 * @see https://utils.feathersjs.com/hooks/unless.html
 */
export declare function unless<H extends HookContext = HookContext>(
  predicate: boolean | PredicateFn,
  ...hooks: HookFunction<H>[]
): (this: any, ctx: HookContext, next?: HookContext) => any
ArgumentTypeDescription
predicateboolean | PredicateFn
hooksHookFunction<H>[]
typemethodsmulti
before, afterallyes

Released under the MIT License.