The per-element conversion is compiled once via
createCoerceFunction(source.schema, targetSchema); if no automatic
conversion exists it throws — a developer error, callers that want to
probe first can call createCoerceFunction themselves and branch on null.
capacity sizes the new buffer (default: the source's). count is how many
leading elements to actually convert (default: everything in range) — a table
passes its live rowCount so unused rows (which may hold undefined in an
array buffer) are not run through the coercer; those slots stay at the new
buffer's zero/default init.
Source values are copied by reference into the new buffer (ECS component
values are never mutated in place); only newly-introduced fields get their own
cloned defaults. Width/precision loss (F64→F32, capped integers) is applied by
the destination buffer as coerced values are written.
Convert
sourceinto a NEW buffer oftargetSchema.The per-element conversion is compiled once via createCoerceFunction(source.schema, targetSchema); if no automatic conversion exists it throws — a developer error, callers that want to probe first can call
createCoerceFunctionthemselves and branch onnull.capacitysizes the new buffer (default: the source's).countis how many leading elements to actually convert (default: everything in range) — a table passes its liverowCountso unused rows (which may holdundefinedin an array buffer) are not run through the coercer; those slots stay at the new buffer's zero/default init.Source values are copied by reference into the new buffer (ECS component values are never mutated in place); only newly-introduced fields get their own cloned defaults. Width/precision loss (F64→F32, capped integers) is applied by the destination buffer as coerced values are written.