// Returns a wrapper function that returns a wrapped callback// The wrapper function should do some stuff, and return a// presumably different callback function.// This makes sure that own properties are retained, so that// decorations and such are not lost along the way.module.exports=wrappyfunctionwrappy(fn,cb){if(fn&&cb)returnwrappy(fn)(cb)if(typeoffn!=='function')thrownewTypeError('need wrapper function')Object.keys(fn).forEach(function(k){wrapper[k]=fn[k]})returnwrapperfunctionwrapper(){varargs=newArray(arguments.length)for(vari=0;i<args.length;i++){args[i]=arguments[i]}varret=fn.apply(this,args)varcb=args[args.length-1]if(typeofret==='function'&&ret!==cb){Object.keys(cb).forEach(function(k){ret[k]=cb[k]})}returnret}}