nl_tokens: / * ! redolent <https : // github . com / tunnckoCore / redolent >
pl_tokens: function redolent ( fn , opts ) { if ( typeof fn !== 'function' ) { throw new TypeError ( 'redolent: expect `fn` to be a function' ) } opts = index$2 ( { context : this , Promise : Promize } , opts ) ; opts . Promise = register ( opts ) ; // we can't test that here, because some // of our devDeps has some Promise library, // so it's loaded by `native-or-another` automatically /* istanbul ignore next */ if ( typeof opts . Promise !== 'function' ) { var msg = 'no native Promise support nor other promise were found' ; throw new TypeError ( 'redolent: ' + msg ) } return function ( ) { opts . context = this || opts . context ; opts . args = index ( opts . args ) . concat ( index$1 ( arguments ) ) ; var promise = new opts . Promise ( function ( resolve , reject ) { var called = false ; function done ( er , res ) { called = true ; if ( er ) { return reject ( er ) } if ( arguments . length > 2 ) { <mask> = index$1 ( arguments , 1 ) ; } return resolve ( res ) } var isAsyncFn = index$5 ( fn ) ; opts . args = isAsyncFn ? opts . args . concat ( done ) : opts . args ; var syncResult = fn . apply ( opts . context , opts . args ) ; var xPromise = isPromise ( syncResult , opts . Promise ) ; var hasPromiseReturn = isAsyncFn && ! called && xPromise ; if ( ( ! isAsyncFn && ! called ) || hasPromiseReturn ) { resolve ( syncResult ) ; return } if ( isAsyncFn && ! xPromise && syncResult !== undefined ) { var msg = 'Asynchronous functions can only return a Promise or invoke a callback' ; reject ( new Error ( 'redolent: ' + msg ) ) ; } } ) ; return normalize ( promise , opts . Promise ) } }