Largest padding target the padding methods accept, in graphemes.
This is the one place the class deliberately stops short of native. Native pads into a compact
character buffer and gives up only at V8's string limit (2**29 - 24); padding here builds one
array element per grapheme before joining, so the same target costs considerably more memory and
exhausts the heap well before reaching native's ceiling. Measured on the padding path: 2**16
costs ~2ms and ~1MB, 2**18 ~3ms and ~1MB, 2**20 ~9ms and ~9MB, and V8's own limit cannot be
reached at all.
A million graphemes of padding is already far past any display or formatting use, so the limit is
set where the cost is still negligible rather than where the engine finally gives out. Exceeding
it throws RangeError, as native does for its own limit.
Largest padding target the padding methods accept, in graphemes.
This is the one place the class deliberately stops short of native. Native pads into a compact character buffer and gives up only at V8's string limit (
2**29 - 24); padding here builds one array element per grapheme before joining, so the same target costs considerably more memory and exhausts the heap well before reaching native's ceiling. Measured on the padding path:2**16costs ~2ms and ~1MB,2**18~3ms and ~1MB,2**20~9ms and ~9MB, and V8's own limit cannot be reached at all.A million graphemes of padding is already far past any display or formatting use, so the limit is set where the cost is still negligible rather than where the engine finally gives out. Exceeding it throws
RangeError, as native does for its own limit.