This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
'use strict'
varslice=[].slice
module.exports=wrap
// Wrap `fn`.
// Can be sync or async; return a promise, receive a completion handler, return
// new values and errors.
functionwrap(fn,callback){
varinvoked
returnwrapped
functionwrapped(){
varparams=slice.call(arguments,0)
varcallback=fn.length>params.length
varresult
if(callback){
params.push(done)
}
try{
result=fn.apply(null,params)
}catch(error){
// Well, this is quite the pickle.
// `fn` received a callback and invoked it (thus continuing the pipeline),
// but later also threw an error.
// We’re not about to restart the pipeline again, so the only thing left