Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

90
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda