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

140
Vistas
Run a Node.JS in-memory script from Node JS code

I have 2 files , app.js and performance.js.

I want to put all the code of performance.js in memory , and whenever needed run requests that reach to app.js against the code of performance.js IN MEMORY.

Notice: I don't want to store a file in memory and then download it into a temporary file!

performance.js

function sum_two(a,b) { 
    return a+b;
}

module.exports = { 
    sum_two,
}

app.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 Respuestas
Responde la pregunta

0

Use new vm.compileFunction(script)(), new Function(script)() or 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 Denunciar
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