source: trip-planner-front/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/lib/index.js.map@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.7 KB
RevLine 
[6a3a178]1{"version":3,"file":"index.js","sources":["../src/util.ts","../src/index.ts"],"sourcesContent":["import { skipTransparentExprWrappers } from \"@babel/helper-skip-transparent-expression-wrappers\";\nimport type { NodePath } from \"@babel/traverse\";\nimport { types as t } from \"@babel/core\";\n// https://crbug.com/v8/11558\n\n// check if there is a spread element followed by another argument.\n// (...[], 0) or (...[], ...[])\n\nfunction matchAffectedArguments(argumentNodes) {\n const spreadIndex = argumentNodes.findIndex(node => t.isSpreadElement(node));\n return spreadIndex >= 0 && spreadIndex !== argumentNodes.length - 1;\n}\n\n/**\n * Check whether the optional chain is affected by https://crbug.com/v8/11558.\n * This routine MUST not manipulate NodePath\n *\n * @export\n * @param {(NodePath<t.OptionalMemberExpression | t.OptionalCallExpression>)} path\n * @returns {boolean}\n */\nexport function shouldTransform(\n path: NodePath<t.OptionalMemberExpression | t.OptionalCallExpression>,\n): boolean {\n let optionalPath: NodePath<t.Expression> = path;\n const chains = [];\n while (\n optionalPath.isOptionalMemberExpression() ||\n optionalPath.isOptionalCallExpression()\n ) {\n const { node } = optionalPath;\n chains.push(node);\n\n if (optionalPath.isOptionalMemberExpression()) {\n optionalPath = skipTransparentExprWrappers(optionalPath.get(\"object\"));\n } else if (optionalPath.isOptionalCallExpression()) {\n optionalPath = skipTransparentExprWrappers(optionalPath.get(\"callee\"));\n }\n }\n for (let i = 0; i < chains.length; i++) {\n const node = chains[i];\n if (\n t.isOptionalCallExpression(node) &&\n matchAffectedArguments(node.arguments)\n ) {\n // f?.(...[], 0)\n if (node.optional) {\n return true;\n }\n // o?.m(...[], 0)\n // when node.optional is false, chains[i + 1] is always well defined\n const callee = chains[i + 1];\n if (t.isOptionalMemberExpression(callee, { optional: true })) {\n return true;\n }\n }\n }\n return false;\n}\n","import { declare } from \"@babel/helper-plugin-utils\";\nimport { transform } from \"@babel/plugin-proposal-optional-chaining\";\nimport { shouldTransform } from \"./util\";\n\nexport default declare(api => {\n api.assertVersion(7);\n\n const noDocumentAll = api.assumption(\"noDocumentAll\");\n const pureGetters = api.assumption(\"pureGetters\");\n\n return {\n name: \"bugfix-v8-spread-parameters-in-optional-chaining\",\n\n visitor: {\n \"OptionalCallExpression|OptionalMemberExpression\"(path) {\n if (shouldTransform(path)) {\n transform(path, { noDocumentAll, pureGetters });\n }\n },\n },\n };\n});\n"],"names":["matchAffectedArguments","argumentNodes","spreadIndex","findIndex","node","t","isSpreadElement","length","shouldTransform","path","optionalPath","chains","isOptionalMemberExpression","isOptionalCallExpression","push","skipTransparentExprWrappers","get","i","arguments","optional","callee","declare","api","assertVersion","noDocumentAll","assumption","pureGetters","name","visitor","transform"],"mappings":";;;;;;;;;AAQA,SAASA,sBAAT,CAAgCC,aAAhC,EAA+C;AAC7C,QAAMC,WAAW,GAAGD,aAAa,CAACE,SAAd,CAAwBC,IAAI,IAAIC,UAAC,CAACC,eAAF,CAAkBF,IAAlB,CAAhC,CAApB;AACA,SAAOF,WAAW,IAAI,CAAf,IAAoBA,WAAW,KAAKD,aAAa,CAACM,MAAd,GAAuB,CAAlE;AACD;;AAUM,SAASC,eAAT,CACLC,IADK,EAEI;AACT,MAAIC,YAAoC,GAAGD,IAA3C;AACA,QAAME,MAAM,GAAG,EAAf;;AACA,SACED,YAAY,CAACE,0BAAb,MACAF,YAAY,CAACG,wBAAb,EAFF,EAGE;AACA,UAAM;AAAET,MAAAA;AAAF,QAAWM,YAAjB;AACAC,IAAAA,MAAM,CAACG,IAAP,CAAYV,IAAZ;;AAEA,QAAIM,YAAY,CAACE,0BAAb,EAAJ,EAA+C;AAC7CF,MAAAA,YAAY,GAAGK,mEAA2B,CAACL,YAAY,CAACM,GAAb,CAAiB,QAAjB,CAAD,CAA1C;AACD,KAFD,MAEO,IAA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