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:
1.3 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | exports.__esModule = true;
|
---|
4 | exports.wrapWithTypes = wrapWithTypes;
|
---|
5 | exports.getTypes = getTypes;
|
---|
6 | exports.runtimeProperty = runtimeProperty;
|
---|
7 | exports.isReference = isReference;
|
---|
8 | exports.replaceWithOrRemove = replaceWithOrRemove;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Copyright (c) 2014-present, Facebook, Inc.
|
---|
12 | *
|
---|
13 | * This source code is licensed under the MIT license found in the
|
---|
14 | * LICENSE file in the root directory of this source tree.
|
---|
15 | */
|
---|
16 | var currentTypes = null;
|
---|
17 |
|
---|
18 | function wrapWithTypes(types, fn) {
|
---|
19 | return function () {
|
---|
20 | var oldTypes = currentTypes;
|
---|
21 | currentTypes = types;
|
---|
22 |
|
---|
23 | try {
|
---|
24 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
---|
25 | args[_key] = arguments[_key];
|
---|
26 | }
|
---|
27 |
|
---|
28 | return fn.apply(this, args);
|
---|
29 | } finally {
|
---|
30 | currentTypes = oldTypes;
|
---|
31 | }
|
---|
32 | };
|
---|
33 | }
|
---|
34 |
|
---|
35 | function getTypes() {
|
---|
36 | return currentTypes;
|
---|
37 | }
|
---|
38 |
|
---|
39 | function runtimeProperty(name) {
|
---|
40 | var t = getTypes();
|
---|
41 | return t.memberExpression(t.identifier("regeneratorRuntime"), t.identifier(name), false);
|
---|
42 | }
|
---|
43 |
|
---|
44 | function isReference(path) {
|
---|
45 | return path.isReferenced() || path.parentPath.isAssignmentExpression({
|
---|
46 | left: path.node
|
---|
47 | });
|
---|
48 | }
|
---|
49 |
|
---|
50 | function replaceWithOrRemove(path, replacement) {
|
---|
51 | if (replacement) {
|
---|
52 | path.replaceWith(replacement);
|
---|
53 | } else {
|
---|
54 | path.remove();
|
---|
55 | }
|
---|
56 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.