jeudi 7 novembre 2019

How do I get the name of a javascript function passed in as a parameter? [duplicate]

This question already has an answer here:

Suppose I have a function:

function findUserByName( name ) { ... }

... which I'm passing in to be used by say a middleware function...


const DoAuthStuff = (findFunction) => (req, res, next) => {

  ... blah ...

  let user = findFunction(payload);

  ... blah ...

}

app.use(DoAuthStuff(findUserbyName));

Is it possible to determine the name of the function passed in? That is, within DoAuthStuff, can one differentiate between ...

app.use(DoAuthStuff(findUserbyName));

... and ...

app.use(DoAuthStuff(findUserbyID));




Aucun commentaire:

Enregistrer un commentaire