UNPKG

aws-sdk-js-codemod

Version:

Collection of codemod scripts that help update AWS SDK for JavaScript APIs

21 lines (20 loc) 1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRequireDeclaratorsWithProperty = void 0; const requireModule_1 = require("./requireModule"); const getRequireDeclaratorsWithProperty = (j, source, { localName, identifierName, sourceValue }) => (0, requireModule_1.getRequireDeclarators)(j, source, sourceValue).filter((varDeclarator) => { const declaratorId = varDeclarator.value.id; const declaratorInit = varDeclarator.value.init; if (declaratorId.type === "Identifier") { const declaratorIdName = declaratorId.name; if (declaratorInit?.type === "MemberExpression" && declaratorInit.property.type === "Identifier") { const importedName = declaratorInit.property.name; if (localName === declaratorIdName && identifierName === importedName) { return true; } } } return false; }); exports.getRequireDeclaratorsWithProperty = getRequireDeclaratorsWithProperty;