download
raw
712 Bytes
'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) {
const result = func.apply(func, args)
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
}

Xet Storage Details

Size:
712 Bytes
·
Xet hash:
8d8daff1b2d1b52c4f8cc7491822145f6d4f686129ae112625a5d3d962773c21

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.