@adobe/data - v0.10.30
    Preparing search index...

    Function createCoerceFunction

    • Build a reusable value converter from an input schema to an output schema, or return null when no automatic conversion exists.

      The analysis is done ONCE, here; the returned function is a specialized closure meant to be applied to every element of a homogeneous collection (e.g. a TypedBuffer column) without re-inspecting the schemas per element. A null return IS the "not convertible" answer — there is no separate predicate.

      Supported automatic conversions:

      • number/integer → number/integer: pass-through; when the output declares minimum/maximum, values are clamped into range (so a narrowing like a capped integer keeps its cap). Precision/width loss (F64→F32, float→int) is applied by the destination buffer's typed-array write, not here.
      • boolean → boolean, string → string: identity.
      • enum → enum: only when every input value is also an output value.
      • → const: any input, every element becomes the output's const value.
      • object → object: per output property, convert the matching input property, or fill from the output property's default when the input lacks it. A new output property with no producible default ⇒ not convertible (null). Input-only properties are dropped; property order is irrelevant.
      • array → array: element-wise via items; a fixed-length output longer than a fixed-length input fills the extra slots from the item default (or is not convertible without one).

      Anything else — a change of kind (number↔object, number↔enum, …) — returns null. Cosmetic schema differences are irrelevant; only the value shape is.

      Parameters

      Returns null | ((value: unknown) => unknown)