Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

91
Visualizações
Execution of fileReader being skipped

I'm trying to run addAttributes in the sequence that the code is written. The code enters the if statement but when it hits the reader it stops and goes the last if statement at the bottom of the code and executes it. After that executes it goes back to the file reader picks up from where it left off, processing the rest of the code that was skipped.

 const addAttributes = (_element) => {
      let selectedElement = _element.layer;
      
      var carPart;
      var speed = 0;
      var handling = 0;
      var acceleration = 0;
      

      if (selectedElement.name != null){
      
          const lineReader = require('line-reader');//SKIPS THIS
          lineReader.eachLine('doc.csv', function(rowItems, last) {
          
             carPart =  [rowItems.split(",")];

             carPart.forEach(dataCheck);
             function dataCheck(carPart){
             
                if ((carPart[0]) == selectedElement.name) {// must incloude random asset 
                  console.log(selectedElement.name);
                  console.log(carPart);
 
                   speed = speed + parseInt(carPart[ 1]);
                   handling = handling + parseInt(carPart[2]);
                   acceleration = acceleration + parseInt(carPart[3]);
    
                  console.log("speed " + speed)
                  console.log("handling " + handling)
                  console.log("acceleration " + acceleration)

                  if (speed != 0){
                    attributesList.push({trait_type: "Speed",Value: speed,})
                  }
        
                  if (handling !=0){
                    attributesList.push({trait_type: "Handling",Value: handling,})
                  }
        
                  if (acceleration != 0){
                    attributesList.push({trait_type: "Acceleration",Value: acceleration,})
                  }   
              }

            if(last){
              
              stop=false;
             }
            }            
          })
        }
            
      const layerAttributes = {
                trait_type: _element.layer.trait,
    value: selectedElement.traitValue,
    ...(_element.layer.display_type !== undefined && {
      display_type: _element.layer.display_type,
      }),
  };

  if (
    attributesList.some((attr) => attr.trait_type === layerAttributes.trait_type ))
    return;
      attributesList.push(layerAttributes);
   };
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda