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

155
Views
Función de llamada dentro de Promesa y resolución

Tengo una función que lee varios archivos json . Ahora quiero modificarlo para que también pueda leer archivos csv . Tengo otra función que convierte texto en matrices json. Estoy tratando de hacer esto, pero recibo un error Property 'csvtoarray' does not exist on type 'FileReader'.ts(2339)

 readFile(reader: FileReader, file: File) { const deferredResult = new Promise(resolve => { reader.addEventListener('load', function getResult() { console.log(file) if(file["type"] == "application/json"){ resolve(reader.result as string)} else if(file["type"]=="text/csv"){ resolve(this.csvtoarray(reader.result)) } reader.removeEventListener('load', getResult) }) })

¿Cómo puedo llamar a mi función que convierte texto en matrices json en esta función readFile ?

Mi función que convierte texto en matrices json es:

 csvtoarray(str,delimiter=','){ const headers = str.slice(0,str.indexOf("\n")).split(delimiter) const rows = str.slice(str.indexOf("\n") + 1).split("\n") const arr = rows.map(function(row) { const values = row.split(delimiter); const el = headers.reduce(function(object,header,index){ object[header] = values[index]; return object },{}); return el }); return arr }
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!