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

214
Vistas
How to require multiple exports from a module without naming all of them?

I'm requiring a lot of exports from a module as follows:

employee.js

// Some logic goes here
module.exports = {
    AvgEmployees,
    AvgDailyEmployee,
    AvgAbsenceEmployee,
    AvgWorkDaysEmpolyee,
    ...
    ..
    ..
};

main.js

const {
  AvgEmployees,
  AvgDailyEmployee,
  AvgAbsenceEmployee,
  AvgWorkDaysEmployee,
  ...
  ...
  ...
} = require('src/employee.js');

// Do what's needed with all the imports
// ....
// ...

I'm importing more than 50 imports and it starts to bother me every time to name all the imports.

Is it possible to import all of them at once without naming each one specifically ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Yes, like this:

const employee = require('src/employee.js');

// Do what's needed with all the imports
employee.AvgEmployees
employee.AvgDailyEmployee
// ....
// ...

Variable employee is the value of module.exports and const { ... } = require('src/employee.js'); is just object destructuring: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

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