Replace strings by views when you can
Briefly

In a Node.js runtime, precomputing the string representation of all 16-bit integers builds a sizable memory footprint. Instead, combine them into one string buffer.
Using a single string buffer for integer values significantly reduces memory use from 2 megabytes down to 382106 bytes, optimizing space effectively.
Though we could compute offsets on the fly, storing them consumes only 256 KB, which is minimal compared to the efficiency gained with a single string.
Benchmark results indicate that processing random values is significantly faster with a single large string, proving collective data storage enhances performance.
Read at Lemire
[
]
[
|
]