-
I am writing a middleware. The middleware accepts two arguments, either a mongoose Model or a normal JavaScript function. function someMiddleware(arg1){
// here, how to differentiate?
if(typeof arg1 === 'function') console.log("it's a function")
} Mongoose models are functions, but I want the consumer of my someMiddleware function to be able to pass a model or a normal function. But how can I differentiate between both in my code? asked also on StackOverflow, but did not get a fulfilling answer: |
Beta Was this translation helpful? Give feedback.
Answered by
vkarpov15
Jul 11, 2022
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
samislam
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Object.getPrototypeOf(arg1) !== mongoose.Model