String.prototype.slice on the same offsets is wrong for any text
containing an astral-plane character, and passes every ASCII test — which
is why anchor fields are named startCodePoint / endCodePoint and why
this helper exists. Offsets are clamped rather than rejected; range
checking against a document belongs to the origin library's validation.
Slices a string by code-point offsets.
String.prototype.sliceon the same offsets is wrong for any text containing an astral-plane character, and passes every ASCII test — which is why anchor fields are namedstartCodePoint/endCodePointand why this helper exists. Offsets are clamped rather than rejected; range checking against a document belongs to the origin library's validation.