0) {
                  
                  
                      queue.push(command)
                  
                  
                      while (queue.length !== 0) {
                  
                  
                        const { stdout, stderr } = await exec(queue[0])
                  
                  
                        queue.shift()
                  
                  
                        console.log('command is done ' + `left: ${queue.length}`)
                  
                  
                      }
                  
                  
                    } else {
                  
                  
                      queue.push(command)
                  
                  
                    }
                  
                  
                  }
                  
                  
                  Можно как-нибудь улучшить? При запросе с командой. из контроллера вызывается scheduler(command)
                  
                  
                
shift дорогая операция
зачем while когда можно просто циклом пройти?
Обсуждают сегодня