Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
998 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.default = _default;
|
---|
7 |
|
---|
8 | var _helperExplodeAssignableExpression = require("@babel/helper-explode-assignable-expression");
|
---|
9 |
|
---|
10 | var _t = require("@babel/types");
|
---|
11 |
|
---|
12 | const {
|
---|
13 | assignmentExpression,
|
---|
14 | sequenceExpression
|
---|
15 | } = _t;
|
---|
16 |
|
---|
17 | function _default(opts) {
|
---|
18 | const {
|
---|
19 | build,
|
---|
20 | operator
|
---|
21 | } = opts;
|
---|
22 | return {
|
---|
23 | AssignmentExpression(path) {
|
---|
24 | const {
|
---|
25 | node,
|
---|
26 | scope
|
---|
27 | } = path;
|
---|
28 | if (node.operator !== operator + "=") return;
|
---|
29 | const nodes = [];
|
---|
30 | const exploded = (0, _helperExplodeAssignableExpression.default)(node.left, nodes, this, scope);
|
---|
31 | nodes.push(assignmentExpression("=", exploded.ref, build(exploded.uid, node.right)));
|
---|
32 | path.replaceWith(sequenceExpression(nodes));
|
---|
33 | },
|
---|
34 |
|
---|
35 | BinaryExpression(path) {
|
---|
36 | const {
|
---|
37 | node
|
---|
38 | } = path;
|
---|
39 |
|
---|
40 | if (node.operator === operator) {
|
---|
41 | path.replaceWith(build(node.left, node.right));
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 | };
|
---|
46 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.