source: imaps-frontend/node_modules/@babel/plugin-transform-nullish-coalescing-operator/lib/index.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.2 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7var _helperPluginUtils = require("@babel/helper-plugin-utils");
8var _core = require("@babel/core");
9var _default = exports.default = (0, _helperPluginUtils.declare)((api, {
10 loose = false
11}) => {
12 var _api$assumption, _api$assumption2;
13 api.assertVersion("^7.0.0-0 || >8.0.0-alpha <8.0.0-beta");
14 const noDocumentAll = (_api$assumption = api.assumption("noDocumentAll")) != null ? _api$assumption : loose;
15 const pureGetters = (_api$assumption2 = api.assumption("pureGetters")) != null ? _api$assumption2 : false;
16 return {
17 name: "transform-nullish-coalescing-operator",
18 manipulateOptions: (_, parser) => parser.plugins.push("nullishCoalescingOperator"),
19 visitor: {
20 LogicalExpression(path) {
21 const {
22 node,
23 scope
24 } = path;
25 if (node.operator !== "??") {
26 return;
27 }
28 let ref;
29 let assignment;
30 if (pureGetters && scope.path.isPattern() && _core.types.isMemberExpression(node.left) && !node.left.computed && _core.types.isIdentifier(node.left.object) && _core.types.isIdentifier(node.left.property) || _core.types.isIdentifier(node.left) && (pureGetters || scope.hasBinding(node.left.name))) {
31 ref = node.left;
32 assignment = _core.types.cloneNode(node.left);
33 } else if (scope.path.isPattern()) {
34 path.replaceWith(_core.template.statement.ast`(() => ${path.node})()`);
35 return;
36 } else {
37 ref = scope.generateUidIdentifierBasedOnNode(node.left);
38 scope.push({
39 id: _core.types.cloneNode(ref)
40 });
41 assignment = _core.types.assignmentExpression("=", ref, node.left);
42 }
43 path.replaceWith(_core.types.conditionalExpression(noDocumentAll ? _core.types.binaryExpression("!=", assignment, _core.types.nullLiteral()) : _core.types.logicalExpression("&&", _core.types.binaryExpression("!==", assignment, _core.types.nullLiteral()), _core.types.binaryExpression("!==", _core.types.cloneNode(ref), scope.buildUndefinedNode())), _core.types.cloneNode(ref), node.right));
44 }
45 }
46 };
47});
48
49//# sourceMappingURL=index.js.map
Note: See TracBrowser for help on using the repository browser.