Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

93
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!