Files
NapCatQQ/.pnpm-store/v3/files/21/79b92f812c84a53d75c6b015b46e1aaea968f6ab0946d2b17b50814d2950c39250bf48bf194894c7b3d01b0102bb22e036b4627c7c84112f0e92e3954fb38e
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

21 lines
619 B
Plaintext

'use strict'
const isInsidePromise = require('./is-inside-promise')
function isInsideCallback(node) {
const isFunction =
node.type === 'FunctionExpression' ||
node.type === 'ArrowFunctionExpression' ||
node.type === 'FunctionDeclaration' // this may be controversial
// it's totally fine to use promises inside promises
if (isInsidePromise(node)) return
const name = node.params && node.params[0] && node.params[0].name
const firstArgIsError = name === 'err' || name === 'error'
const isInACallback = isFunction && firstArgIsError
return isInACallback
}
module.exports = isInsideCallback