source: trip-planner-front/node_modules/regenerator-transform/src/util.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 960 bytes
Line 
1/**
2 * Copyright (c) 2014-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8let currentTypes = null;
9
10export function wrapWithTypes(types, fn) {
11 return function (...args) {
12 const oldTypes = currentTypes;
13 currentTypes = types;
14 try {
15 return fn.apply(this, args);
16 } finally {
17 currentTypes = oldTypes;
18 }
19 };
20}
21
22export function getTypes() {
23 return currentTypes;
24}
25
26export function runtimeProperty(name) {
27 const t = getTypes();
28 return t.memberExpression(
29 t.identifier("regeneratorRuntime"),
30 t.identifier(name),
31 false
32 );
33}
34
35export function isReference(path) {
36 return path.isReferenced() || path.parentPath.isAssignmentExpression({ left: path.node });
37}
38
39export function replaceWithOrRemove(path, replacement) {
40 if (replacement) {
41 path.replaceWith(replacement)
42 } else {
43 path.remove();
44 }
45}
Note: See TracBrowser for help on using the repository browser.