{"version":3,"names":["declare","api","options","assertVersion","ignoreFunctionLength","assumption","loose","noNewArrows","name","visitor","Function","path","isArrowFunctionExpression","get","some","param","isRestElement","isAssignmentPattern","arrowFunctionToExpression","isFunctionExpression","convertedRest","convertFunctionRest","convertedParams","convertFunctionParams","scope","crawl"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport convertFunctionParams from \"./params\";\nimport convertFunctionRest from \"./rest\";\nexport { convertFunctionParams };\n\nexport interface Options {\n loose?: boolean;\n}\n\nexport default declare((api, options: Options) => {\n api.assertVersion(7);\n\n const ignoreFunctionLength =\n api.assumption(\"ignoreFunctionLength\") ?? options.loose;\n // Todo(BABEL 8): Consider default it to false\n const noNewArrows = (api.assumption(\"noNewArrows\") ?? true) as boolean;\n\n return {\n name: \"transform-parameters\",\n\n visitor: {\n Function(path) {\n if (\n path.isArrowFunctionExpression() &&\n path\n .get(\"params\")\n .some(param => param.isRestElement() || param.isAssignmentPattern())\n ) {\n // default/rest visitors require access to `arguments`, so it cannot be an arrow\n path.arrowFunctionToExpression({ noNewArrows });\n\n // In some cases arrowFunctionToExpression replaces the function with a wrapper.\n // Return early; the wrapped function will be visited later in the AST traversal.\n if (!path.isFunctionExpression()) return;\n }\n\n const convertedRest = convertFunctionRest(path);\n const convertedParams = convertFunctionParams(\n path,\n ignoreFunctionLength,\n );\n\n if (convertedRest || convertedParams) {\n // Manually reprocess this scope to ensure that the moved params are updated.\n path.scope.crawl();\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AAAyC,eAO1B,IAAAA,0BAAO,EAAC,CAACC,GAAG,EAAEC,OAAgB,KAAK;EAAA;EAChDD,GAAG,CAACE,aAAa,CAAC,CAAC,CAAC;EAEpB,MAAMC,oBAAoB,sBACxBH,GAAG,CAACI,UAAU,CAAC,sBAAsB,CAAC,8BAAIH,OAAO,CAACI,KAAK;EAEzD,MAAMC,WAAW,uBAAIN,GAAG,CAACI,UAAU,CAAC,aAAa,CAAC,+BAAI,IAAgB;EAEtE,OAAO;IACLG,IAAI,EAAE,sBAAsB;IAE5BC,OAAO,EAAE;MACPC,QAAQ,CAACC,IAAI,EAAE;QACb,IACEA,IAAI,CAACC,yBAAyB,EAAE,IAChCD,IAAI,CACDE,GAAG,CAAC,QAAQ,CAAC,CACbC,IAAI,CAACC,KAAK,IAAIA,KAAK,CAACC,aAAa,EAAE,IAAID,KAAK,CAACE,mBAAmB,EAAE,CAAC,EACtE;UAEAN,IAAI,CAACO,yBAAyB,CAAC;YAAEX;UAAY,CAAC,CAAC;;UAI/C,IAAI,CAACI,IAAI,CAACQ,oBAAoB,EAAE,EAAE;QACpC;QAEA,MAAMC,aAAa,GAAG,IAAAC,aAAmB,EAACV,IAAI,CAAC;QAC/C,MAAMW,eAAe,GAAG,IAAAC,eAAqB,EAC3CZ,IAAI,EACJP,oBAAoB,CACrB;QAED,IAAIgB,aAAa,IAAIE,eAAe,EAAE;UAEpCX,IAAI,CAACa,KAAK,CAACC,KAAK,EAAE;QACpB;MACF;IACF;EACF,CAAC;AACH,CAAC,CAAC;AAAA"}