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

170
Views
Establecer algo igual al valor de un método conocido con contenido conocido da como resultado un valor indefinido

Tengo un fragmento de código que genera objetos que entregan funciones, pero la variable de función extraída de la primera variable solo aparece como indefinida.

Al principio del código, se define un objeto para devolver un objeto que contiene funciones, siendo la función en este caso algo así como:

 /* Pulls in and sets up libraries like hapi, axios, lodash, joi, await-to-js */ /* CODE */ module.exports = { routes: () => { // This is in a set location used by a well established library return [ { 'handler': function (a, b) { return ((a - b)/12) } } ] } }

Un objeto es creado por una función en mis scripts de prueba:

 /* Pulls in and libraries like chai, chai expect, chance, to, sinon, proxyquire, and sinonChai */ /* CODE */ describe ('function fetcher', () => { it('should return a function', async () => { let testModule = proxyquire('../path-to-file/', {}) let myObject = await testModule.routes() // The library function that grabs the routes console.debug(typeof(myObject)) console.debug(myObject) let result = myObject.handler console.debug(typeof(result)) console.debug(result) result(chance.Number, chance.Number) /* More processing */ }) })

y vuelve

 /* OUTPUT */ object { handler: [Function: handler] } undefined undefined

Mi objetivo es hacer que esta línea funcione:

 /* CODE */ return result(a, b)
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!