UNPKG

aws-sdk-js-codemod

Version:

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

20 lines (19 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.replaceAwsUtilArrayFunctions = void 0; const getAwsUtilCallExpression_1 = require("./getAwsUtilCallExpression"); const replaceAwsUtilArrayFunctions = (j, source, v2GlobalName) => { // replace arrayEach (0, getAwsUtilCallExpression_1.getAwsUtilCallExpression)(j, source, { v2GlobalName, functionName: "arrayEach" }) .filter(({ node }) => node.arguments.length === 2) .replaceWith(({ node }) => { const array = node.arguments[0]; const iteratee = node.arguments[1]; return j.callExpression(j.memberExpression(array, j.identifier("forEach")), [iteratee]); }); // replace arraySliceFn (0, getAwsUtilCallExpression_1.getAwsUtilCallExpression)(j, source, { v2GlobalName, functionName: "arraySliceFn" }) .filter(({ node }) => node.arguments.length === 1) .replaceWith(({ node }) => j.memberExpression(node.arguments[0], j.identifier("slice"))); }; exports.replaceAwsUtilArrayFunctions = replaceAwsUtilArrayFunctions;