Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.default = shouldStoreRHSInTemporaryVariable;
|
---|
7 |
|
---|
8 | var _core = require("@babel/core");
|
---|
9 |
|
---|
10 | function shouldStoreRHSInTemporaryVariable(node) {
|
---|
11 | if (_core.types.isArrayPattern(node)) {
|
---|
12 | const nonNullElements = node.elements.filter(element => element !== null);
|
---|
13 | if (nonNullElements.length > 1) return true;else return shouldStoreRHSInTemporaryVariable(nonNullElements[0]);
|
---|
14 | } else if (_core.types.isObjectPattern(node)) {
|
---|
15 | if (node.properties.length > 1) return true;else if (node.properties.length === 0) return false;else return shouldStoreRHSInTemporaryVariable(node.properties[0]);
|
---|
16 | } else if (_core.types.isObjectProperty(node)) {
|
---|
17 | return shouldStoreRHSInTemporaryVariable(node.value);
|
---|
18 | } else if (_core.types.isAssignmentPattern(node)) {
|
---|
19 | return shouldStoreRHSInTemporaryVariable(node.left);
|
---|
20 | } else if (_core.types.isRestElement(node)) {
|
---|
21 | if (_core.types.isIdentifier(node.argument)) return true;
|
---|
22 | return shouldStoreRHSInTemporaryVariable(node.argument);
|
---|
23 | } else {
|
---|
24 | return false;
|
---|
25 | }
|
---|
26 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.