If you look at this line https://github.com/hapijs/hapi-auth-basic/blob/master/lib/index.js#L14 , you can see that it calls internals.implementation
without passing in any parameters, but the method has 2 parameters https://github.com/hapijs/hapi-auth-basic/blob/master/lib/index.js#L14 .
How does the method internals.implementation
work if no params are passed into it?
On line 14, internals.implementation
is not actually being called. Rather, a reference to the function is being passed to plugins.auth.scheme()
, presumably to be invoked later by the auth
plugin (where actual parameters will be passed).
For example, here's a simplified version:
function sampleImplementation(message) { alert(message); } function useImplementation(implementation, message) { implementation.apply(this, [message]); // invoke the function with args } useImplementation(sampleImplementation, "hey there!"); // should alert "hey there!"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.