identityWhenever

Skip the filter when your own test of the props' values says so.

identityWhenever(
  props: string[],
  when: (values: Record<string, unknown>) =,
> boolean): IdentityRule

Import identityWhenever from shaders/std.

List in props every prop the test reads: a per-pixel mapped prop among them disables the skip, and the engine needs the list to know which.

Parameters

NameTypeNotes
propsstring[]
when(values: Record<string, unknown>) => boolean

Example

identityWhen: identityWhenever(['amount', 'mode'], (v) => v.amount === 0 || v.mode === 'off')

See also

  • isZero — Skip the filter entirely while prop is exactly 0.
  • isValue — Skip the filter entirely while prop equals value, for a filter whose no-op is not 0.
  • allOf — Skip the filter only while every rule holds, for a no-op that needs several props at rest.