util.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.runtimeProperty = runtimeProperty;
  4. exports.isReference = isReference;
  5. exports.replaceWithOrRemove = replaceWithOrRemove;
  6. var _babelTypes = require("babel-types");
  7. var t = _interopRequireWildcard(_babelTypes);
  8. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  9. function runtimeProperty(name) {
  10. return t.memberExpression(t.identifier("regeneratorRuntime"), t.identifier(name), false);
  11. } /**
  12. * Copyright (c) 2014, Facebook, Inc.
  13. * All rights reserved.
  14. *
  15. * This source code is licensed under the BSD-style license found in the
  16. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  17. * additional grant of patent rights can be found in the PATENTS file in
  18. * the same directory.
  19. */
  20. function isReference(path) {
  21. return path.isReferenced() || path.parentPath.isAssignmentExpression({ left: path.node });
  22. }
  23. function replaceWithOrRemove(path, replacement) {
  24. if (replacement) {
  25. path.replaceWith(replacement);
  26. } else {
  27. path.remove();
  28. }
  29. }