Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Chrome 131
Windows
Desktop
5 months ago
Test name Executions per second
0 - 999 22710.2 Ops/sec
0 - 9999 2345.1 Ops/sec
0 - 99999 213.1 Ops/sec
0 - 999999 20.6 Ops/sec
Script Preparation code:
AخA
 
function* placeHolders(array) {
  if (array.every(n => n === 0)) array.unshift(1);
  let total = Number(array.join(""));
  for (let i = 0; i < total; i++) yield i;
}
Tests:
  • 0 - 999

     
    [...placeHolders([0, 0, 0])]
  • 0 - 9999

     
    [...placeHolders([0, 0, 0, 0])]
  • 0 - 99999

     
    [...placeHolders([0, 0, 0, 0, 0])]
  • 0 - 999999

     
    [...placeHolders([0, 0, 0, 0, 0, 0])]