Remote / foldkit-remote/maintained

classifyOperation

function · packages/remote/src/maintained/classify.ts:84

function classifyOperation(
  op: AnyOperation,
  options?: {
    readonly on?: 'insert' | 'delete' | undefined
    readonly implementations?: OperationImplementations | undefined
    readonly rewritePolicy?: Expr.ForeignRewritePolicy | undefined
  },
): Classification

Classify a custom reduce fold over a @doeixd/metakit/operation Operation, as its keeper runs it: a change is folded in where it arrives only where rewritePolicy applies the operation's commutative and associative claims, and a delete is taken back out only where it also applies invertible and the inverse is implemented.