Files
memecoin-botV2/.pnpm-store/v10/files/d0/8c56f60402da58cfaf9c791cf8d7fa8e9eba4b0fbaa0cd210870f6a35c48683005f5864ca5680d592ffd55ecf5c6cd5d807ccf1322df4acc75f2e690843d6c

99 lines
3.4 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseThenCall = parseThenCall;
exports.parseCatchCall = parseCatchCall;
exports.parseFinallyCall = parseFinallyCall;
const utils_1 = require("@typescript-eslint/utils");
const misc_1 = require("./misc");
/**
* Parses a syntactically possible `Promise.then()` call. Does not check the
* type of the callee.
*/
function parseThenCall(node, context) {
if (node.callee.type === utils_1.AST_NODE_TYPES.MemberExpression) {
const methodName = (0, misc_1.getStaticMemberAccessValue)(node.callee, context);
if (methodName === 'then') {
if (node.arguments.length >= 1) {
if (node.arguments[0].type === utils_1.AST_NODE_TYPES.SpreadElement) {
return {
object: node.callee.object,
};
}
if (node.arguments.length >= 2) {
if (node.arguments[1].type === utils_1.AST_NODE_TYPES.SpreadElement) {
return {
object: node.callee.object,
onFulfilled: node.arguments[0],
};
}
return {
object: node.callee.object,
onFulfilled: node.arguments[0],
onRejected: node.arguments[1],
};
}
return {
object: node.callee.object,
onFulfilled: node.arguments[0],
};
}
return {
object: node.callee.object,
};
}
}
return undefined;
}
/**
* Parses a syntactically possible `Promise.catch()` call. Does not check the
* type of the callee.
*/
function parseCatchCall(node, context) {
if (node.callee.type === utils_1.AST_NODE_TYPES.MemberExpression) {
const methodName = (0, misc_1.getStaticMemberAccessValue)(node.callee, context);
if (methodName === 'catch') {
if (node.arguments.length >= 1) {
if (node.arguments[0].type === utils_1.AST_NODE_TYPES.SpreadElement) {
return {
object: node.callee.object,
};
}
return {
object: node.callee.object,
onRejected: node.arguments[0],
};
}
return {
object: node.callee.object,
};
}
}
return undefined;
}
/**
* Parses a syntactically possible `Promise.finally()` call. Does not check the
* type of the callee.
*/
function parseFinallyCall(node, context) {
if (node.callee.type === utils_1.AST_NODE_TYPES.MemberExpression) {
const methodName = (0, misc_1.getStaticMemberAccessValue)(node.callee, context);
if (methodName === 'finally') {
if (node.arguments.length >= 1) {
if (node.arguments[0].type === utils_1.AST_NODE_TYPES.SpreadElement) {
return {
object: node.callee.object,
};
}
return {
object: node.callee.object,
onFinally: node.arguments[0],
};
}
return {
object: node.callee.object,
};
}
}
return undefined;
}