Sha256: c1e66bdacf9d97145682a7727e51fa703210a4f0a5ff4e403fadc8398fe7aad3

Contents?: true

Size: 960 Bytes

Versions: 56

Compression:

Stored size: 960 Bytes

Contents

/**
 * Copyright (c) 2014-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

let currentTypes = null;

export function wrapWithTypes(types, fn) {
  return function (...args) {
    const oldTypes = currentTypes;
    currentTypes = types;
    try {
      return fn.apply(this, args);
    } finally {
      currentTypes = oldTypes;
    }
  };
}

export function getTypes() {
  return currentTypes;
}

export function runtimeProperty(name) {
  const t = getTypes();
  return t.memberExpression(
    t.identifier("regeneratorRuntime"),
    t.identifier(name),
    false
  );
}

export function isReference(path) {
  return path.isReferenced() || path.parentPath.isAssignmentExpression({ left: path.node });
}

export function replaceWithOrRemove(path, replacement) {
  if (replacement) {
    path.replaceWith(replacement)
  } else {
    path.remove();
  }
}

Version data entries

56 entries across 55 versions & 11 rubygems

Version Path
immosquare-cleaner-0.1.62 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.61 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.60 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.59 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.58 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.57 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.56 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.55 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.54 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.53 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.52 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.51 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.50 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.49 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.48 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.47 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.46 node_modules/regenerator-transform/src/util.js
immosquare-cleaner-0.1.45 node_modules/regenerator-transform/src/util.js
optimacms-0.1.61 spec/dummy/node_modules/regenerator-transform/src/util.js
disco_app-0.18.0 test/dummy/node_modules/regenerator-transform/src/util.js