Metakit / @doeixd/metakit

CommuteCondition

type · packages/metakit/src/ops/ways.ts:55

type CommuteCondition =
  | 'always'
  | 'one-kind'
  | 'same-literal'
  | 'different-literals'
  | 'in-range'
  | 'same-operation'
  | 'disjoint-fields'
  | 'steady'
  | 'reads-no-set-field'

When two writes to one path give one state in either order:

  • always;
  • one-kind: both values are known to be text, or both numbers (a set refuses a member of the other kind, at whichever write meets it first);
  • same-literal: both values are one literal;
  • different-literals: the two values are literals that differ;
  • in-range: the total and both amounts are integers, and the checker shows each total either order passes through stays in the safe range;
  • disjoint-fields: the two set different fields, and neither's key, test or set reads a field the other sets;
  • steady: no element can refuse either write (each key, key field, test and set is a value no operation refuses, as its Schema says), so neither removing what the other reads changes whether it is refused;
  • reads-no-set-field: the removal's key or test reads no field the patch sets, and the patch is steady.