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