UNPKG

aws-sdk-js-codemod

Version:

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

40 lines (39 loc) 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getImportSpecifiers = void 0; const getImportDeclarations_1 = require("./getImportDeclarations"); const getImportSpecifiers = (j, source, path) => { const importSpecifiers = new Set(); (0, getImportDeclarations_1.getImportDeclarations)(j, source, path).forEach((importDeclaration) => { const specifiers = importDeclaration.value.specifiers || []; for (const specifier of specifiers) { switch (specifier.type) { case "ImportSpecifier": { const importedName = specifier.imported.name; const localName = specifier.local?.name; if (typeof importedName !== "string" || (localName && typeof localName !== "string")) { throw new Error("Please report your use case on https://github.com/aws/aws-sdk-js-codemod"); } importSpecifiers.add({ importedName, localName: localName || importedName, }); break; } case "ImportNamespaceSpecifier": case "ImportDefaultSpecifier": { if (specifier.local) { const localName = specifier.local.name; if (typeof localName !== "string") { throw new Error("Please report your use case on https://github.com/aws/aws-sdk-js-codemod"); } importSpecifiers.add({ localName }); } break; } } } }); return Array.from(importSpecifiers); }; exports.getImportSpecifiers = getImportSpecifiers;