source: trip-planner-front/node_modules/regenerator-transform/lib/util.js@ 6c1585f

Last change on this file since 6c1585f 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
3exports.__esModule = true;
4exports.wrapWithTypes = wrapWithTypes;
5exports.getTypes = getTypes;
6exports.runtimeProperty = runtimeProperty;
7exports.isReference = isReference;
8exports.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 */
16var currentTypes = null;
17
18function 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
35function getTypes() {
36 return currentTypes;
37}
38
39function runtimeProperty(name) {
40 var t = getTypes();
41 return t.memberExpression(t.identifier("regeneratorRuntime"), t.identifier(name), false);
42}
43
44function isReference(path) {
45 return path.isReferenced() || path.parentPath.isAssignmentExpression({
46 left: path.node
47 });
48}
49
50function 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.