You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varhooks=require('hooks');functionDoc(data){this.name=data.name;}// Add hooks' methods: `hook`, `pre`, and `post`for(varkinhooks){Doc[k]=hooks[k];}Doc.prototype.foo=function(){console.log('foo');this.name=this.name.toUpperCase();};Doc.prototype.getBar=function(){console.log('bar');return'bar';};Doc.pre('foo',function(next){console.log('pre foo');next();});Doc.pre('getBar',function(next){console.log('pre getBar');next();});vardoc=newDoc({name: 'Joe'});doc.foo();// goodconsole.log(doc.getBar());// prints return value of undefinedconsole.dir(doc);// { name: 'JOE' }
Output:
pre foo
foo
pre getBar
bar
undefined
{ name: 'JOE' }
Maybe I am doing something wrong...? Everything is executed correctly, but the return value ends up being undefined. Tried stepping through things and debugging it, not sure what happens. The return value is correct both in the ret in _done and in fnWrapper in once.
The text was updated successfully, but these errors were encountered:
With 0.3.2 and 0.2.1
Output:
Maybe I am doing something wrong...? Everything is executed correctly, but the return value ends up being
undefined
. Tried stepping through things and debugging it, not sure what happens. The return value is correct both in theret
in_done
and infnWrapper
inonce
.The text was updated successfully, but these errors were encountered: