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

139
Views
Ejecute un script en memoria de Node.JS desde el código de Node JS

Tengo 2 archivos, app.js y performance.js .

Quiero poner todo el código de performance.js en la memoria y, cuando sea necesario, ejecutar solicitudes que lleguen a app.js contra el código de performance.js IN MEMORY .

Aviso: ¡No quiero almacenar un archivo en la memoria y luego descargarlo en un archivo temporal!

rendimiento.js

 function sum_two(a,b) { return a+b; } module.exports = { sum_two, }

aplicación.js:

 // 1.Store performance.js in the memory somehow // HAPPENS ONLY ONCE! // 2.run against the memory the function sum_two // HAPPENS OVER AND OVER AGAIN const res = sum_two(1,2); console.log('Result:' , res);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use new vm.compileFunction(script)() , new Function(script)() o eval(script)

 // Example with esbuild esbuild.build(esbuildConfig).then(res => { res[0].outputFiles.map((f) => /\.m*js$/.test(f.path) && new vm.compileFunction(f.text)()) });
about 4 years ago · Juan Pablo Isaza Report
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!