The package's original implementation[1] also seems like it would have resulted in O(n^2) operation rather than desired O(n).
That linear-time operation is then additionally repeated `len` times
In practice, memory allocators tend to double the size of an allocation like this, which is still quadratic.
In practice, JS runtimes also tend to use data structures like Ropes for strings to handle this sort of issue. That brings it down to linear time in practice (I think?)